Esempio n. 1
0
 public void AddPlayer(BattleCarsPlayerNet _player)
 {
     if (!players.ContainsKey(_player.playerId))
     {
         players.Add(_player.playerId, _player);
     }
 }
Esempio n. 2
0
        private IEnumerator AssignPlayerToLobbySlotDelayed(BattleCarsPlayerNet _player, bool _left, int _slotId)
        {
            while (lobby == null)
            {
                yield return(null);

                lobby = FindObjectOfType <Lobby>();
            }

            lobby.AssignPlayerToSlot(_player, _left, _slotId);
        }
Esempio n. 3
0
        /// <summary>
        /// Finds next available ID and assigns it.
        /// </summary>
        /// <param name="_playerObj"></param>
        protected void AssignPlayerId(GameObject _playerObj)
        {
            byte        id        = 0;
            List <byte> playerIds = players.Keys.OrderBy(x => x).ToList(); //generate sorted list

            foreach (byte key in playerIds)
            {
                //if this id is not free, go to next
                if (id == key)
                {
                    id++;
                }
            }

            //get component and assign
            BattleCarsPlayerNet player = _playerObj.GetComponent <BattleCarsPlayerNet>();

            player.playerId = id;

            players.Add(id, player);
        }