void RemovePlayer(PlayerFrame frame) { frame.Parent = null; orderedTeamA.Remove(frame); orderedTeamB.Remove(frame); playerFrames.Remove(frame.NetPlayer.Id); }
void AddPlayer(NetworkPlayer player) { PlayerFrame pFrame = new PlayerFrame(player, netPlayerComponent.OurNetPlayerId == player.Id, UDim2.Zero, new UDim2(1f, 0, 0, 30), Theme) { Parent = player.Team == Team.A ? teamAFrame : teamBFrame }; playerFrames.Add(player.Id, pFrame); if (player.Team == Team.A) { orderedTeamA.Add(pFrame); } if (player.Team == Team.B) { orderedTeamB.Add(pFrame); } }
void AlignAndSortLists() { orderedTeamA.Sort(CompareFrame); orderedTeamB.Sort(CompareFrame); for (int y = 0; y < orderedTeamA.Count; y++) { PlayerFrame frame = orderedTeamA[y]; frame.Position.Y.Offset = 60 + 30 * y; frame.SetAltColor(y % 2 == 0); } for (int y = 0; y < orderedTeamB.Count; y++) { PlayerFrame frame = orderedTeamB[y]; frame.Position.Y.Offset = 60 + 30 * y; frame.SetAltColor(y % 2 == 0); } }
private void ReadyPlayerFrame() { PlayerFrame playerFrame = null; PlayerFrame[] playerFrames = GameObject.FindObjectsOfType <PlayerFrame>(); foreach (PlayerFrame frame in playerFrames) { if (frame.IsMe == _isMe) { playerFrame = frame; break; } } if (playerFrame != null) { playerFrame.Ready(this); } }
public void Initialize(string name, string classCode, bool isMe, Game game) { if (_player == null) { _player = InstantiatePlayerClass(name, game, classCode); if (_player == null) { Debug.LogError("Could not instantiate player, probable cause is a mismatched class name."); return; } _isMe = isMe; _playerName = PlayerName; _game = game; _unitsOnField = new List <UnitScript>(); tag = _isMe ? "CurrentPlayer" : "EnemyPlayer"; _className = ((IPlayerClass)_player).ClassName; _classTier = ((IPlayerClass)_player).ClassTier; _cardContainer = GameObject.FindGameObjectWithTag("CardContainer"); _gameCanvas = GameObject.FindGameObjectWithTag("GameCanvas"); _deckObject = GameObject.FindGameObjectWithTag("Deck"); PlayerFrame[] playerFrames = GameObject.FindObjectsOfType <PlayerFrame>(); foreach (PlayerFrame playerFrame in playerFrames) { if (playerFrame.IsMe == _isMe) { _playerFrame = playerFrame; } } _cardsOnHand = new List <GameObject>(); ReadySpawnPoints(); ReadyEvents(); ReadyPlayerFrame(); } }
int CompareFrame(PlayerFrame a, PlayerFrame b) { return(b.NetPlayer.Score - a.NetPlayer.Score); }
// Start is called before the first frame update void Start() { controller = this.GetComponent <CharacterController>(); playerFrame = new PlayerFrame(); Debug.Log(" player onStart !"); }