Ejemplo n.º 1
0
 public void RemovePlayer(PlayerState state)
 {
     otherPlayersRWLock.EnterWriteLock();
     try
     {
         OtherPlayers.Remove(state);
     }
     catch (Exception) { throw; }
     finally { otherPlayersRWLock.ExitWriteLock(); }
 }
Ejemplo n.º 2
0
 public List<PlayerState> GetPlayerList(PlayerState exclude = null)
 {
     List<PlayerState> list = new List<PlayerState>(PlayerCount);
     if (Master != null && Master != exclude)
         list.Add(Master);
     otherPlayersRWLock.EnterReadLock();
     try
     {
         foreach (PlayerState s in OtherPlayers)
             if (s != exclude)
                 list.Add(s);
     }
     catch (Exception) { throw; }
     finally { otherPlayersRWLock.ExitReadLock(); }
     return list;
 }
Ejemplo n.º 3
0
 public bool AddPlayer(PlayerState state)
 {
     otherPlayersRWLock.EnterWriteLock();
     try
     {
         if (OtherPlayers.Count < _maxOtherPlayers)
         {
             OtherPlayers.Add(state);
             return true;
         }
         else { return false; }
     }
     catch (Exception) { throw; }
     finally { otherPlayersRWLock.ExitWriteLock(); }
 }
Ejemplo n.º 4
0
        public void ForEach(ForEachPlayerAction action, PlayerState skip = null)
        {
            if (Master != null && Master != skip)
                action(Master);

            otherPlayersRWLock.EnterReadLock();
            try
            {
                foreach (PlayerState s in OtherPlayers)
                    if (s != skip) action(s);
            }
            catch (Exception) { throw; }
            finally { otherPlayersRWLock.ExitReadLock(); }
        }
Ejemplo n.º 5
0
 public Room(PlayerState master = null)
 {
     if (master != null)
     {
         this._master = master;
         master.CurrentRoom = this;
     }
 }