Exemple #1
0
        private void HandleRemovePlayer(Event ev)
        {
            MatchRemovePlayerEvent evCasted = (MatchRemovePlayerEvent)ev;

            evCasted.Player.OnEvent -= HandlePlayerShot;
            foreach (Ship ship in evCasted.Player.Ships)
            {
                ship.OnEvent -= HandleShipMove;
                ship.OnEvent -= HandleShipDestroyed;
            }
        }
 /// <summary>
 /// Call when a player is to be removed from the match.
 /// </summary>
 /// <param name="plr"></param>
 public virtual bool RemovePlayer(Player plr)
 {
     if (players.Remove(plr))
     {
         MatchRemovePlayerEvent ev = new MatchRemovePlayerEvent(plr);
         AppendEvent(ev);
         if (OnPlayerRemove != null)
         {
             OnPlayerRemove(this, ev);
         }
         return(true);
     }
     return(false);
 }
 /// <summary>
 /// Call when a player is to be removed from the match.
 /// </summary>
 /// <param name="plr"></param>
 public virtual bool RemovePlayer(Player plr)
 {
     if (players.Remove(plr))
     {
         MatchRemovePlayerEvent ev = new MatchRemovePlayerEvent(plr);
         AppendEvent(ev);
         if (OnPlayerRemove != null)
         {
             OnPlayerRemove(this, ev);
         }
         return true;
     }
     return false;
 }