// 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 { ryw_Event } from "../../FrameWork/Event/EventEnum"; import EventMgr from "../../FrameWork/Event/EventMgr"; import User from "../../FrameWork/User/User"; import AppPlatform from "../../FrameWork/Util/AppPlatform"; import Common5 from "../../Platform/th/Common5"; import TaskManager, { MainTaskIdEnum } from "../../Scripts/JuQingChat/TaskManager"; import BagManager from "../../Scripts/Manager/BagManager"; import ChouShuiDataManager from "../../Scripts/Manager/ChouShuiDataManager"; import PrefabManage, { GameType } from "../../Scripts/PrefabManager/PrefabManage"; import ChoushuiTwo from "./ChoushuiTwo"; const { ccclass, property } = cc._decorator; @ccclass export default class ChoushuiFirst extends cc.Component { @property(cc.Node) contentNode: cc.Node = null @property(cc.Node) itemChild: cc.Node = null @property(cc.Node) shuaxin: cc.Node = null changehui: number = 0; itemArr = [] isAD: boolean; // LIFE-CYCLE CALLBACKS: onLoad() { } start() { // let allShuiKeng = ChouShuiDataManager.getShowWater(); // BagManager.subBagList(3008, 1) // BagManager.subBagList(3009, 1) this.initContent() //接受广播 EventMgr.onEvent_custom(ryw_Event.refreshChoushui, (posIndex) => { console.log(posIndex + "================================="); this.refreshChiTangStatus(posIndex); }, this); let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id if (mainId == MainTaskIdEnum.MainTask_307 && BagManager.getBagGoodNums(3008) <= 0) { this.node.getChildByName("shuaxin").getChildByName("jieSuoQiPao").active = true } else { this.node.getChildByName("shuaxin").getChildByName("jieSuoQiPao").active = false } } initContent() { this.itemArr = [] let tab = ChouShuiDataManager.getShowWater() console.log("获取tab==", tab) for (let i = 0; i < tab.length; i++) { this.contentNode.getChildByName('node_' + i).removeAllChildren() let item = cc.instantiate(this.itemChild) item.active = true item.parent = this.contentNode.getChildByName('node_' + i) item.getChildByName("itemName").getComponent(cc.Label).string = tab[i].nameStr Common5.getSpriteFrameFromBundle("Choushui", "texture/1/" + tab[i].sprUrl, item.getChildByName("liang").getComponent(cc.Sprite)); Common5.getSpriteFrameFromBundle("Choushui", "texture/1/" + tab[i].sprUrl, item.getChildByName("hui").getComponent(cc.Sprite)); item.attr({ index: i, shuikengConfig: tab[i] }) this.itemArr.push(item) if (tab[i].isChoushui) { item.getChildByName('hui').active = tab[i].isChoushui item.getChildByName('liang').active = !tab[i].isChoushui } } } //进入玩法按钮 Choushuitwobutton(event) { let bindConfig = event.target.shuikengConfig PrefabManage.loadPrefabByType(GameType.ChoushuiTwo, null, (prefabNode) => { prefabNode.getComponent(ChoushuiTwo).initView(event.target.index, bindConfig.type); }); } //变灰之后提示按钮 ChangeHuibutton() { PrefabManage.showTextTips("该水坑已被抽干!"); } //刷新池塘状态 refreshChiTangStatus(typeIndex) { //console.log(this.itemArr); let tab = User.getCurDayWaterArr() let bHui = tab[typeIndex].isChoushui this.itemArr[typeIndex].getChildByName('hui').active = bHui this.itemArr[typeIndex].getChildByName('liang').active = !bHui // this.item.getChildByName('hui').active = bHui // this.item.getChildByName('liang').active = !bHui // if(bHui){ // this.chiTangItemNodeArr[typeIndex].getChildByName('Hui').active = true // this.chiTangItemNodeArr[typeIndex].getChildByName('Liang').active = false // }else{ // this.chiTangItemNodeArr[typeIndex].getChildByName('Hui').active = false // this.chiTangItemNodeArr[typeIndex].getChildByName('Liang').active = true // } let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id if (mainId == MainTaskIdEnum.MainTask_307 && BagManager.getBagGoodNums(3008) <= 0) { this.node.getChildByName("shuaxin").getChildByName("jieSuoQiPao").active = true } else { this.node.getChildByName("shuaxin").getChildByName("jieSuoQiPao").active = false } } //刷新 onButtonshuaxin() { Common5.playEffect("sound/按键点击") let tab = { onClose: (finish) => { if (finish) { let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo() let mainId = mainTaskInfo.Id Common5.ReportDY("inLevel", `任务${mainId}-AD-鱼塘刷新`); ChouShuiDataManager.clearAllRecord(); this.initContent(); ChouShuiDataManager.setIsAD(true) } else { Common5.showTips_custom("广告未观看完"); } }, onFailed: () => { } } AppPlatform.playVideo_custom(tab) } // update (dt) {} }