开局破防了
 
 
 
 
 
kaijupofangle/assets/ZoomLevels/fanmaikuaile/script/FanMaiKuaiLeScript.ts

271 lines
8.6 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 GameReport from "../../../FrameWork/Report/ZyZyReport";
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 FanMaiKuaiLeConfig from "./FanMaiKuaiLeConfig";
const { ccclass, property } = cc._decorator;
@ccclass
export default class FanMaiKuaiLeScript extends WordGameBaseComponent {
@property(cc.Node)
checkNodeList: cc.Node = null;
@property(cc.Node)
props: 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.playMusicCustom('fanmaikuaile', 'sound/背景音感人2');
Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/FanMaiKuaiLeConfig',(assest)=>{
//this.jsonData = JSON.stringify(assest.json)
this.jsonData =assest.json
this.initParameters();
this.initComponent();
})
}
//初始化参数
initParameters() {
this.curSchedule = 0;
this.titleArrayConfig = this.jsonData.titleArray //FanMaiKuaiLeConfig.getInstance().getGameConfig('titleArray') as string[];
this.chadianArrayConfig = this.jsonData.chadianArray //FanMaiKuaiLeConfig.getInstance().getGameConfig('chadianArray') as any[];
this.duihuaArrayConfig = this.jsonData.duihuaArray //FanMaiKuaiLeConfig.getInstance().getGameConfig('duihuaArray') as any[];
Common.Type = 0;
Common.subLevel = 0;
Common.GameSubTipConfigs = this.jsonData.tipsArray //FanMaiKuaiLeConfig.getInstance().getGameConfig('tipsArray');
Common.GameSubAnswerConfigs = this.jsonData.answersArray //FanMaiKuaiLeConfig.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.NormalTouchMoveCheck, (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];
let title = this.titleArrayConfig[0];
Game.ins.setGameTitle(title)
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.showDuiHua(this.duihuaArrayConfig[1],()=>{
this.node.getChildByName("mask").active = false;
});
});
}
nodeCheckSuccessCallback(targetNode: any) {
this.curSchedule++;
GameReport.BtnsReport(targetNode.checkNode.name, Common5.selectGameInfo.titleUrl);
console.log("[GameReport]++++++++++++++++++++++>" + targetNode.checkNode.name);
let index = this.checkNodeList.children.indexOf(targetNode.checkNode);
this.hideNodeList[index].active = false;
this.showNodeList[index].active = true;
if(index == 2)
{
this.hideNodeList[6].x -= 50;
this.showNodeList[6].x -= 50;
}
let log = this.chadianArrayConfig[index];
if (log && log[0]) {
// this.node.getChildByName("mask").active = true;
this.showDuiHua(log[0], () => {
if (log[1]) {
this.showDuiHua(log[1], () => {
this.node.getChildByName("mask").active = false;
this.determine();
});
} else {
this.node.getChildByName("mask").active = false;
this.determine();
}
});
}
}
normalTouchCheckCallback(targetNode: any) {
console.log("targetNodeName+++++++++++++++++++++>" + targetNode.name);
switch (targetNode.name) {
case '创可贴':
this.endGameView(1);
break;
default:
break;
}
}
determine() {
if (this.curSchedule == this.chadianArrayConfig.length) {
this.endGameView(1);
//this.node.getChildByName("layerNode").getChildByName("operate").active = true;
}
}
//显示对话
showDuiHua(curLog, func?) {
console.log("curLog==", curLog);
if (curLog.effectUrl) {
Common5.playEffectCustom("fanmaikuaile", 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) { }
}