// 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/WenZiRes/ui/Game"; const {ccclass, property} = cc._decorator; @ccclass export default class BianChengMeiNv extends WordGameBaseComponent { @property(cc.SpriteFrame) pro1Array:cc.SpriteFrame[] = [] @property(cc.SpriteFrame) pro2Array:cc.SpriteFrame[] = [] @property(cc.SpriteFrame) pro3Array:cc.SpriteFrame[] = [] @property(cc.SpriteFrame) pro4Array:cc.SpriteFrame[] = [] @property(cc.Node) proChoose:cc.Node = null; @property(cc.Node) proNodeShow:cc.Node = null; curIndex = 0 titleArrayConfig: string[] = []; duihuaArrayConfig: any[] = []; chadianArrayConfig: any[] = []; wrongAnswerConfig: string[] = []; answersDuihuaConfig: any[] = []; allProArray = [] ShenTiShouState = '' headStateStr = '丑头' start () { this.allProArray = [ this.pro1Array, this.pro2Array, this.pro3Array, this.pro4Array ] super.start(); DaDianScript.userEnterDaDian(); Common5.getJsonFromBundle(Common5.selectGameInfo.bundle,'script/BianChengMeiNvConfig',(assest)=>{ this.jsonData = assest.json this.initParameters(); }) EventMgr.onEvent_custom(ryw_Event.NormalTouchMoveCheck, (data_) => { this.normalTouchCheckCallback(data_.targetNode); }, this); } normalTouchCheckCallback(targetNode){ if(targetNode.name == '珍珠'){ let spriteSt = this.node.getChildByName('身体').getComponent(cc.Sprite) if(this.ShenTiShouState == '束腰'){ Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/瘦身体/白",spriteSt) }else if(this.ShenTiShouState == '绳子'){ Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/绳子身体/白",spriteSt) }else{ Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/胖身体/白",spriteSt) let qzSpine = this.node.getChildByName('裙子spine').getComponent(sp.Skeleton) qzSpine.setAnimation(0,'撑破裙皮肤白',false) } //头 let spriteHead = this.node.getChildByName('头Node').getComponent(cc.Sprite) Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/"+this.headStateStr+"/白",spriteHead) this.nanshifangying(true, false) if(this.ShenTiShouState == '束腰' && this.headStateStr == '美头' && this.node.getChildByName('头发精致后').active){ this.endGameView(true) } } } // update (dt) {} unlockLevel(sublevel) { Game.ins.tipUnlock(sublevel) } 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]); this.showProChooseNodes() } // update (dt) {} showProChooseNodes(){ if(this.curIndex==4){ this.endGameView(false) return } if(this.curIndex==3){ this.node.getChildByName('checkNode').active = true } this.proChoose.scale = 0 this.proChoose.active = true this.proChoose.stopAllActions() cc.tween(this.proChoose) .call(()=>{ let proArray = this.allProArray[this.curIndex] for(let i = 0; i{ szSpine.active = false this.nanshifangying(false) this.node.getChildByName('裙子spine').active = false let sprite = this.node.getChildByName('身体').getComponent(cc.Sprite) Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/绳子身体/胖",sprite) this.node.getChildByName('绳2').active = true },0.2) }else if(this.curIndex == 1){ //面膜 this.headStateStr = '丑头' let slSpine = this.node.getChildByName('瘦脸spine') slSpine.active = true slSpine.getComponent(sp.Skeleton).setAnimation(0,'面膜',false) slSpine.getComponent(sp.Skeleton).setCompleteListener(()=>{ this.node.getChildByName('痘痘').active = true this.nanshifangying(false) }) }else if(this.curIndex == 2){ //剪刀 Common5.playEffectCustom("bianchengmeinv", "sound/剪刀"); let tfSpine = this.node.getChildByName('头发spine') tfSpine.active = true tfSpine.getComponent(sp.Skeleton).setAnimation(0,'剪刀',false) tfSpine.getComponent(sp.Skeleton).setCompleteListener(()=>{ tfSpine.active = false this.node.getChildByName('头发乱前').active = false this.node.getChildByName('头发乱后').active = false this.nanshifangying(false) }) }else if(this.curIndex == 3){ //墨水 let msSpine = this.node.getChildByName('墨水spine') Common5.playEffectCustom("bianchengmeinv", "sound/丢屎"); msSpine.active = true msSpine.getComponent(sp.Skeleton).setAnimation(0,'墨水',false) msSpine.getComponent(sp.Skeleton).setCompleteListener(()=>{ msSpine.active = false this.nanshifangying(false) //身体 let spriteSt = this.node.getChildByName('身体').getComponent(cc.Sprite) if(this.ShenTiShouState == '束腰'){ Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/瘦身体/乌漆嘛黑",spriteSt) }else if(this.ShenTiShouState == '绳子'){ Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/绳子身体/乌漆嘛黑",spriteSt) }else{ Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/胖身体/乌漆嘛黑",spriteSt) let qzSpine = this.node.getChildByName('裙子spine').getComponent(sp.Skeleton) qzSpine.setAnimation(0,'撑破裙皮肤乌黑',false) } //头 let spriteHead = this.node.getChildByName('头Node').getComponent(cc.Sprite) Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/"+this.headStateStr+"/乌漆嘛黑",spriteHead) }) } this.unlockLevel(this.curIndex) this.curIndex++ } chooseProClickEvent2(){ console.log('chooseProClickEvent2') this.proChoose.active = false if(this.curIndex == 0){ //裙子 this.ShenTiShouState = "裙子" let qzSpine = this.node.getChildByName('裙子spine').getComponent(sp.Skeleton) qzSpine.setAnimation(0,'黑裙子撑破',false) this.scheduleOnce(()=>{ Common5.playEffectCustom("bianchengmeinv", "sound/衣服撑开"); this.nanshifangying(false) qzSpine.setAnimation(0,'撑破裙静止',false) },1.0) }else if(this.curIndex == 1){ //按摩椅 this.headStateStr = '蛇精脸' let slSpine = this.node.getChildByName('瘦脸spine') slSpine.active = true slSpine.getComponent(sp.Skeleton).setAnimation(0,'瘦脸仪',false) slSpine.getComponent(sp.Skeleton).setCompleteListener(()=>{ let sprite = this.node.getChildByName('头Node').getComponent(cc.Sprite) Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/蛇精脸/蛇精脸",sprite) this.nanshifangying(false) }) }else if(this.curIndex == 2){ //烫发棒 let tfSpine = this.node.getChildByName('头发spine') tfSpine.active = true tfSpine.getComponent(sp.Skeleton).setAnimation(0,'直板夹',false) tfSpine.getComponent(sp.Skeleton).setCompleteListener(()=>{ tfSpine.active = false this.node.getChildByName('头发乱前').active = false this.node.getChildByName('头发乱后').active = false this.node.getChildByName('爆炸头').active = true this.nanshifangying(false) }) }else if(this.curIndex == 3){ //大便 let msSpine = this.node.getChildByName('墨水spine') Common5.playEffectCustom("bianchengmeinv", "sound/丢屎"); msSpine.active = true msSpine.getComponent(sp.Skeleton).setAnimation(0,'屎',false) msSpine.getComponent(sp.Skeleton).setCompleteListener(()=>{ msSpine.active = false this.nanshifangying(false) //身体 let spriteSt = this.node.getChildByName('身体').getComponent(cc.Sprite) if(this.ShenTiShouState == '束腰'){ Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/瘦身体/黑",spriteSt) }else if(this.ShenTiShouState == '绳子'){ Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/绳子身体/黑",spriteSt) }else{ Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/胖身体/黑",spriteSt) let qzSpine = this.node.getChildByName('裙子spine').getComponent(sp.Skeleton) qzSpine.setAnimation(0,'撑破裙皮肤黑',false) } //头 let spriteHead = this.node.getChildByName('头Node').getComponent(cc.Sprite) Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/"+this.headStateStr+"/黑",spriteHead) this.nanshifangying(false) }) } this.unlockLevel(this.curIndex) this.curIndex++ } chooseProClickEvent3(){ console.log('chooseProClickEvent3') this.proChoose.active = false if(this.curIndex == 0){ //塑腰 this.ShenTiShouState = "束腰" this.showDaoju('束腰',()=>{ let sprite = this.node.getChildByName('身体').getComponent(cc.Sprite) Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/瘦身体/变瘦身体",sprite) this.node.getChildByName('裙子spine').active = false this.nanshifangying(true) }) }else if(this.curIndex == 1){ //胶布 this.headStateStr = '美头' Common5.playEffectCustom("bianchengmeinv", "sound/胶带"); let slSpine = this.node.getChildByName('瘦脸spine') slSpine.active = true slSpine.getComponent(sp.Skeleton).setAnimation(0,'胶带',false) slSpine.getComponent(sp.Skeleton).setCompleteListener(()=>{ let sprite = this.node.getChildByName('头Node').getComponent(cc.Sprite) Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/美头/美头",sprite) this.nanshifangying(true) }) }else if(this.curIndex == 2){ //水桶 Common5.playEffectCustom("bianchengmeinv", "sound/倒水"); let tfSpine = this.node.getChildByName('头发spine') tfSpine.active = true tfSpine.getComponent(sp.Skeleton).setAnimation(0,'水桶泼水',false) tfSpine.getComponent(sp.Skeleton).setCompleteListener(()=>{ tfSpine.active = false this.node.getChildByName('头发乱前').active = false this.node.getChildByName('头发乱后').active = false this.node.getChildByName('头发精致前').active = true this.node.getChildByName('头发精致后').active = true this.nanshifangying(true) }) }else if(this.curIndex == 3){ //身体乳 this.showDaoju('身体乳',()=>{ if(this.ShenTiShouState == '束腰'){ this.node.getChildByName('汗毛瘦').active = true }else{ this.node.getChildByName('汗毛胖').active = true } this.nanshifangying(false) }) } this.unlockLevel(this.curIndex) this.curIndex++ } showDaoju(proStr, callfunc){ this.node.getChildByName('proNode').active = true this.node.getChildByName('proNode').opacity = 255 let sprite1 = this.node.getChildByName('proNode').getComponent(cc.Sprite) Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,"texture/道具/"+proStr,sprite1) cc.tween(this.node.getChildByName('proNode')) .to(2, {opacity:0}) .call(()=>{ if(callfunc){ callfunc() } }) .start() } nanshifangying(isHappy, isNext = true){ if(isHappy){ this.node.getChildByName('男1').getChildByName('嫌弃表情').active = false this.node.getChildByName('男2').getChildByName('嫌弃表情').active = false this.node.getChildByName('男3').getChildByName('嫌弃表情').active = false this.node.getChildByName('色表情').active = true Common5.playEffectCustom("bianchengmeinv", "sound/喜欢"); }else{ this.node.getChildByName('男1').getChildByName('嫌弃表情').active = true this.node.getChildByName('男2').getChildByName('嫌弃表情').active = true this.node.getChildByName('男3').getChildByName('嫌弃表情').active = true this.node.getChildByName('色表情').active = false Common5.playEffectCustom("bianchengmeinv", "sound/嫌弃"); } this.scheduleOnce(()=>{ this.node.getChildByName('男1').getChildByName('嫌弃表情').active = false this.node.getChildByName('男2').getChildByName('嫌弃表情').active = false this.node.getChildByName('男3').getChildByName('嫌弃表情').active = false this.node.getChildByName('色表情').active = false if(isNext){ this.showProChooseNodes() } },2.0) } endGameView(isSuccess) { Game.ins.stopTime(); if(isSuccess){ this.scheduleOnce(()=>{ Game.ins.showSuccess() },3) }else{ this.scheduleOnce(()=>{ Game.ins.showFail() },3) } } }