示例#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
 public bool AddSpectator(string id)
 {
     if (Spectators.Contains(id))
     {
         return(false);
     }
     Spectators.Add(id);
     return(true);
 }
示例#3
0
        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
        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);
        }