Bottom.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { _decorator, Component, Label, Node, Sprite } from 'cc';
  2. import { ModulerBase } from '../../GameFrameWork/ModulerBase';
  3. import { GameInfo } from '../../../GameInfo';
  4. import { resMgr } from '../../../Frames/ResourcesMgr';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('Bottom')
  7. export class Bottom extends ModulerBase {
  8. private _lvNumber: Node = null;
  9. private _oreGrade: Node = null;
  10. private _oreSpeed: Node = null;
  11. private _characterSlot: Node = null;
  12. private _ownDiamondNum: Node = null;
  13. private _needDiamondNum: Node = null;
  14. protected onLoad(): void {
  15. this._lvNumber = this.node.getChildByPath("labelLevel/_lvNumber");
  16. this._oreGrade = this.node.getChildByPath("OreSpeed/_oreGrade");
  17. this._oreSpeed = this.node.getChildByPath("OreSpeed/_oreSpeed");
  18. this._characterSlot = this.node.getChildByName("CharacterSlot");
  19. this._ownDiamondNum = this.node.getChildByPath("Diamond/OwnNumber");
  20. this._needDiamondNum = this.node.getChildByPath("Diamond/NeedDiamond/NeedNumber");
  21. }
  22. init(){
  23. this._lvNumber.getComponent(Label).string = String(GameInfo.Instance.getCurlv());
  24. this._oreGrade.getComponent(Label).string = `等级:${GameInfo.Instance.getOreGrade()}`;
  25. this._oreSpeed.getComponent(Label).string = String(GameInfo.Instance.getOreSpeed()) + "/分钟";
  26. this._ownDiamondNum.getComponent(Label).string = String(GameInfo.Instance.getOwnDiamondNum());
  27. this._needDiamondNum.getComponent(Label).string = String(GameInfo.Instance.getNeedDiamondNum());
  28. this._setRoleImg();
  29. }
  30. private _setRoleImg(){
  31. for(let i = 0; i < this._characterSlot.children.length; i++){
  32. const role: Node = this._characterSlot.children[i];
  33. role.getChildByName("Sprite").getComponent(Sprite).spriteFrame =
  34. resMgr.getSpriteFrame(GameInfo.Instance.getRoleImgNames()[i])
  35. }
  36. }
  37. }