还有谁挑战
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.
 
 
 
 
 

321 lines
11 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 logPrefabScript from "../../../WordGame/gameComScript/logPrefabScript";
// import HunLiZhaoPianConfig from "./HunLiZhaoPianConfig";
const { ccclass, property } = cc._decorator;
@ccclass
export default class HunLiZhaoPian extends WordGameBaseComponent {
@property(cc.Node)
layerNode: cc.Node[] = [];
@property(cc.Node)
operateNodeList: cc.Node[] = [];
@property(cc.ProgressBar)
progressNode: cc.ProgressBar = null;
//当前层级下标
curLayerIndex = 0;
//当前进度
curSchedule: number = 0;
//文本配置
titleArrayConfig: string[] = [];
duihuaArrayConfig: any[] = [];
chadianArrayConfig: any[] = [];
answersIndexConfig: number[] = [];
isResult: boolean = false;
start() {
super.start();
DaDianScript.userEnterDaDian();
//this.openTouchEvent(this.node.getChildByName('bg'));
Common5.stopMusic();
Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/HunLiZhaoPianConfig',(assest)=>{
this.jsonData = assest.json
this.initParameters();
this.initComponent();
})
}
//初始化参数
initParameters() {
this.curLayerIndex = 0;
this.curSchedule = 0;
this.titleArrayConfig = this.jsonData.titleArray//HunLiZhaoPianConfig.getInstance().getGameConfig('titleArray') as string[];
this.duihuaArrayConfig = this.jsonData.duihuaArray//HunLiZhaoPianConfig.getInstance().getGameConfig('duihuaArray') as any[];
this.chadianArrayConfig = this.jsonData.chadianArray// HunLiZhaoPianConfig.getInstance().getGameConfig('chadianArray');
this.answersIndexConfig = this.jsonData.answersIndex// HunLiZhaoPianConfig.getInstance().getGameConfig('answersIndex');
Common.Type = 3;
Common.subLevel = 0;
Common.GameSubTipConfigs = this.jsonData.answersArray//HunLiZhaoPianConfig.getInstance().getGameConfig('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('zhiboyijie', 'sound/背景音');
// this.node.getChildByName("mask").active = true;
// this.showDuiHua(this.duihuaArrayConfig[0], () => {
// this.node.getChildByName("mask").active = false;
// });
this.progressNode.progress = 0;
}
//触摸回调
normalTouchCallback(targetNode: cc.Node) {
console.log("+++++++++++++++++++++>" + targetNode.name);
switch (targetNode.name) {
case '花束':
this.showDuiHua(this.chadianArrayConfig[0].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[0]);
break;
case '头纱':
this.showDuiHua(this.chadianArrayConfig[1].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[1]);
break;
case '伴郎的脸':
this.showDuiHua(this.chadianArrayConfig[2].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[2]);
break;
case '伴郎的身体':
this.showDuiHua(this.chadianArrayConfig[3].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[3]);
break;
case '伴娘的眼睛':
this.showDuiHua(this.chadianArrayConfig[4].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[4]);
break;
case '新郎胸花':
this.showDuiHua(this.chadianArrayConfig[5].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[5]);
break;
case '拉拉链':
this.showDuiHua(this.chadianArrayConfig[6].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[6]);
break;
case '剃须刀':
this.showDuiHua(this.chadianArrayConfig[7].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[7]);
break;
case '腋毛':
this.showDuiHua(this.chadianArrayConfig[8].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[8]);
break;
case '手套':
this.showDuiHua(this.chadianArrayConfig[9].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[9]);
break;
case '伴娘的手':
this.showDuiHua(this.chadianArrayConfig[10].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[10]);
break;
case '伴郎的手':
this.showDuiHua(this.chadianArrayConfig[11].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[11]);
break;
case '新郎':
// targetNode.setPosition(cc.v2(-137, -577.526));
// targetNode['checkNode'].setPosition(cc.v2(136.5, -577.526));
// targetNode.active = true;
// targetNode['checkNode'].active = true;
this.showDuiHua(this.chadianArrayConfig[12].log[0], () => {
this.determine();
});
this.unlockLevel(this.answersIndexConfig[12]);
break;
default:
break;
}
}
//判定
determine() {
this.curSchedule++;
this.progressNode.progress = this.curSchedule / this.chadianArrayConfig.length;
if (this.curSchedule == this.chadianArrayConfig.length) {
cc.tween(this.layerNode[0])
.delay(0.5)
.set({ opacity: 0 })
.call(() => {
this.node.getChildByName('MaskNode').getChildByName('bg').active = true;
})
.delay(0.5)
.call(() => {
this.node.getChildByName('MaskNode').getChildByName('bg').active = false;
})
.set({ opacity: 255 })
.to(1, { scale: 0.5 })
.to(1, { scale: 0.7 })
.call(() => {
this.endGameView(1);
})
.start();
} else if (this.curSchedule == this.chadianArrayConfig.length - 1) {
this.operateNodeList[0].active = true;
}
}
//显示对话
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("mask").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) { }
}