import { _decorator, Component, Label, Node, Sprite } from 'cc'; import { ModulerBase } from '../../GameFrameWork/ModulerBase'; import { GameInfo } from '../../../GameInfo'; import { resMgr } from '../../../Frames/ResourcesMgr'; const { ccclass, property } = _decorator; @ccclass('Bottom') export class Bottom extends ModulerBase { private _lvNumber: Node = null; private _oreGrade: Node = null; private _oreSpeed: Node = null; private _characterSlot: Node = null; private _ownDiamondNum: Node = null; private _needDiamondNum: Node = null; protected onLoad(): void { this._lvNumber = this.node.getChildByPath("labelLevel/_lvNumber"); this._oreGrade = this.node.getChildByPath("OreSpeed/_oreGrade"); this._oreSpeed = this.node.getChildByPath("OreSpeed/_oreSpeed"); this._characterSlot = this.node.getChildByName("CharacterSlot"); this._ownDiamondNum = this.node.getChildByPath("Diamond/OwnNumber"); this._needDiamondNum = this.node.getChildByPath("Diamond/NeedDiamond/NeedNumber"); } init(){ this._lvNumber.getComponent(Label).string = String(GameInfo.Instance.getCurlv()); this._oreGrade.getComponent(Label).string = `等级:${GameInfo.Instance.getOreGrade()}`; this._oreSpeed.getComponent(Label).string = String(GameInfo.Instance.getOreSpeed()) + "/分钟"; this._ownDiamondNum.getComponent(Label).string = String(GameInfo.Instance.getOwnDiamondNum()); this._needDiamondNum.getComponent(Label).string = String(GameInfo.Instance.getNeedDiamondNum()); this._setRoleImg(); } private _setRoleImg(){ for(let i = 0; i < this._characterSlot.children.length; i++){ const role: Node = this._characterSlot.children[i]; role.getChildByName("Sprite").getComponent(Sprite).spriteFrame = resMgr.getSpriteFrame(GameInfo.Instance.getRoleImgNames()[i]) } } }