Exemple #1
0
        public async Task JoinChat(JoinOrCreateRoomMesg mesg)
        {
            //获取房间
            this.room = RoomManager.GetRoom(mesg.RoomName);

            if (room == null)
            {
                Console.WriteLine($"no Room {mesg.RoomName}");
                return;
            }

            await this.room.AddAsync(Context);

            var count = await room.GetMemberCountAsync();

            Console.WriteLine("Current Chat Player Count: " + count);

            //保存名字
            me = mesg.UserName;

            //广播消息:加入房间
            Broadcast(room).OnJoinChat(mesg);

            Console.WriteLine($"{mesg.UserName} Join {mesg.RoomName} Chat. {mesg.RoomName} Chat Player Count : {count}");
        }
        public async void OnJoinChat(JoinOrCreateRoomMesg mesg)
        {
            //todo 进入场景 -- 游戏场景
            SceneManager.LoadScene(2);

            var localPlayer = mesg.UserName == LocalPlayer.PlayerName;

            var player = PlayerManager.Instance.CreatePlayer(localPlayer, mesg.UserName);

            ChatUI.alpha = 1;
            RoomUI.alpha = 0;
            if (!localPlayer)
            {
                _showMesg($"{mesg.UserName} Join Room.");
            }
        }