public override void OnPlayerLeftRoom(Player other) { string text = other.NickName + " has left the game."; PlayerUi.SendMessage("AddActivityText", text, SendMessageOptions.RequireReceiver); // Reset all owned properties of the player // We do this locally for every player so we don't need to use the network for (int i = 0; i < 40; i++) { if (board.locations[i] is Property) { Property property = (Property)board.locations[i]; if (property.owner == other) { property.Reset(); } } else if (board.locations[i] is Utility) { Utility property = (Utility)board.locations[i]; if (property.owner == other) { property.owner = null; } } else if (board.locations[i] is Railroad) { Railroad property = (Railroad)board.locations[i]; if (property.owner == other) { property.owner = null; } } } if (PhotonNetwork.IsMasterClient) { if (players[currentPlayer] == other) { players = PhotonNetwork.PlayerList; NextPlayer(); } else { players = PhotonNetwork.PlayerList; CheckNumBankrupt(); } } else { players = PhotonNetwork.PlayerList; } }
public void OnEvent(EventData photonEvent) { byte eventCode = photonEvent.Code; switch (eventCode) { case SendNewActivityLineCode: object[] arr = (object[])photonEvent.CustomData; ReceiveActivityMessage(arr); break; case PlayerTurnCode: currentPlayer = (int)photonEvent.CustomData; StartTurn(); break; case ReceiveMoneyCode: int amount = (int)photonEvent.CustomData; PlayerManager.balance += amount; break; case PropertyChangeCode: object[] data = (object[])photonEvent.CustomData; int location = (int)data[0]; string property = (string)data[1]; if (board.locations[location] is Utility) { Utility temp = (Utility)board.locations[location]; if (property == "owner") { if (data[2] == null) { temp.owner = null; } else { temp.owner = players[(int)data[2]]; } } board.locations[location] = temp; } else if (board.locations[location] is Railroad) { Railroad temp = (Railroad)board.locations[location]; if (property == "owner") { if (data[2] == null) { temp.owner = null; } else { temp.owner = players[(int)data[2]]; } } board.locations[location] = temp; } else if (board.locations[location] is Property) { Property temp = (Property)board.locations[location]; if (property == "owner") { if (data[2] == null) { temp.owner = null; } else { temp.owner = players[(int)data[2]]; } board.locations[location] = temp; } else if (property == "buildHouse") { temp.BuildHouse(); } else if (property == "reset") { temp.Reset(); } board.locations[location] = temp; } break; case EndGameCode: int?playerNum = (int?)photonEvent.CustomData; if (playerNum == null) { EndGame(null); } else { EndGame(players[(int)playerNum], true); } break; case CardCode: string[] data2 = (string[])photonEvent.CustomData; cardWindow.DisplayCard(data2[0], data2[1]); break; } }