咸鱼的反击
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.
 
 
 

225 lines
8.0 KiB

import DaDianScript from "../../../../FrameWork/Base/DaDianScript";
import WordGameBaseComponent from "../../../../FrameWork/Base/WordGameBaseComptent";
import { ryw_Event } from "../../../../FrameWork/Event/EventEnum";
import EventMgr from "../../../../FrameWork/Event/EventMgr";
import Common from "../../../../FrameWork/Util/Common";
import Common5 from "../../../../Platform/th/Common5";
import Game from "../../../../Scripts/WenZiRes/ui/Game";
import CccGame from "../../../WordGame/gameComScript/CccGame/CccGame";
import logPrefabScript from "../../../WordGame/gameComScript/logPrefabScript";
// import HunLiZhaoPianConfig from "./HunLiZhaoPianConfig";
const { ccclass, property } = cc._decorator;
@ccclass
export default class HuanXingLaoGong extends WordGameBaseComponent {
@property(cc.Node)
layerNode: cc.Node[] = [];
@property(cc.Node)
operateNodeList: cc.Node[] = [];
//当前层级下标
curLayerIndex = 0;
//当前进度
curSchedule: number = 0;
//文本配置
titleArrayConfig: string[] = [];
duihuaArrayConfig: any[] = [];
chadianArrayConfig: any[] = [];
wrongAnswerConfig: string[] = [];
answersIndexConfig: number[] = [];
start() {
super.start();
DaDianScript.userEnterDaDian();
//this.openTouchEvent(this.node.getChildByName('bg'));
Common5.stopMusic();
Common5.getJsonFromBundle(Common5.selectGameInfo.bundle, 'script/HuanXingLaoGongConfig', (assest) => {
this.jsonData = assest.json;
this.initParameters();
this.initComponent();
})
}
//初始化参数
initParameters() {
this.curLayerIndex = 0;
this.curSchedule = 0;
this.titleArrayConfig = this.jsonData.titleArray;
this.duihuaArrayConfig = this.jsonData.duihuaArray;
this.chadianArrayConfig = this.jsonData.chadianArray;
this.wrongAnswerConfig = this.jsonData.wrongAnswer;
this.answersIndexConfig = this.jsonData.answersIndex;
Common.Type = 3;
Common.subLevel = 0;
Common.GameSubTipConfigs = this.jsonData.answersArray;
EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (data_) => {
this.normalTouchCallback(data_.targetNode);
}, this);
EventMgr.onEvent_custom(ryw_Event.NormalTouchEndCheck, (data_) => {
this.normalTouchCallback(data_.targetNode);
}, this);
EventMgr.onEvent_custom(ryw_Event.DirectTouchMoveCheck, (data_) => {
this.normalTouchCallback(data_.targetNode);
}, this);
EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => {
this.endGameView(0);
}, this);
}
//初始化组件
initComponent() {
for (const node of this.layerNode) {
node.active = false;
}
let node = this.layerNode[this.curLayerIndex];
node.active = true;
Game.ins.setGameTitle(this.titleArrayConfig[0]);
//Common5.playMusicCustom(Common5.selectGameInfo.bundle, 'sound/背景音');
this.node.getChildByName("inputBlock").active = true;
this.showDuiHua(this.duihuaArrayConfig[0], () => {
this.node.getChildByName("inputBlock").active = false;
});
}
//触摸回调
normalTouchCallback(targetNode: cc.Node) {
console.log("+++++++++++++++++++++>" + targetNode.name);
const targetNameList = ['洗发露', '直板夹', '黄瓜', '胶带', '针线', '护士服'];
const determine = (target: cc.Node) => {
const index = targetNameList.indexOf(target.name);
this.unlockLevel(this.answersIndexConfig[index]);
this.node.getChildByName("inputBlock").active = true;
Common5.playEffectCustom(Common5.selectGameInfo.bundle, 'sound/男生哇');
CccGame.playAnimation2(this.getLayerChild('心电仪', '心电图'), '心率变化');
if (this.curSchedule == 0) {
this.getLayerChild('床', '躺平').children[this.curSchedule].active = false;
} else {
this.getLayerChild('床', '躺平').children[this.curSchedule - 1].active = false;
}
this.getLayerChild('床', '坐起').children[this.curSchedule].active = true;
this.getLayerChild('床', '坐起', '爱心').active = true;
this.scheduleOnce(() => {
this.node.getChildByName("inputBlock").active = false;
if (this.curSchedule < this.chadianArrayConfig.length - 1) {
CccGame.playAnimation2(this.getLayerChild('心电仪', '心电图'), '心率拉平');
this.getLayerChild('床', '躺平').children[this.curSchedule].active = true;
this.getLayerChild('床', '坐起').children[this.curSchedule].active = false;
this.getLayerChild('床', '坐起', '爱心').active = false;
}
this.showDuiHua(this.chadianArrayConfig[this.curSchedule].log[0]);
this.curSchedule++;
if (this.curSchedule >= this.chadianArrayConfig.length) {
this.scheduleOnce(() => {
this.endGameView(1);
}, 5);
}
}, 2);
}
const itemLogic = {
default: (target: cc.Node) => {
determine(target);
},
: (target: cc.Node) => {
let roles = this.getLayerChild('床', '躺平');
for (const iterator of roles.children) {
iterator.active = false;
}
roles.children[0].active = true;
CccGame.playAnimation2(this.getLayerChild('心电仪', '心电图'), '心率拉平');
this.scheduleOnce(() => {
this.showDuiHua(this.duihuaArrayConfig[1], () => {
this.endGameView(0);
});
}, 2);
},
}
if (itemLogic[targetNode.name]) {
itemLogic[targetNode.name]?.(targetNode);
} else if (targetNameList.includes(targetNode.name)) {
itemLogic.default(targetNode);
}
}
//显示对话
showDuiHua(curLog, func?) {
console.log("curLog==", curLog);
if (curLog.effectUrl) {
Common5.playEffectCustom(Common5.selectGameInfo.bundle, curLog.effectUrl);
}
let string_ = curLog.str;
let qiPaoPos_ = curLog.qiPaoPos;
let delayTime_ = curLog.delayTime || 3;
let node = this.layerNode[this.curLayerIndex];
if (qiPaoPos_ != -1) {
let qiPao = node.getChildByName("qiPao").getChildByName("qiPao_" + qiPaoPos_);
qiPao.stopAllActions()
qiPao.getChildByName("str").getComponent(cc.Label).string = string_
cc.tween(qiPao)
.set({ active: true, scale: 0 })
.to(0.2, { scale: 1 })
.delay(delayTime_)
.set({ active: false })
.start();
}
else {
let logPrefab = this.node.getChildByName('logPrefab');
let script_: logPrefabScript = logPrefab.getComponent('logPrefabScript');
script_.setDailogShow(string_, delayTime_);
}
this.scheduleOnce(() => {
if (func) {
func();
}
}, delayTime_);
}
//获取当前场景下的节点
getLayerChild(...path: string[]) {
let child = this.layerNode[this.curLayerIndex];
if (path.length > 1) {
for (const name of path) {
child = child.getChildByName(name);
}
return child;
}
return child.getChildByName(path[0]);
}
//结束弹窗
endGameView(touchIndex) {
this.node.getChildByName("inputBlock").active = true;
Game.ins.stopTime();
if (touchIndex == 0) {
Game.ins.showFail();
} else {
Game.ins.showSuccess();
}
}
//解锁提示
unlockLevel(sublevel) {
Game.ins.tipUnlock(sublevel)
}
}