21 lines
547 B
TypeScript
21 lines
547 B
TypeScript
import { _decorator, Component, Node, Label } from "cc"
|
|
import { IPlayer } from "../Common"
|
|
import DataManager from "../Global/DataManager"
|
|
const { ccclass, property } = _decorator
|
|
|
|
@ccclass("PlayerManager")
|
|
export class PlayerManager extends Component {
|
|
init({ id, nickname, rid }: IPlayer) {
|
|
const label = this.getComponent(Label)
|
|
let str = nickname
|
|
if (DataManager.Instance.myPlayerId === id) {
|
|
str += `(我)`
|
|
}
|
|
if (rid) {
|
|
str += `(房间${rid})`
|
|
}
|
|
label.string = str
|
|
this.node.active = true
|
|
}
|
|
}
|