public MultiSpawnPlayer(int _T, int _C, TeamSystem.Team _t, string _P) { T = _T; C = _C; t = (int)_t; P = _P; }
//creates a player info pannel for the player data given under the team given private void CreatePannelForPlayer(PlayerData player, TeamSystem.Team team) { //spawn the object in GameObject instance = Instantiate(playerPannelPrefab, scrollRects[(int)team].GetComponent <ScrollRect>().content); //move it down for formatting instance.transform.Translate( 0, -(instance.GetComponent <RectTransform>().rect.height *(playersInTeam[team] - 1)) - ((playersInTeam[team] - 1) * 5), 0); //fill the player pannel in with the data from the playerdata object player.FillUIElement(instance.GetComponent <PlayerDescriptionUI>()); //store it in the playerPannels dictionary playerPannels[player.PlayerName] = new Tuple <GameObject, TeamSystem.Team>(instance, team); //increase the amount of players in that team playersInTeam[team]++; }
public void AddPlayerToTeamList(PlayerData data, TeamSystem.Team newTeam) { //check if we're keeping track of how many players are in the team if (!playersInTeam.TryGetValue(newTeam, out _)) { //we aren't, add an entry for the team playersInTeam.Add(newTeam, 1); } //otherwise we can do nothing //see if the player pannel exists for this player if (playerPannels.TryGetValue(data.PlayerName, out Tuple <GameObject, TeamSystem.Team> pannel)) { //yep, destroy it and recreate it under a new team. and also, remove one member from the old team Destroy(pannel.Item1); playersInTeam[pannel.Item2]--; } //create the new pannel CreatePannelForPlayer(data, newTeam); }
public void PlayerSetup(int _clientID, TeamSystem.Team _team, string _name) { client = FindObjectOfType <MultiClient>(); ClientID = _clientID; team = _team; PlayerName = _name; nameText.text = PlayerName; LocalOwned = ClientID == client._ClientID; TeamSystem teamSystem = FindObjectOfType <TeamSystem>(); if (teamSystem) { teamSystem.ChangeTeam(_team); } #if UNITY_EDITOR Debug.Log(String.Format("Player {0} Spawned in {1}", ClientID, UnityEngine.SceneManagement.SceneManager.GetActiveScene().name)); #endif }