GameRankItem.ts 741 B

12345678910111213141516171819202122232425
  1. import { _decorator, color, Color, Component, Label, Node, Sprite } from 'cc';
  2. import { GameMgr } from '../../module_basic/scripts/GameMgr';
  3. const { ccclass, property } = _decorator;
  4. const TOP_RANK_COLORS = [
  5. new Color(0,255,0,255),
  6. new Color(255,255,255,255),
  7. ]
  8. @ccclass('TankGameRankItem')
  9. export class TankGameRankItem extends Component {
  10. @property(Label) lblInfo;
  11. @property(Sprite) sprBg;
  12. setInfo(rank:number,name:string,score:number,teamId:number) {
  13. this.lblInfo.string = `${rank}.${name} (${score})`;
  14. if(teamId == GameMgr.inst.selfPlayer.teamId){
  15. this.lblInfo.color = TOP_RANK_COLORS[0];
  16. }
  17. else{
  18. this.lblInfo.color = TOP_RANK_COLORS[1];
  19. }
  20. }
  21. }