觉醒时刻
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

246 lines
10 KiB

1 week ago
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
import EventMgr from "../../FrameWork/Event/EventMgr";
import User from "../../FrameWork/User/User";
import Common5 from "../../Platform/th/Common5";
import TouZiXieYiShu from "../GameMethodRes/TouZiXieYiShu/TouZiXieYiShu";
import GameBaseScript from "../GameRoomRes/GameBaseScript";
import guiyin from "../GameRoomRes/SuiPian/guiyin";
import xiangyin from "../GameRoomRes/SuiPian/xiangyin";
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager";
import BagManager from "../Manager/BagManager";
import UserManager from "../Manager/UserManager";
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
import GetAward from "../SCommon/GetAward";
import DHBase from "./DHBase";
const { ccclass, property } = cc._decorator;
let needIDs = [
{
goodids: [3016, 3017, 3018],
tiaoZhuanGameType: GameType.CiShanChouJiang,
huoYuan: '慈善抽奖',
}
]
@ccclass
export default class DH_5 extends DHBase {
chatConfig = [
{ effectUrl: 'DH/DH_5/sound/你怎么喝成这样?', delayTime: 1.88, str: '你怎么喝成这样?', posi: '-1' },
{ effectUrl: 'DH/DH_5/sound/我爸催婚呢,可你这个小男人合适吗?', delayTime: 6.5, str: '我爸催婚呢,可你这个小男人合适吗?', posi: 'qipao2' },
{ effectUrl: 'DH/DH_5/sound/(咳嗽),那个,我有若若了', delayTime: 3.4, str: '(咳嗽),那个,我有若若了', posi: '-1' },
{ effectUrl: 'DH/DH_5/sound/哼,胆小鬼!这是象印的地址,赶紧滚!', delayTime: 6.5, str: '哼,胆小鬼!这是象印的地址,赶紧滚!', posi: 'qipao2' },
// { effectUrl: 'DH/DH_5/sound/第二件物品是坤瓷,找到就有投资,去吧。', delayTime: 3, str: '第二件物品是坤瓷,找到就有投资,去吧。', posi: 'qipao2' },
]
@property(cc.Node)
needLayer: cc.Node = null;
@property(cc.Node)
singleItem: cc.Node = null;
@property(cc.ScrollView)
m_ScrollView: cc.ScrollView = null;
@property(cc.Node)
touziren: cc.Node = null;
curNeedID: number = -1;
start() {
this.scheduleOnce(() => {
PrefabManage.preloadPrefabByType(GameType.DH_6)
})
GameBaseScript.preLoadRemoteAudioByChatConfig(this.chatConfig);
super.start();
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if (mainId == MainTaskIdEnum.MainTask_502) {
this.continueStory();
} else {
}
// this.scheduleOnce(() => {
// PrefabManage.preloadPrefabByType(GameType.DH_59)
// })
this.refreshNeedLayer()
EventMgr.onEvent_custom(ryw_Event.refreshNeedLayer, () => {
this.refreshNeedLayer()
}, this)
}
refreshNeedLayer() {
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if (mainId == MainTaskIdEnum.MainTask_503 || mainId == MainTaskIdEnum.MainTask_504) {
this.curNeedID = 0
}
if (this.curNeedID >= 0) {
this.needLayer.active = true
this.needLayer.getChildByName("huanYuanNode").getChildByName("huoYuan").getComponent(cc.Label).string = needIDs[this.curNeedID].huoYuan
this.initItemContent()
} else {
this.needLayer.active = false
}
}
initItemContent() {
this.m_ScrollView.content.removeAllChildren()
let isAllFind = true
let propIdArr = needIDs[this.curNeedID].goodids
this.needLayer.getChildByName("huanYuanNode").getChildByName("huoYuan").getComponent(cc.Label).string = needIDs[this.curNeedID].huoYuan
for (let i = 0; i < propIdArr.length; i++) {
let item = cc.instantiate(this.singleItem)
item.active = true
item.parent = this.m_ScrollView.content
let spFrame_hui = item.getChildByName('spFrame_hui')
let spFrame_liang = item.getChildByName('spFrame_liang')
Common5.setRemoteSpriteFrame(spFrame_hui.getComponent(cc.Sprite), 'GoodIcon/' + propIdArr[i])
Common5.setRemoteSpriteFrame(spFrame_liang.getComponent(cc.Sprite), 'GoodIcon/' + propIdArr[i])
let _pro = BagManager.getGoodsProperty(propIdArr[i])
item.getChildByName('nameStr').getComponent(cc.Label).string = _pro.goodName
if (BagManager.getBagGoodNums(propIdArr[i]) > 0) {
spFrame_liang.active = true
spFrame_hui.active = false
} else {
isAllFind = false
spFrame_liang.active = false
spFrame_hui.active = true
}
}
if (isAllFind) {
this.needLayer.getChildByName("按钮").active = true
this.needLayer.getChildByName("huanYuanNode").active = false
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
}
}
// 继续剧情
continueStory() {
let touzirenSpine = this.touziren.getComponent(sp.Skeleton)
touzirenSpine.setAnimation(0, "扶男主待机", true)
const dialogEvents = [
(func) => {
this.showClickDialog(this.chatConfig[this.dialogIndex++], func, () => {
});
},
(func) => {
this.showQiPao(this.chatConfig[this.dialogIndex++], func, () => {
touzirenSpine.setAnimation(0, "扶男主不笑说话", true)
});
},
(func) => {
touzirenSpine.setAnimation(0, "扶男主待机", true)
this.showClickDialog(this.chatConfig[this.dialogIndex++], func, () => {
});
},
(func) => {
this.showQiPao(this.chatConfig[this.dialogIndex++], func, () => {
touzirenSpine.setAnimation(0, "扶男主不笑说话", true)
});
},
(func) => {
touzirenSpine.setAnimation(0, "扶男主待机", true)
func()
},
]
const dialogCallFunc = (logEvents: any[]) => {
logEvents.shift()(() => {
if (logEvents.length > 0) {
dialogCallFunc(logEvents);
} else {
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_502)
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_503)
this.refreshNeedLayer()
// PrefabManage.showBlackGuoDu(() => {
// PrefabManage.loadPrefabByType(GameType.CityPrefab)
// this.node.destroy()
// })
}
});
}
dialogCallFunc(dialogEvents);
}
onTouchSubmit() {
//碎片合并
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
let goodArray = []
if (mainId == MainTaskIdEnum.MainTask_504) {//象印
goodArray = [{ goodId: 3021, goodNum: 1 }]
}
this.needLayer.active = false
//播放合成动画
PrefabManage.loadPrefabByType(GameType.xiangyin, this.node, (node) => {
node.getComponent(xiangyin).run(this.m_ScrollView.content.children, () => {
this.scheduleOnce(() => {
PrefabManage.loadPrefabByType(GameType.GetAward, null, (prefabNode) => {
prefabNode.getComponent('GetAward').initView(goodArray, () => {
//播放完再显示投资协议书
PrefabManage.loadPrefabByType(GameType.TouZiXieYiShu, null, (prefab) => {
let money = 700000
prefab.getComponent(TouZiXieYiShu).initView("叶氏食品厂", money, () => {
UserManager.addMoney(money)
PrefabManage.showTextTips(`恭喜获得投资${Common5.getNumberChangeHanzi(money, '1')}`)
this["continueStory3"]();
})
})
});
})
}, 1)
})
})
}
// 继续剧情
continueStory3() {
let touziren = this.touziren
let touzirenSpine = touziren.getComponent(sp.Skeleton)
touzirenSpine.setAnimation(0, "扶男主待机", true)
const dialogEvents = [
// (func) => {
// this.showQiPao(this.chatConfig.chatConfig_4[this.dialogIndex++], func, () => {
// touzirenSpine.setAnimation(0, "扶男主不笑说话", true)
// });
// },
(func) => {
touzirenSpine.setAnimation(0, "扶男主待机", true)
func()
},
]
const dialogCallFunc = (logEvents: any[]) => {
logEvents.shift()(() => {
if (logEvents.length > 0) {
dialogCallFunc(logEvents);
} else {
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_504)
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_505, false)
Common5.playRemoteAudioEffect("ZhuiJiaTouZi/还是有点醉,留下来陪我,给你追加投资。");
this.scheduleOnce(() => {
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_505)
}, 5)
this.curNeedID = -1
this.refreshNeedLayer()
// PrefabManage.loadPrefabByType(GameType.CityPrefab)
// this.node.destroy()
// this.onDoTask201()
// EventMgr.emitEvent_custom(ryw_Event.EnterNextGame);
// this.node.destroy()
}
});
}
dialogCallFunc(dialogEvents);
}
onBtnHuoYuanTiaoZhuan() {
// this.node.removeFromParent()
// this.node.destroy()
PrefabManage.loadPrefabByType(needIDs[this.curNeedID].tiaoZhuanGameType)
}
}