21 lines
577 B
TypeScript
Raw Permalink Normal View History

2023-01-06 20:30:08 +08:00
import { _decorator, Component, Node, Label } from "cc"
import { IRoom } from "../Common"
import { EventEnum } from "../Enum"
import EventManager from "../Global/EventManager"
const { ccclass, property } = _decorator
2022-12-01 22:26:41 +08:00
2022-12-08 21:14:02 +08:00
@ccclass("RoomManager")
2022-12-03 20:06:57 +08:00
export class RoomManager extends Component {
2023-01-06 20:30:08 +08:00
id: number
init({ id, players }: IRoom) {
this.id = id
const label = this.getComponent(Label)
label.string = `房间id:${id},当前人数:${players.length}`
this.node.active = true
2022-12-01 22:26:41 +08:00
}
handleClick() {
2023-01-06 20:30:08 +08:00
EventManager.Instance.emit(EventEnum.RoomJoin, this.id)
2022-12-01 22:26:41 +08:00
}
}