import { ryw_Event } from "../../../FrameWork/Event/EventEnum"; import EventMgr from "../../../FrameWork/Event/EventMgr"; import User from "../../../FrameWork/User/User"; import Common5 from "../../../Platform/th/Common5"; import TaskManager, { MainTaskIdEnum } from "../../JuQingChat/TaskManager"; import MeiNvZhaoMu from "../../MeiNvZhaoMu/MeiNvZhaoMu"; import { ZhaoMuGameType } from "../../MeiNvZhaoMu/MeiNvZhaoMuManager"; import NewGuideScript from "../../NewGuide/NewGuideScript"; import PrefabManage, { GameType } from "../../PrefabManager/PrefabManage"; import TiShengShouYi from "../TiShengShouYi/TiShengShouYi"; import ZhongCanTingManager, { CaiXiEnum } from "./ZhongCanTingManager"; import ZhongCanTingShengJi from "./ZhongCanTingShengJi"; const { ccclass, property } = cc._decorator; @ccclass export default class ZhongCanTing extends cc.Component { @property(cc.Node) itemContent: cc.Node = null; @property(cc.Node) singleItem: cc.Node = null; @property(cc.Label) allShouYiStr: cc.Label = null; @property(cc.Node) scrollViewNode: cc.Node = null; isShowSpine: boolean = false start() { this.scheduleOnce(() => { PrefabManage.preloadPrefabByType(GameType.ZhongCanTingShengJi) PrefabManage.preloadPrefabByType(GameType.MeiNvZhaoMu) }) EventMgr.onEvent_custom(ryw_Event.refreshMiaoZhuan, () => { let allMoney = ZhongCanTingManager.getPerSecondShouYi() this.allShouYiStr.string = '秒赚:' + Common5.getNumberChangeHanzi(allMoney, '1') + '/秒' ZhongCanTingManager.checkTask() }, this) let mishubtn = this.node.getChildByName("New Sprite").getChildByName("blueBtn") cc.tween(mishubtn) .sequence( cc.tween().to(0.5,{scale:1.1}), cc.tween().to(0.5,{scale:1}), ) .repeatForever() .start() } initView(caiXi) { this.itemContent.removeAllChildren() let ZhongCanTingConfig = ZhongCanTingManager.getZhongCanTingConfig() for (let i = 0; i < ZhongCanTingConfig.length; i++) { let item = cc.instantiate(this.singleItem) item.active = true item.parent = this.itemContent } this.refreshAllItem() this.scrollViewNode.getComponent(cc.ScrollView).scrollToPercentVertical((8 - caiXi) / 8, 0.2) } refreshAllItem() { let ZhongCanTingConfig = ZhongCanTingManager.getZhongCanTingConfig() let baDaCaiXiLevelInfo = User.getBaDaCaiXiLevelInfo() for (let i = 0; i < ZhongCanTingConfig.length; i++) { let item = this.itemContent.children[i] let level = baDaCaiXiLevelInfo[i].level if (!this.isShowSpine) { Common5.getSpriteFrameFromBundle("ZhongCanTing", "texture/" + ZhongCanTingConfig[i].caiMing, item.getChildByName('tittleIcon').getComponent(cc.Sprite)); item.getChildByName('spineNode').getComponent(sp.Skeleton).setAnimation(0, ZhongCanTingConfig[i].spineName, true) item.getChildByName('spineNode').getComponent(sp.Skeleton).timeScale = 1 - i * 0.05 } let shouyi = 0 for (let j = 0; j <= level - 1; j++) { shouyi += ZhongCanTingConfig[i].meiMiaoShouYiArr[j] } item.getChildByName('shouYi').getComponent(cc.Label).string = Common5.getNumberChangeHanzi(shouyi, '1') + '/秒' // item.getChildByName('shouYi').getComponent(cc.Label).string = Common5.getNumberChangeHanzi(ZhongCanTingConfig[i].meiMiaoShouYiArr[level - 1], '1') + '/秒' item.getChildByName('dengJi').getComponent(cc.Label).string = '' + level + '级' if (level >= ZhongCanTingConfig[i].maxLevel) { item.getChildByName('btnFinishYanZhi').active = true item.getChildByName('btnYanZhi').active = false } else { item.getChildByName('btnFinishYanZhi').active = false item.getChildByName('btnYanZhi').active = true } item.getChildByName('btnYanZhi').attr({ bindId: i, bindLevel: level }) item.getChildByName('btnFinishYanZhi').attr({ bindId: i, bindLevel: level }) item.getChildByName('锁').attr({ subtitle: ZhongCanTingConfig[i].subtitle }) if (ZhongCanTingManager.getCaiXiUnlockStatus(ZhongCanTingConfig[i].unLockTag)) { item.getChildByName('锁').active = false } else { item.getChildByName('锁').active = true } let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id let config = TaskManager.getTaskConfigById(mainId); if (mainId == MainTaskIdEnum.MainTask_311 && i == 0 && level == 1) { let node = this.itemContent.children[0].getChildByName("btnYanZhi") this.guideView([node]); } // else if (mainId == MainTaskIdEnum.MainTask_810 && i == 2 && level < 5) { // this.itemContent.children[2].getChildByName("jieSuoQiPao").active = true // } else if (mainId == MainTaskIdEnum.MainTask_1406 && i == 2 && level < 8) { // this.itemContent.children[2].getChildByName("jieSuoQiPao").active = true // } else { // this.itemContent.children[i].getChildByName("jieSuoQiPao").active = false // } this.itemContent.children[i].getChildByName("jieSuoQiPao").active = false if (config.GMCapitalLevel && config.GMCapitalLevel.length > 0) { for (let index = 0; index < config.GMCapitalLevel.length; index++) { let arr = config.GMCapitalLevel[index] if (arr[0] == i && level < arr[1]) { this.itemContent.children[i].getChildByName("jieSuoQiPao").active = true break } } } } let allMoney = ZhongCanTingManager.getPerSecondShouYi() this.allShouYiStr.string = '秒赚:' + Common5.getNumberChangeHanzi(allMoney, '1') + '/秒' this.isShowSpine = true } guideView(nodeArray) { PrefabManage.loadPrefabByType(GameType.GuideMskNode, null, (prefab) => { let guideNodeArray = nodeArray let firstNode = guideNodeArray.shift() prefab.getComponent(NewGuideScript).setBindNode(firstNode, guideNodeArray) }) } onBtnClickYanZhi(event) { let id = event.target.bindId let level = event.target.bindLevel PrefabManage.loadPrefabByType(GameType.ZhongCanTingShengJi, null, (prefabNode) => { prefabNode.getComponent(ZhongCanTingShengJi).initView(id, level, () => { this.refreshAllItem() EventMgr.emitEvent_custom(ryw_Event.refreshJianZaoXinXi); }) }) } onBtnClickTiLiJiaCheng() { PrefabManage.loadPrefabByType(GameType.TiShengShouYi, null, (prefabNode) => { prefabNode.getComponent(TiShengShouYi).initView(2) }) } onBtnClickNaoLiJiaCheng() { PrefabManage.loadPrefabByType(GameType.TiShengShouYi, null, (prefabNode) => { prefabNode.getComponent(TiShengShouYi).initView(3) }) } onClickSuo(event) { let subtitle = event.target.subtitle let num = subtitle - User.getCurTaskIndex(); if (num > 0) { PrefabManage.showTextTips(`还差${num}个任务解锁`); } } zhaomuClickEvent() { Common5.playEffect("CommonRes/sound/按键点击") PrefabManage.loadPrefabByType(GameType.MeiNvZhaoMu, null, (prefabNode) => { prefabNode.getComponent(MeiNvZhaoMu).initView(0) }) } }