public void CreateLobbyPlayer(string playerID) { if (playerID == GameFramework.Instance.MyPlayer.PlayerID) { this.lobbyPlayers.Add(CreateLobbyPlayer(GameFramework.Instance.MyPlayer)); } else { Player otherPlayer = new OtherPlayer(); otherPlayer.Initialize(); otherPlayer.PlayerID = playerID; this.lobbyPlayers.Add(CreateLobbyPlayer(otherPlayer)); } }
public void RESPONSE_JOIN_ROOM(TcpPacket packet) { if (packet.header.extra == (int)EXTRA.SUCCESS) { SERVERtoCLIENT_JoinRoomPacketData recvData = new SERVERtoCLIENT_JoinRoomPacketData(); recvData.Deserialize(packet); LobbySceneGUI.Instance.ChangeLobbyToRoom(); RoomPlayer[] roomPlayers = new RoomPlayer[recvData.joinedPlayerCount]; for (int i = 0; i < recvData.joinedPlayerCount; i++) { Player player; if (recvData.joinedPlayers[i] != GameFramework.Instance.MyPlayer.PlayerID) { player = new OtherPlayer(); player.Initialize(); player.PlayerID = recvData.joinedPlayers[i]; } else { player = GameFramework.Instance.MyPlayer; } RoomPlayer roomPlayer = RoomManager.Instance.CreateRoomPlayer(player); roomPlayer.readyState = recvData.joinedPlayerReadyState[i]; roomPlayer.isLeader = recvData.isLeaders[i]; roomPlayers[i] = roomPlayer; } Room room = RoomManager.Instance.CreateRoom(recvData.roomName, recvData.roomKey, recvData.joinedPlayerCount); room.PushRoomPlayer(roomPlayers); room.Enter(); RoomGUI.Instance.Initialize(room); } }
public void RESPONSE_JOIN_ROOM_OTHER_PLAYER(TcpPacket packet) { if (packet.header.extra == (int)EXTRA.SUCCESS) { SERVERtoCLIENT_JoinRoomOtherPlayerPacketData recvData = new SERVERtoCLIENT_JoinRoomOtherPlayerPacketData(); recvData.Deserialize(packet); if (GameFramework.Instance.MyPlayer.State == PLAYER_STATE.LOBBY) { //내가 Lobby에 있을때 다른사람이 Room으로 들어갔으므로 오른쪽 유저 리스트에 해당 유저를 지워야 함 LobbyManager.Instance.RemoveLobbyPlayer(recvData.playerID); //해당 방에 사람이 들어갔으므로 방 참여자수 1 증가 RoomButton roomButton = RoomManager.Instance.GetRoomButton(recvData.roomKey); if (roomButton != null) { roomButton.IncreaseRoomJoinCount(); } } else if (GameFramework.Instance.MyPlayer.State == PLAYER_STATE.IN_ROOM) { //내가 Room에 있을때 다른사람이 Room에서 들어왔으므로 방에 해당 유저를 추가해야 함 string chatMessage = "[Server] : " + recvData.playerID + "님이 방에 입장하였습니다."; RoomGUI.Instance.ShowChatMessage(chatMessage, Color.red); Player player = new OtherPlayer(); player.Initialize(); player.PlayerID = recvData.playerID; RoomPlayer roomPlayer = RoomManager.Instance.CreateRoomPlayer(player); roomPlayer.readyState = false; roomPlayer.isLeader = false; RoomManager.Instance.EnteredRoom.PushRoomPlayer(roomPlayer); RoomGUI.Instance.UpdateRoomPlayerUIElement(RoomManager.Instance.EnteredRoom); } } }