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

284 lines
9.7 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";
// import JingDiaoXiaBaConfig from "./JingDiaoXiaBaConfig";
const { ccclass, property } = cc._decorator;
@ccclass
export default class JingDiaoXiaBa extends WordGameBaseComponent {
@property(cc.Node)
checkNodeList: cc.Node = null;
@property(cc.Node)
props: cc.Node = null;
@property(cc.Node)
man: cc.Node = null;
@property(cc.Node)
hideNodeList: cc.Node[] = [];
@property(cc.Node)
showNodeList: cc.Node[] = [];
//当前层级下标
curLayerIndex = 0;
//当前进度
curSchedule: number = 0;
//文本配置
titleArrayConfig: string[] = [];
duihuaArrayConfig: any[] = [];
chadianArrayConfig: any[] = [];
isshowSuccess: boolean = false;
start() {
super.start();
DaDianScript.userEnterDaDian();
this.openTouchEvent(this.node.getChildByName('bg'));
Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/JingDiaoXiaBaConfig',(assest)=>{
this.jsonData = assest.json
this.initParameters();
this.initComponent();
})
}
//初始化参数
initParameters() {
this.curSchedule = 0;
this.titleArrayConfig = this.jsonData.titleArray //JingDiaoXiaBaConfig.getInstance().getGameConfig('titleArray') as string[];
this.chadianArrayConfig = this.jsonData.chadianArray //JingDiaoXiaBaConfig.getInstance().getGameConfig('chadianArray') as any[];
this.duihuaArrayConfig = this.jsonData.duihuaArray //JingDiaoXiaBaConfig.getInstance().getGameConfig('duihuaArray') as any[];
Common.Type = 0;
Common.subLevel = 0;
Common.GameSubTipConfigs = this.jsonData.tipsArray //JingDiaoXiaBaConfig.getInstance().getGameConfig('tipsArray');
Common.GameSubAnswerConfigs = this.jsonData.answersArray //JingDiaoXiaBaConfig.getInstance().getGameConfig('answersArray');
EventMgr.onEvent_custom(ryw_Event.NormalTouchEndCheck, (data_) => {
this.normalTouchCheckCallback(data_.targetNode);
}, this);
EventMgr.onEvent_custom(ryw_Event.DirectTouchMoveCheck, (data_) => {
this.normalTouchCheckCallback(data_.targetNode);
}, this);
EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => {
this.endGameView(0);
}, this);
}
//初始化组件
initComponent() {
let lab = this.node.getChildByName("标题").getChildByName("lab");
lab.getComponent(cc.Label).string = this.titleArrayConfig[0];
Game.ins.setGameTitle(this.titleArrayConfig[0])
for (const iterator of this.props.children) {
let callbacks = CccGame.onNodeTouchMoreCheckEvent(iterator, this.checkNodeList.children);
callbacks.setSuccessListener((data_) => {
this.nodeCheckSuccessCallback(data_.targetNode);
});
}
this.node.getChildByName("mask").active = true;
this.showDuiHua(this.duihuaArrayConfig[0], () => {
this.node.getChildByName("mask").active = false;
})
}
nodeCheckSuccessCallback(targetNode: any) {
this.curSchedule++;
let index = this.checkNodeList.children.indexOf(targetNode.checkNode);
let log = this.chadianArrayConfig[index];
switch (targetNode.checkNode.name) {
case '新娘':
this.hideNodeList[index].active = false;
this.showNodeList[index].active = true;
this.checkNodeList.children[1].active = true;
this.man.getChildByName('男主惊讶').active = true;
this.man.getChildByName('下巴').active = true;
this.man.getChildByName('下巴').height += (500 / this.chadianArrayConfig.length);
if (log && log[0]) {
// this.node.getChildByName("mask").active = true;
this.showDuiHua(log[0], () => {
this.node.getChildByName("mask").active = false;
this.determine();
});
}
break;
case '跑车':
if (log && log[0]) {
// this.node.getChildByName("mask").active = true;
this.showDuiHua(log[0], () => {
this.node.getChildByName("mask").active = false;
this.man.getChildByName('男主惊讶').active = true;
this.man.getChildByName('下巴').active = true;
this.man.getChildByName('下巴').height += (500 / this.chadianArrayConfig.length);
let car = this.hideNodeList[index];
cc.tween(car)
.to(1, { x: car.x - 200 })
.set({ active: false })
.call(() => {
this.showNodeList[index].active = true;
this.determine();
})
.start();
});
}
break;
default:
this.hideNodeList[index].active = false;
this.showNodeList[index].active = true;
this.man.getChildByName('男主惊讶').active = true;
this.man.getChildByName('下巴').active = true;
this.man.getChildByName('下巴').height += (500 / this.chadianArrayConfig.length);
if (log && log[0]) {
// this.node.getChildByName("mask").active = true;
this.showDuiHua(log[0], () => {
this.node.getChildByName("mask").active = false;
this.determine();
});
}
break;
}
}
normalTouchCheckCallback(targetNode: any) {
console.log("targetNodeName+++++++++++++++++++++>" + targetNode.name);
switch (targetNode.name) {
case '窗户':
break;
default:
break;
}
}
determine() {
if (this.curSchedule == this.chadianArrayConfig.length) {
this.endGameView(1);
}
}
//显示对话
showDuiHua(curLog, func?) {
console.log("curLog==", curLog);
if (curLog.effectUrl) {
Common5.playEffectCustom("jingdiaoxiaba", curLog.effectUrl);
}
let string_ = curLog.str
let qiPaoPos_ = curLog.qiPaoPos
let delayTime_ = curLog.delayTime || 3;
let node = this.node.getChildByName('layerNode');
if (qiPaoPos_ != -1) {
let qiPao = node.getChildByName("qiPao").getChildByName("qiPao_" + qiPaoPos_);
qiPao.stopAllActions()
qiPao.getChildByName("str").getComponent(cc.Label).string = string_
qiPao.active = true
qiPao.scale = 0
cc.tween(qiPao)
.to(0.2, { scale: 1 })
.delay(delayTime_)
.call(() => {
qiPao.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 (touchIndex == 0) {
this.scheduleOnce(() => {
Game.ins.showFail();
}, 3);
} else {
if(this.isshowSuccess){
return
}
this.isshowSuccess = true
this.scheduleOnce(() => {
Game.ins.showSuccess();
}, 3);
}
}
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) { }
}