private void WebGameCreateAiPlayerContainer(PlayerCreationEntity playerCreationEntity) { var createdObject = Instantiate(WebGameNewPlayerAiPrefab, WebGamePlayersContainer.transform); var playerContainer = createdObject.GetComponent <PlayersContainerScript>(); var color = playerCreationEntity.GetColor(); playerContainer.SetColor(color); playerContainer.SetTeam(playerCreationEntity.Team); playerContainer.SetUnitsNumber(playerCreationEntity.UnitsNumber); }
public static void AddBotToRoomHashtable(PlayerCreationEntity player) { var aiPlayers = CurrentRoomGetCustomPropertyPlayers(PhotonPropertiesNames.AiPlayers); aiPlayers.Add(player.GetColor().ToString(), player.AsDistionary()); var hash = new Hashtable { { PhotonPropertiesNames.AiPlayers, aiPlayers } }; PhotonNetwork.CurrentRoom.SetCustomProperties(hash); }
public static void RemoveHumanFromRoomHashtable(PlayerCreationEntity player) { var humanPlayers = CurrentRoomGetCustomPropertyPlayers(PhotonPropertiesNames.HumanPlayers); humanPlayers.Remove(player.GetColor().ToString()); var hash = new Hashtable { { PhotonPropertiesNames.HumanPlayers, humanPlayers } }; PhotonNetwork.CurrentRoom.SetCustomProperties(hash); }
public void LoadFromServer() { ResetMatch(); PlayersToCreate.Clear(); var aiPlayers = CustomPropertiesHelper.CurrentRoomGetCustomPropertyPlayers(PhotonPropertiesNames.AiPlayers); var humanPlayers = CustomPropertiesHelper.CurrentRoomGetCustomPropertyPlayers(PhotonPropertiesNames.HumanPlayers); foreach (var el in aiPlayers) { var dict = (Dictionary <string, object>)el.Value; PlayersToCreate.Add(PlayerCreationEntity.FromDictionary(dict)); } foreach (var el in humanPlayers) { var dict = (Dictionary <string, object>)el.Value; PlayersToCreate.Add(PlayerCreationEntity.FromDictionary(dict)); } }
private void WebGameRefreshHostGuestList() { foreach (Transform child in WebGamePlayersContainer.transform) { Destroy(child.gameObject); } var aiPlayers = CustomPropertiesHelper.CurrentRoomGetCustomPropertyPlayers(PhotonPropertiesNames.AiPlayers); var humanPlayers = CustomPropertiesHelper.CurrentRoomGetCustomPropertyPlayers(PhotonPropertiesNames.HumanPlayers); foreach (var el in aiPlayers) { var dict = (Dictionary <string, object>)el.Value; WebGameCreateAiPlayerContainer(PlayerCreationEntity.FromDictionary(dict)); } foreach (var el in humanPlayers) { var dict = (Dictionary <string, object>)el.Value; WebGameCreateHumanPlayerContainer(PlayerCreationEntity.FromDictionary(dict)); } }