コード例 #1
0
        /// <summary>
        /// Adds a participant
        /// </summary>
        public static void AddParticipant(Guid id)
        {
            var client = ClientHandler.GetById(id);

            if (client == null)
            {
                return;
            }

            if (Participants.Contains(client))
            {
                return;
            }

            if (Spectators.Contains(client))
            {
                Console.WriteLine($"Removed {client.Id}|{client.Name} from the game of {CurrentGameType} as Spectator");
                ClientHandler.BroadcastServerMessage($"{client.Name} is no longer spectating.");
                Spectators.Remove(client);
            }

            Participants.Add(client);

            Console.WriteLine($"Participant {client.Id}|{client.Name} added to the game of {CurrentGameType}");
            ClientHandler.BroadcastServerMessage($"{client.Name} has joined the game.");
        }
コード例 #2
0
ファイル: Battle_Spectate.cs プロジェクト: AllanNisbet/runuo
        public void RemoveSpectator(PlayerMobile pm, bool teleport)
        {
            if (!IsSpectator(pm))
            {
                return;
            }

            Spectators.Remove(pm);

            if (teleport)
            {
                var bounce = BounceInfo.GetValue(pm);

                if (bounce != null && !bounce.InternalOrZero)
                {
                    Teleport(pm, bounce, bounce);

                    BounceInfo.Remove(pm);
                }
                else
                {
                    Teleport(pm, Options.Locations.Eject, Options.Locations.Eject);
                }
            }

            OnSpectatorRemoved(pm);
        }
コード例 #3
0
ファイル: Battle_Spectate.cs プロジェクト: zerodowned/Core
        public void RemoveSpectator(PlayerMobile pm, bool teleport)
        {
            if (!IsSpectator(pm))
            {
                return;
            }

            Spectators.Remove(pm);

            if (teleport)
            {
                Teleport(pm, Options.Locations.Eject, Options.Locations.Eject.Map);
            }

            OnSpectatorRemoved(pm);
        }
コード例 #4
0
        /// <summary>
        /// Invokes the <see cref="UserDropping"/> event from derived classes.
        /// </summary>
        protected void OnDroppingUser(IUser user)
        {
            if (Players.Contains(user, DiscordComparers.UserComparer))
            {
                Players = Players.Remove(user, DiscordComparers.UserComparer);
            }
            else if (Spectators.Contains(user, DiscordComparers.UserComparer))
            {
                Spectators = Spectators.Remove(user, DiscordComparers.UserComparer);
            }
            else
            {
                throw new ArgumentException("The given user is not playing in or spectating this game.", nameof(user));
            }

            UserDropping?.Invoke(this, new UserDroppingEventArgs(user));
        }
コード例 #5
0
ファイル: Room.cs プロジェクト: SeGaRFromHeLL/NeatDiggers
 public bool Disconnect(string id)
 {
     if (!Spectators.Remove(id))
     {
         Player player = Players.Find(p => p.Id == id);
         if (player != null)
         {
             if (player.IsTurn)
             {
                 NextTurn();
             }
             if (Players.IndexOf(player) < PlayerTurn)
             {
                 PlayerTurn--;
             }
             Players.Remove(player);
             return(true);
         }
     }
     return(false);
 }