import GameM, { AUDIO_TYPE } from "../manager/GameM"; import GuideMng from "../manager/GuideMng"; import BookItem from "../other/item/BookItem"; import { PlayerPrefs } from "../tools/MyExtends"; import BasePanel from "../uiFrames/BasePanel"; const { ccclass, property } = cc._decorator; @ccclass export default class RichCollectPanel extends BasePanel { @property(cc.Node) panelNode: cc.Node = null; @property(cc.Node) content: cc.Node = null; @property(cc.Node) itemNode: cc.Node = null; private isInit: boolean = false; private data: any = null; private dataIndex: number = 0; /* fairyjadec: Array(2) 0: {id: 1, scripture: 100, rewardfairyJade: 50} 1: id: 2 rewardfairyJade: 60 scripture: 300 */ OnEnter(param: any) { this.Init(param); this.panelNode.scale = 0; this.node.active = true; cc.tween(this.panelNode).to(0.2, { scale: 1 }, { easing: "backOut" }) .call(() => { if (GuideMng.Ins.CurGuideId == 23 && PlayerPrefs.GetInt("GGuide23", 0) != 1) { //引导取经 大富翁 GuideMng.Ins.ResumeGuide(); } }) .start(); } Init(data) { this.data = data; this.content.removeAllChildren(); this.dataIndex = 0; this.isInit = true; //if (!this.isInit) { // this.isInit = true; //for (let i = 0; i < data.length; i++) { // let copynode = cc.instantiate(this.itemNode); // this.content.addChild(copynode); // copynode.active = true; // copynode.getComponent(BookItem).Init(data[i].id, data[i].rewardfairyJade, data[i].scripture); //} //} } OnExit() { this.node.active = false; this.isInit = false; //引导取经 大富翁 GuideMng.Ins.CheckRichGuide22(); } update(dt) { if (this.isInit) { if (this.dataIndex < this.data.length) { let copynode = cc.instantiate(this.itemNode); this.content.addChild(copynode); copynode.active = true; copynode.getComponent(BookItem).Init(this.data[this.dataIndex].id, this.data[this.dataIndex].rewardfairyJade, this.data[this.dataIndex].scripture); this.dataIndex++; //console.log("DataIndex:"+this.dataIndex); } } } Click_CloseBtn() { this.OnExit(); GameM.audioM.playEffect(AUDIO_TYPE.button); } }