123456789101112131415161718192021222324252627282930313233 |
- import { _decorator, Component, Node } from "cc";
- import BaseUI from "../../scripts/base/BaseUI";
- import { RankPlayerDto } from "../../scripts/api/RankM";
- import Utils from "../../scripts/utils/Utils";
- const { ccclass, property } = _decorator;
- @ccclass("RankPlayerItem")
- export class RankPlayerItem extends BaseUI {
- init(data: RankPlayerDto) {
- // this.setText("lbl_rank", data.rank.toString());
- let rank_icons = this.FindNode("rank_icons");
- rank_icons.active = data.rank <= 3;
- let lbl_rank = this.FindNode("lbl_rank");
- lbl_rank.active = data.rank > 3;
- if (data.rank > 3) {
- this.setText("lbl_rank", data.rank.toString());
- } else {
- rank_icons.children.forEach((child) => {
- child.active = false;
- });
- rank_icons.getChildByName(data.rank + "").active = true;
- }
- this.setText("lbl_rank_value", Utils.formatNumber(data.rankValue, 1));
-
- if (data.userName != null) {
- this.setText("lbl_user_name", data.userName);
- } else {
- this.setText("lbl_user_name", "-");
- }
- }
- }
|