21 lines
617 B
TypeScript
21 lines
617 B
TypeScript
|
import { _decorator, Component, Node, Label } from 'cc';
|
||
|
import { EventEnum } from '../Enum';
|
||
|
import EventManager from '../Global/EventManager';
|
||
|
const { ccclass, property } = _decorator;
|
||
|
|
||
|
@ccclass('RoomItemManager')
|
||
|
export class RoomItemManager extends Component {
|
||
|
id: number
|
||
|
init({ id, players }: { id: number, players: Array<{ id: number, nickname: string }> }) {
|
||
|
this.id = id
|
||
|
const label = this.getComponent(Label)
|
||
|
label.string = `房间id:${id},当前人数:${players.length}`
|
||
|
this.node.active = true
|
||
|
}
|
||
|
|
||
|
handleClick() {
|
||
|
EventManager.Instance.emit(EventEnum.RoomJoin, this.id)
|
||
|
}
|
||
|
}
|
||
|
|