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.
277 lines
8.8 KiB
277 lines
8.8 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/Game";
|
|
import CccGame from "../../../WordGame/gameComScript/CccGame/CccGame";
|
|
import logPrefabScript from "../../../WordGame/gameComScript/logPrefabScript";
|
|
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class ChuMenShangXue extends WordGameBaseComponent {
|
|
@property(cc.Node)
|
|
layerNode: cc.Node[] = [];
|
|
|
|
@property(cc.Node)
|
|
operateNodeList: cc.Node[] = [];
|
|
|
|
//当前层级下标
|
|
curLayerIndex = 0;
|
|
//当前进度
|
|
curSchedule: number = 0;
|
|
|
|
//文本配置
|
|
titleArrayConfig: string[] = [];
|
|
duihuaArrayConfig: any[] = [];
|
|
answersIndexConfig: number[] = [];
|
|
chadianArrayConfig: any[] = [];
|
|
isResult: boolean = false;
|
|
|
|
start() {
|
|
super.start();
|
|
DaDianScript.userEnterDaDian();
|
|
//this.openTouchEvent(this.node.getChildByName('bg'));
|
|
Common5.stopMusic();
|
|
|
|
Common5.getJsonFromBundle(Common5.selectGameInfo.bundle, 'script/ChuMenShangXueConfig', (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.answersIndexConfig = this.jsonData.answersIndex;
|
|
this.chadianArrayConfig = this.jsonData.chadianArray;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
//初始化组件
|
|
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);
|
|
switch (targetNode.name) {
|
|
case '小孩子':
|
|
this.determine(0);
|
|
this.showDuiHua(this.chadianArrayConfig[0].log[0]);
|
|
break;
|
|
case '水壶':
|
|
this.determine(1);
|
|
this.showDuiHua(this.chadianArrayConfig[1].log[0]);
|
|
break;
|
|
case '猫':
|
|
this.determine(2);
|
|
this.showDuiHua(this.chadianArrayConfig[2].log[0], () => {
|
|
this.showDuiHua(this.chadianArrayConfig[2].log[1]);
|
|
});
|
|
break;
|
|
case '尿素袋':
|
|
this.determine(3);
|
|
this.showDuiHua(this.chadianArrayConfig[3].log[0]);
|
|
break;
|
|
case '行李箱关':
|
|
this.determine(4);
|
|
this.showDuiHua(this.chadianArrayConfig[4].log[0]);
|
|
break;
|
|
case '背包2':
|
|
this.determine(5);
|
|
this.showDuiHua(this.chadianArrayConfig[5].log[0]);
|
|
break;
|
|
case '零食袋':
|
|
this.determine(6);
|
|
break;
|
|
case '水桶':
|
|
this.determine(7);
|
|
this.showDuiHua(this.chadianArrayConfig[7].log[0]);
|
|
break;
|
|
case '斜挎包':
|
|
this.determine(8);
|
|
break;
|
|
case '眼镜':
|
|
this.determine(9);
|
|
this.showDuiHua(this.chadianArrayConfig[11].log[0]);
|
|
break;
|
|
case '充电器':
|
|
this.determine(10);
|
|
this.showDuiHua(this.chadianArrayConfig[12].log[0]);
|
|
break;
|
|
case '方便面':
|
|
this.showDuiHua(this.chadianArrayConfig[6].log[0]);
|
|
break;
|
|
case '零食':
|
|
this.showDuiHua(this.chadianArrayConfig[6].log[0]);
|
|
break;
|
|
case '牛奶':
|
|
this.showDuiHua(this.chadianArrayConfig[6].log[0]);
|
|
break;
|
|
case '身份证':
|
|
this.showDuiHua(this.chadianArrayConfig[8].log[0]);
|
|
break;
|
|
case '车票':
|
|
this.showDuiHua(this.chadianArrayConfig[9].log[0]);
|
|
break;
|
|
case '钱':
|
|
this.showDuiHua(this.chadianArrayConfig[10].log[0]);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
//判定
|
|
determine(index: number) {
|
|
this.curSchedule++;
|
|
if (this.curSchedule == 11) {
|
|
this.scheduleOnce(() => {
|
|
this.endGameView(1);
|
|
}, 2);
|
|
};
|
|
this.unlockLevel(this.answersIndexConfig[index]);
|
|
}
|
|
|
|
|
|
//显示对话
|
|
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_);
|
|
}
|
|
|
|
//结束弹窗
|
|
endGameView(touchIndex) {
|
|
this.node.getChildByName("inputBlock").active = true;
|
|
Game.ins.stopTime();
|
|
if (this.isResult) {
|
|
return
|
|
}
|
|
this.isResult = true
|
|
if (touchIndex == 0) {
|
|
this.scheduleOnce(() => {
|
|
Game.ins.showFail();
|
|
}, 3);
|
|
} else {
|
|
this.scheduleOnce(() => {
|
|
Game.ins.showSuccess();
|
|
}, 3);
|
|
}
|
|
}
|
|
|
|
//解锁提示
|
|
unlockLevel(sublevel) {
|
|
Game.ins.tipUnlock(sublevel)
|
|
}
|
|
|
|
openTouchEvent(node) {
|
|
node.on(cc.Node.EventType.TOUCH_START, this.touchStartNode, this)
|
|
node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMoveNode, this)
|
|
node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEndNode, this)
|
|
node.on(cc.Node.EventType.TOUCH_END, this.touchEndNode, this)
|
|
}
|
|
|
|
closeTouchEvent(node: cc.Node) {
|
|
node.off(cc.Node.EventType.TOUCH_START, this.touchStartNode, this)
|
|
node.off(cc.Node.EventType.TOUCH_MOVE, this.touchMoveNode, this)
|
|
node.off(cc.Node.EventType.TOUCH_CANCEL, this.touchEndNode, this)
|
|
node.off(cc.Node.EventType.TOUCH_END, this.touchEndNode, this)
|
|
}
|
|
|
|
touchStartNode(event) {
|
|
let target = event.target;
|
|
console.log('touchStartNode');
|
|
}
|
|
|
|
touchMoveNode(event) {
|
|
|
|
}
|
|
|
|
touchEndNode(event) {
|
|
let target = event.target;
|
|
let logPrefab = this.node.getChildByName('logPrefab');
|
|
logPrefab.getChildByName('duihua').active = false;
|
|
}
|
|
|
|
onClick(event) {
|
|
let target = event.target as cc.Node;
|
|
console.log("+++++++++++++++++++++>" + target.name);
|
|
Common5.playEffect("点击音效");
|
|
switch (target.name) {
|
|
case "BtnAddTimes":
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
//update(dt) { }
|
|
}
|
|
|