public void HandleLeaveDungeonRequest(LeavesDungeonRequestMessage message, int connectID) { PlayerData playerData = serverDataHolder.players.Find(x => x.playerIndex == connectID); RoomData currentRoom = serverDataHolder.rooms[playerData.roomID[0], playerData.roomID[1]]; Debug.Log("leave dungeon id = " + connectID); //check if player can leave dungeon if (!currentRoom.containsExit) { RequestDenied(message, connectID); return; } Debug.Log("leave ID = " + connectID); //edit the list serverDataHolder.activePlayerIDs.Remove(connectID); //needs testing playerData.activeInDungeon = false; //send message to all players the player left dungeon PLayerLeftDungeonMessage leftMessage = new PLayerLeftDungeonMessage() { PlayerID = connectID }; SendMessageToAll(leftMessage); //next turn NextPlayerTurn(); }
public void PlayerLeftDungeon(ref DataStreamReader reader) { var message = new PLayerLeftDungeonMessage(); message.DeserializeObject(ref reader); //I left dungeon if (message.PlayerID == dataHolder.myData.playerIndex) { dataHolder.game.cRoom.ILeftDungeon(); } else { PlayerData leftPlayer = dataHolder.game.cRoom.otherPlayersInRoom.Find(x => x.playerIndex == message.PlayerID); //Other player left dungeon //PlayerData leftPlayer = dataHolder.players.Find(x => x.playerIndex == message.PlayerID); if (leftPlayer != null) { Debug.Log("left player: " + leftPlayer); dataHolder.game.cRoom.PlayerLeftRoom(leftPlayer); } } //update ui dataHolder.game.cRoom.UpdatePlayerUIElements(); }