21 lines
547 B
TypeScript
Raw Normal View History

2022-12-14 20:25:40 +08:00
import { _decorator, Component, Node, Label } from "cc"
2022-12-15 16:41:37 +08:00
import { IPlayer } from "../Common"
2022-12-14 20:25:40 +08:00
import DataManager from "../Global/DataManager"
const { ccclass, property } = _decorator
2022-12-01 22:26:41 +08:00
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-15 16:41:37 +08:00
init({ id, nickname, rid }: IPlayer) {
2022-12-14 20:25:40 +08:00
const label = this.getComponent(Label)
let str = nickname
2022-12-01 22:26:41 +08:00
if (DataManager.Instance.myPlayerId === id) {
2022-12-14 20:25:40 +08:00
str += `(我)`
2022-12-01 22:26:41 +08:00
}
2022-12-14 20:25:40 +08:00
if (rid) {
str += `(房间${rid})`
2022-12-01 22:26:41 +08:00
}
2022-12-14 20:25:40 +08:00
label.string = str
this.node.active = true
2022-12-01 22:26:41 +08:00
}
}