public new void SetNextPlayer() { string[] playersOrder = NetworkCustomProperties.GetRoomProperty(NetworkCustomProperties.PLAYERS_ORDER) as string[]; string nextPlayer = null; if (this.currentPlayerController == null && players.Count > 0) { this.currentPlayerController = getPlayerByName(playersOrder[0]); nextPlayer = playersOrder[0]; } else if (this.currentPlayerController != null) { var currentIndex = 0; foreach (string playerC in playersOrder) { if (currentPlayerController.Player.GetPlayerName().Equals(playerC)) { break; } currentIndex++; } if (currentIndex == playersOrder.Length - 1) { this.currentPlayerController = getPlayerByName(playersOrder[0]); nextPlayer = playersOrder[0]; } else { this.currentPlayerController = getPlayerByName(playersOrder[currentIndex + 1]); nextPlayer = playersOrder[currentIndex + 1]; } } NetworkCustomProperties.AddRoomProperty(NetworkCustomProperties.NEXT_PLAYER, nextPlayer); }
private void Cmd_ShuffleData() { Debug.Log("Cmd_ShuffleData"); PickUpPlayersOrder(); string[] playersOrder = new string[players.Count]; for (var i = 0; i < players.Count; i++) { PlayerController pc = players[i]; playersOrder[i] = pc.Player.GetPlayerName(); } ShuffleTerritories(); NetworkCustomProperties.AddRoomProperty(NetworkCustomProperties.PLAYERS_ORDER, playersOrder); }
public void HandleReadyButton() { int playersReady = (int)NetworkCustomProperties.GetRoomProperty(NetworkCustomProperties.ROOM_PLAYERS_READY); if (readyButton.isOn) { playersReady++; } else if (playersReady > 0) { playersReady--; } NetworkCustomProperties.AddPlayerProperty(NetworkCustomProperties.PLAYER_IS_READY, readyButton.isOn); NetworkCustomProperties.AddRoomProperty(NetworkCustomProperties.ROOM_PLAYERS_READY, playersReady); }
public void HandleColor(Dropdown change) { int i = 0; foreach (KeyValuePair <int, Photon.Realtime.Player> player in PhotonNetwork.CurrentRoom.Players) { Color color = GetColorByValue(playersTable[i].GetComponentInChildren <Dropdown>().value); i++; int colorIndex = 0; for (colorIndex = 0; colorIndex < GameSettings.playerColors.Length; colorIndex++) { if (GameSettings.playerColors[colorIndex].Equals(color)) { break; } } NetworkCustomProperties.AddPlayerProperty(player.Value, NetworkCustomProperties.PLAYER_COLOR, colorIndex); } }
// Update is called once per frame void Update() { var i = 0; if (PhotonNetwork.CurrentRoom == null) { return; } foreach (KeyValuePair <int, Photon.Realtime.Player> player in PhotonNetwork.CurrentRoom.Players) { Debug.Log(playersTable[i].GetComponentInChildren <Text>().text); if (string.Equals(playersTable[i].GetComponentInChildren <Text>().text, NO_PLAYER, System.StringComparison.OrdinalIgnoreCase)) { playersTable[i].GetComponentInChildren <Text>().text = player.Value.NickName; } if (player.Value.CustomProperties.ContainsKey(NetworkCustomProperties.PLAYER_COLOR)) { playersTable[i].GetComponentInChildren <Dropdown>().value = GetValueByColor(GameSettings.playerColors[(int)NetworkCustomProperties.GetPlayerProperty(player.Value, NetworkCustomProperties.PLAYER_COLOR)]); } if (player.Value.CustomProperties.ContainsKey(NetworkCustomProperties.PLAYER_IS_READY)) { playersTable[i].GetComponentInChildren <Toggle>().isOn = (bool)player.Value.CustomProperties[NetworkCustomProperties.PLAYER_IS_READY]; } playersTable[i].GetComponentInChildren <Dropdown>().interactable = PhotonNetwork.IsMasterClient || PhotonNetwork.NickName.Equals(playersTable[i].GetComponentInChildren <Text>().text); i++; } int playersReady = (int)NetworkCustomProperties.GetRoomProperty(NetworkCustomProperties.ROOM_PLAYERS_READY); if (playersReady == PhotonNetwork.CurrentRoom.Players.Count) { startButton.gameObject.SetActive(PhotonNetwork.IsMasterClient); } else { startButton.gameObject.SetActive(false); } }
public void GetNextPlayer() { string nextPlayer = NetworkCustomProperties.GetRoomProperty(NetworkCustomProperties.NEXT_PLAYER) as string; this.currentPlayerController = getPlayerByName(nextPlayer); }