20 lines
565 B
TypeScript
Raw Normal View History

2022-12-08 21:14:02 +08:00
import { _decorator, Component, Node, Label } from "cc";
import DataManager from "../Global/DataManager";
2022-12-01 22:26:41 +08:00
const { ccclass, property } = _decorator;
2022-12-08 21:14:02 +08:00
@ccclass("PlayerManager")
2022-12-03 20:06:57 +08:00
export class PlayerManager extends Component {
2022-12-08 21:14:02 +08:00
init({ id, nickname, rid }: { id: number; nickname: string; rid: number }) {
const label = this.getComponent(Label);
let str = nickname;
2022-12-01 22:26:41 +08:00
if (DataManager.Instance.myPlayerId === id) {
2022-12-08 21:14:02 +08:00
str += `(我)`;
2022-12-01 22:26:41 +08:00
}
if (rid !== -1) {
2022-12-08 21:14:02 +08:00
str += `(房间${rid})`;
2022-12-01 22:26:41 +08:00
}
2022-12-08 21:14:02 +08:00
label.string = str;
this.node.active = true;
2022-12-01 22:26:41 +08:00
}
}