觉醒时刻
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.

270 lines
11 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 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;
@ccclass
export default class DH_26 extends DHBase {
chatConfig = [
{ effectUrl: 'DH/DH_26/sound/嗯?怎么被打晕了?救醒她就真相大白了!', delayTime: 3.3, str: '嗯?怎么被打晕了?救醒她就真相大白了!', posi: '-1' },
{ effectUrl: 'DH/DH_26/sound/老板,我好怕!', delayTime: 2.85, str: '老板,我好怕!', posi: 'qipao2' },
{ effectUrl: 'DH/DH_26/sound/别装了,你为什么害我!', delayTime: 2.4, str: '别装了,你为什么害我!', posi: '-1' },
{ effectUrl: 'DH/DH_26/sound/我没有!是顾书雅,是她让我扔掉那些东西的。', delayTime: 5.7, str: '我没有!是顾书雅,是她让我扔掉那些东西的。', posi: 'qipao3' },
{ effectUrl: 'DH/DH_26/sound/还狡辩,我不想再见到你!', delayTime: 3, str: '还狡辩,我不想再见到你!', posi: '-1' },
]
@property(sp.Skeleton)
baishishi_1: sp.Skeleton = null;
@property(sp.Skeleton)
baishishi_2: sp.Skeleton = null;
@property([cc.Node])
layers: cc.Node[] = [];
taskGoodStep: number = 0
start() {
this.scheduleOnce(() => {
PrefabManage.preloadPrefabByType(GameType.DH_24)
})
GameBaseScript.preLoadRemoteAudioByChatConfig(this.chatConfig);
super.start();
for (const layer of this.layers) {
layer.active = false
}
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if (mainId == MainTaskIdEnum.MainTask_1706) {
this.dialogIndex = 1
for (const layer of this.layers) {
layer.active = true
}
this.node.getChildByName("juQingTipNode").active = true
} else {
this.node.getChildByName("juQingTipNode").active = false
this.layers[0].active = true
this.continueStory();
}
// this.scheduleOnce(() => {
// PrefabManage.preloadPrefabByType(GameType.DH_59)
// })
// EventMgr.onEvent_custom(ryw_Event.RefreshJuQingDuiHua, () => {
// this.continueStory1();
// }, this);
EventMgr.onEvent_custom(ryw_Event.goodTouchMoveCheck, (targetNode) => {
this.checkTaskGoodStep(targetNode);
}, this);
}
// 继续剧情
continueStory() {
this.baishishi_1.node.active = true
const dialogEvents = [
(func) => {
this.baishishi_1.setAnimation(0, "待机", true)
this.showClickDialog(this.chatConfig[this.dialogIndex++], func, () => {
});
},
]
const dialogCallFunc = (logEvents: any[]) => {
logEvents.shift()(() => {
if (logEvents.length > 0) {
dialogCallFunc(logEvents);
} else {
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_1705)
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_1706)
// PrefabManage.showBlackGuoDu(() => {
// PrefabManage.loadPrefabByType(GameType.CityPrefab)
// this.node.destroy()
// })
}
});
}
dialogCallFunc(dialogEvents);
}
// 继续剧情
continueStory1() {
this.layers[0].active = false
this.baishishi_2.node.active = true
const dialogEvents = [
(func) => {
this.baishishi_2.setAnimation(0, "靠近", false)
this.baishishi_2.setCompleteListener(() => {
this.baishishi_2.setCompleteListener(null)
this.baishishi_2.setAnimation(0, "待机", true)
})
this.showQiPao(this.chatConfig[this.dialogIndex++], func, () => {
});
},
(func) => {
this.showClickDialog(this.chatConfig[this.dialogIndex++], func, () => {
this.baishishi_2.setAnimation(0, "被推开", false)
this.baishishi_2.setCompleteListener(() => {
this.baishishi_2.setCompleteListener(null)
this.baishishi_2.setAnimation(0, "被推开待机", true)
})
});
},
(func) => {
this.showQiPao(this.chatConfig[this.dialogIndex++], func, () => {
});
},
(func) => {
this.showClickDialog(this.chatConfig[this.dialogIndex++], func, () => {
});
},
]
const dialogCallFunc = (logEvents: any[]) => {
logEvents.shift()(() => {
if (logEvents.length > 0) {
dialogCallFunc(logEvents);
} else {
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_1706)
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_1707)
// PrefabManage.showBlackGuoDu(() => {
// PrefabManage.loadPrefabByType(GameType.CityPrefab)
// this.node.destroy()
// })
}
});
}
dialogCallFunc(dialogEvents);
}
checkTaskGoodStep(targetNode) {
let rightStepTab = ['icon_3701', 'icon_3702', 'icon_3700', 'icon_3703']
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
let callFunc = (typeStr) => {
if (typeStr == 0) {
if (targetNode.parent.name == 'icon_3701') {
Common5.getSpriteFrameFromBundle("DH_26", "res/碘酒灰", targetNode.getComponent(cc.Sprite))
this.layers[1].getChildByName('治疗').getComponent(sp.Skeleton).setAnimation(0, "碘酒", false)
} else if (targetNode.parent.name == 'icon_3702') {
Common5.getSpriteFrameFromBundle("DH_26", "res/止血粉灰", targetNode.getComponent(cc.Sprite))
this.layers[1].getChildByName('治疗').getComponent(sp.Skeleton).setAnimation(0, "止血粉", false)
} else if (targetNode.parent.name == 'icon_3700') {
Common5.getSpriteFrameFromBundle("DH_26", "res/纱布灰", targetNode.getComponent(cc.Sprite))
this.layers[1].getChildByName('治疗').getComponent(sp.Skeleton).setAnimation(0, "绷带", false)
} else if (targetNode.parent.name == 'icon_3703') {
Common5.getSpriteFrameFromBundle("DH_26", "res/抗生素灰", targetNode.getComponent(cc.Sprite))
this.layers[1].getChildByName('治疗').getComponent(sp.Skeleton).setAnimation(0, "抗生素", false)
this.layers[1].getChildByName('治疗').getComponent(sp.Skeleton).setCompleteListener(() => {
this.layers[1].getChildByName('治疗').getComponent(sp.Skeleton).setCompleteListener(null)
this.layers[1].getChildByName('手指箭头').active = false;
this.layers[1].getChildByName('nodex').active = false;
this.layers[1].getChildByName('治疗').active = false;
})
}
} else if (typeStr == 1) {
let wrongTip = this.layers[1].getChildByName('wrongTip')
wrongTip.stopAllActions()
cc.tween(wrongTip)
.set({ active: true, scale: 0 })
.to(0.2, { scale: 1 })
.delay(2)
.to(0.2, { scale: 0 })
.set({ active: false })
.start()
}
}
//结束操作后弹框成功或失败
if (targetNode.parent.name == rightStepTab[this.taskGoodStep]) {
console.log('物品正确', targetNode.parent.name)
// this.node.getChildByName('jieShengTask504Node').getChildByName('手指箭头').active = false
this.taskGoodStep++
if (this.taskGoodStep >= rightStepTab.length) {
this.scheduleOnce(() => {
this.continueStory1()
}, 2)
// let successFunc = () => {
// this.finishTask()
// }
// cc.tween(this.node)
// .delay(2.5)
// .call(()=>{
// PrefabManage.loadPrefabByType(GameType.TaskResult,null,(prefabNode)=>{
// prefabNode.getComponent(TaskResult).initView1(1,true,successFunc)
// })
// })
// .start()
}
callFunc(0)
} else {
console.log('物品错误', targetNode.parent.name)
callFunc(1)
}
}
finishTask() {
// this.isStartTask603 = false
// User.setRoomGoodStatus(5)
TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_207)
TaskManager.setCurUnLockMainTaskInfo(MainTaskIdEnum.MainTask_208)
BagManager.subBagList(3700, 1)
BagManager.subBagList(3701, 1)
BagManager.subBagList(3702, 1)
BagManager.subBagList(3703, 1)
// BagManager.subBagList(3034,1)
// Common5.playMusicCustom('CommonRes', 'sound/背景音');
this.node.removeFromParent()
this.node.destroy()
// Common5.releaseBundleAssets('GameStory2')
}
// 震屏效果
// 参数:duration 震屏时间
shakeEffect(duration) {
this.node.runAction(
cc.repeatForever(
cc.sequence(
// cc.moveTo(0.02, cc.v2(5, 7)),
// cc.moveTo(0.02, cc.v2(-6, 7)),
// cc.moveTo(0.02, cc.v2(-13, 3)),
// cc.moveTo(0.02, cc.v2(3, -6)),
// cc.moveTo(0.02, cc.v2(-5, 5)),
// cc.moveTo(0.02, cc.v2(2, -8)),
// cc.moveTo(0.02, cc.v2(-8, -10)),
// cc.moveTo(0.02, cc.v2(3, 10)),
// cc.moveTo(0.02, cc.v2(0, 0))
cc.moveTo(0.2, cc.v2(5, 7)),
// cc.moveTo(0.2, cc.v2(-6, 7)),
cc.moveTo(0.2, cc.v2(-13, 3)),
// cc.moveTo(0.2, cc.v2(3, -6)),
cc.moveTo(0.2, cc.v2(-5, 5)),
// cc.moveTo(0.2, cc.v2(2, -8)),
cc.moveTo(0.2, cc.v2(-8, -10)),
// cc.moveTo(0.2, cc.v2(3, 10)),
cc.moveTo(0.2, cc.v2(0, 0))
)
)
);
setTimeout(() => {
this.node.stopAllActions();
this.node.setPosition(0, 0);
}, duration * 1000);
}
}