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

            if (client == null)
            {
                return;
            }

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

            if (Participants.Contains(client))
            {
                Console.WriteLine($"Removed {client.Id}|{client.Name} from the game of {CurrentGameType} as Participant");
                ClientHandler.BroadcastServerMessage($"{client.Name} has left the game.");
                Participants.Remove(client);
            }

            Spectators.Add(client);

            Console.WriteLine($"Spectator {client.Id}|{client.Name} added to the game of {CurrentGameType}");
            ClientHandler.BroadcastServerMessage($"{client.Name} is now spectating.");
        }
コード例 #2
0
ファイル: Room.cs プロジェクト: SeGaRFromHeLL/NeatDiggers
 public bool AddSpectator(string id)
 {
     if (Spectators.Contains(id))
     {
         return(false);
     }
     Spectators.Add(id);
     return(true);
 }
コード例 #3
0
ファイル: GamePacman.cs プロジェクト: clarson15/AIBracket
        public void AddSpectator(ISocket spec)
        {
            var ret = "";

            ret += (int)PacmanGame.EventType.BoardReset + " " + Game.GetBoardString() + "*";
            ret += (int)PacmanGame.EventType.PacmanLives + " " + Game.Pacman.Lives + "*";
            foreach (var g in Game.Ghosts)
            {
                ret += (int)PacmanGame.EventType.GhostUpdate + $" {g.GetPosition().ToString()} {g.IsDead} {g.IsVulnerable}*";
            }
            ret += (int)PacmanGame.EventType.PacmanUpdate + " " + Game.Pacman.GetPosition().ToString() + "*";
            ret += (int)PacmanGame.EventType.Score + " " + Game.Score;
            spec.WriteData(ret);
            if (spec.IsConnected)
            {
                Spectators.Add(spec);
            }
        }
コード例 #4
0
ファイル: Battle_Spectate.cs プロジェクト: zerodowned/Core
        public void AddSpectator(PlayerMobile pm, bool teleport)
        {
            if (pm == null || pm.Deleted)
            {
                return;
            }

            if (!CanSpectate(pm))
            {
                OnSpectateReject(pm);
                return;
            }

            Spectators.Add(pm);

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

            OnSpectatorAdded(pm);
        }