// Learn TypeScript: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html 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"; const {ccclass, property} = cc._decorator; @ccclass export default class ChunShanXue extends WordGameBaseComponent { @property(cc.Node) qipao1:cc.Node = null; @property(cc.Node) qipao2:cc.Node = null; @property(cc.Node) qipao3:cc.Node = null; @property(cc.Node) renwu1Node:cc.Node = null; @property(cc.Node) renwu2Node:cc.Node = null; @property(cc.Node) renwu3Node:cc.Node = null; curIndex = 0 titleArrayConfig: string[] = []; duihuaArrayConfig: any[] = []; chadianArrayConfig: any[] = []; wrongAnswerConfig: string[] = []; answersDuihuaConfig: any[] = []; // LIFE-CYCLE CALLBACKS: @property(cc.ProgressBar) progressBar:cc.ProgressBar = null; // onLoad () {} start () { super.start(); DaDianScript.userEnterDaDian(); Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/ChunShanXueConfig',(assest)=>{ this.jsonData = assest.json this.initParameters(); }) 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.NormalTouchEndCheck, (data_) => { this.normalTouchCheckCallback(data_.targetNode); }, this); // EventMgr.onEvent_custom(ryw_Event.timeOut, (tab) => { // this.failView(); // }, this); } initParameters(){ this.titleArrayConfig = this.jsonData.titleArray; this.duihuaArrayConfig = this.jsonData.duihuaArray; this.chadianArrayConfig = this.jsonData.chadianArray; this.wrongAnswerConfig = this.jsonData.wrongAnswer; this.answersDuihuaConfig = this.jsonData.answersDuihua; Common.Type = 3; Common.subLevel = 0; Common.GameSubTipConfigs = this.jsonData.answersArray; this.curIndex = 0 Game.ins.setGameTitle(this.titleArrayConfig[0]); } normalTouchCheckCallback(targetNode){ console.log("targetNodeName+++++++++++++++++++++>" + targetNode.name); if(targetNode.name == 'zenggao'){ let postx = this.renwu1Node.getPosition().x let posty = this.renwu1Node.getPosition().y this.renwu1Node.setPosition(cc.v2(postx, posty-60)) let qipaox = this.qipao1.getPosition().x let qipaoy = this.qipao1.getPosition().y this.qipao1.setPosition(cc.v2(qipaox, qipaoy-60)) let huabix = this.node.getChildByName('画笔spine').getPosition().x let huabiy = this.node.getChildByName('画笔spine').getPosition().y this.node.getChildByName('画笔spine').setPosition(cc.v2(huabix, huabiy-60)) this.curIndex++ this.showQiPao(this.qipao1,'站得高看得远,差不多就行了') this.endGameView() this.unlockLevel(0) }else if(targetNode.name == 'zhongcheck'){ this.unlockLevel(3) let postx = this.renwu1Node.getPosition().x let posty = this.renwu1Node.getPosition().y this.renwu1Node.setPosition(cc.v2(postx, posty-270)) let qipaox = this.qipao1.getPosition().x let qipaoy = this.qipao1.getPosition().y this.qipao1.setPosition(cc.v2(qipaox, qipaoy-250)) let huabix = this.node.getChildByName('画笔spine').getPosition().x let huabiy = this.node.getChildByName('画笔spine').getPosition().y this.node.getChildByName('画笔spine').setPosition(cc.v2(huabix, huabiy-250)) this.curIndex++ this.showQiPao(this.qipao1, '站哪里都一样,差不多就行了') this.endGameView() }else if(targetNode.name == '图层check'){ this.curIndex++ this.showQiPao(this.qipao1, '这背景才适合我') this.unlockLevel(8) this.endGameView() }else if(targetNode.name == '红发'){ this.unlockLevel(1) this.curIndex++ this.showQiPao(this.qipao1,'特意染黄好让你们注意我,差不多就行了') this.endGameView() }else if(targetNode.name == 'renwucheck'){ this.curIndex++ this.showQiPao(this.qipao3,'我都不好意思唱下去了') this.unlockLevel(6) this.endGameView() }else if(targetNode.name == '皮带check'){ this.unlockLevel(7) this.curIndex++ this.showQiPao(this.qipao3,'出门太着急,忘记系了') this.endGameView() }else if(targetNode.name == '问号'){ this.curIndex++ this.showQiPao(this.qipao2,'给我看懵逼了') this.unlockLevel(4) this.endGameView() }else if(targetNode.name == '鞋带1'){ this.curIndex++ this.showQiPao(this.qipao2,'唱太入迷了,没注意到') this.unlockLevel(5) this.endGameView() }else if(targetNode.name == 'checkShou'){ this.unlockLevel(2) this.curIndex++ this.showQiPao(this.qipao1,'我在跟观众打招呼呢') this.endGameView() }else if(targetNode.name == '毛笔'){ this.unlockLevel(9) this.node.getChildByName('画笔spine').active = true this.node.getChildByName('画笔spine').getComponent(sp.Skeleton).setAnimation(0,'毛笔',false) this.node.getChildByName('画笔spine').getComponent(sp.Skeleton).setCompleteListener(()=>{ //this.renwu1Node.getChildByName('heise').active = false this.renwu1Node.getChildByName('baise').active = true this.renwu1Node.getChildByName('heise').getChildByName('黑').active = false this.curIndex++ this.showQiPao(this.qipao1,'黑的白的都一样,差不多就行了') this.endGameView() }) } } unlockLevel(sublevel) { Game.ins.tipUnlock(sublevel) } showQiPao(qipaoNode, str, delayTime=3, callFunc=null){ this.progressBar.progress = this.curIndex/10 qipaoNode.scale = 0 qipaoNode.active = true qipaoNode.stopAllActions() qipaoNode.getChildByName("str").getComponent(cc.Label).string = str if (str) { Common5.playEffectCustom("chunshanxue", "sound/"+str); } cc.tween(qipaoNode) .to(0.2,{scale:1}) .delay(delayTime) .call(()=>{ qipaoNode.active = false if(callFunc){ callFunc() } }) .start() } endGameView(delay = 6) { if(this.curIndex>=10){ Game.ins.stopTime(); this.scheduleOnce(()=>{ Game.ins.showSuccess() },delay) } } // update (dt) {} }