Exemplo n.º 1
0
        public static void Stop(Player player, bool Won)
        {
            if (Failed != null && Mines != null)
            {
                Failed.Clear();

                foreach (Vector3I m in Mines.Values)
                {
                    Vector3I removed;
                    Mines.TryRemove(m.ToString(), out removed);
                }
            }
            World world = WorldManager.FindWorldOrPrintMatches(player, "Minefield");

            WorldManager.RemoveWorld(world);
            WorldManager.SaveWorldList();
            Server.RequestGC();
            instance = null;
            if (Won)
            {
                Server.Players.Message("{0}&S Won the game of MineField!", player.ClassyName);
            }
            else
            {
                Server.Players.Message("{0}&S aborted the game of MineField", player.ClassyName);
            }
        }
Exemplo n.º 2
0
        private static void GameHandler(Player player, Command cmd)
        {
            string GameMode = cmd.Next();
            string Option   = cmd.Next();
            World  world    = player.World;

            /*if (world == WorldManager.MainWorld){
             *  player.Message("/Game cannot be used on the main world");
             *  return;
             * }*/

            if (GameMode.ToLower() == "zombie")
            {
                if (Option.ToLower() == "start")
                {
                    ZombieGame game = new ZombieGame(player.World);   //move to world
                    game.Start();
                    return;
                }
                else
                {
                    CdGame.PrintUsage(player);
                    return;
                }
            }
            if (GameMode.ToLower() == "minefield")
            {
                if (Option.ToLower() == "start")
                {
                    if (WorldManager.FindWorldExact("Minefield") != null)
                    {
                        player.Message("&WA game of Minefield is currently running and must first be stopped");
                        return;
                    }
                    MineField.GetInstance();
                    MineField.Start(player);
                    return;
                }
                else if (Option.ToLower() == "stop")
                {
                    if (WorldManager.FindWorldExact("Minefield") == null)
                    {
                        player.Message("&WA game of Minefield is currently not running");
                        return;
                    }
                    MineField.Stop(player, false);
                    return;
                }
                else
                {
                    CdGame.PrintUsage(player);
                    return;
                }
            }
            else
            {
                CdGame.PrintUsage(player);
                return;
            }
        }
Exemplo n.º 3
0
 public static MineField GetInstance()
 {
     if ( instance == null ) {
         instance = new MineField();
         Failed = new List<Player>();
         Mines = new ConcurrentDictionary<string, Vector3I>();
         Player.Moving += new EventHandler<PlayerMovingEventArgs>( PlayerMoving );
         Player.PlacingBlock += new EventHandler<PlayerPlacingBlockEventArgs>( PlayerPlacing );
         _rand = new Random();
         _stopped = false;
     }
     return instance;
 }
Exemplo n.º 4
0
 public static MineField GetInstance()
 {
     if (instance == null)
     {
         instance             = new MineField();
         Failed               = new List <Player>();
         Mines                = new ConcurrentDictionary <string, Vector3I>();
         Player.Moving       += new EventHandler <PlayerMovingEventArgs>(PlayerMoving);
         Player.PlacingBlock += new EventHandler <PlayerPlacingBlockEventArgs>(PlayerPlacing);
         _rand                = new Random();
         _stopped             = false;
     }
     return(instance);
 }
Exemplo n.º 5
0
 public void HitPlayer(World world, Player hitted, Player by)
 {
     if (by == null)
     {
         if (MineField.Failed != null && !MineField.Failed.Contains(hitted))
         {
             hitted.Kill(world, String.Format("{0}&S was torn to pieces and lost the game!", hitted.ClassyName));
             if (MineField.PlayerBlowUpCheck(hitted))
             {
                 hitted.Message("&WYou lost the game! You are now unable to win.");
             }
             return;
         }
         else
         {
             return;
         }
     }
     hitted.Kill(world, String.Format("{0}&S was torn to pieces by {1}", hitted.ClassyName, hitted.ClassyName == by.ClassyName?"theirself":by.ClassyName));
 }
Exemplo n.º 6
0
        public static void Stop( Player player, bool Won )
        {
            if ( Failed != null && Mines != null ) {
                Failed.Clear();

                foreach ( Vector3I m in Mines.Values ) {
                    Vector3I removed;
                    Mines.TryRemove( m.ToString(), out removed );
                }
            }
            World world = WorldManager.FindWorldOrPrintMatches( player, "Minefield" );
            WorldManager.RemoveWorld( world );
            WorldManager.SaveWorldList();
            Server.RequestGC();
            instance = null;
            if ( Won ) {
                Server.Players.Message( "{0}&S Won the game of MineField!", player.ClassyName );
            } else {
                Server.Players.Message( "{0}&S aborted the game of MineField", player.ClassyName );
            }
        }
Exemplo n.º 7
0
        private static void GameHandler(Player player, Command cmd)
        {
            string GameMode = cmd.Next();
            string Option   = cmd.Next();
            World  world    = player.World;

            if (PropHunt.StartMode != Game.StartMode.None)
            {
                player.Message("&cThere is already a game running!");
                return;
            }

            if (GameMode == null)
            {
                CdGame.PrintUsage(player);
                return;
            }
            if (GameMode.ToLower() == "zombie")
            {
                if (Option.ToLower() == "start")
                {
                    ZombieSurvival game = new ZombieSurvival(player.World); //move to world
                    game.Start();
                    return;
                }
                else if (Option.ToLower() == "stop")
                {
                    ZombieSurvival.Stop(player);
                    Server.Message("{0} &cended the game of zombie survival in the world {1}", player.ClassyName,
                                   world.ClassyName);
                    return;
                }
            }
            if (GameMode.ToLower() == "minefield")
            {
                if (Option == null)
                {
                    player.Message("&cYou must choose an option! &astart/stop");
                    return;
                }
                else if (Option.ToLower() == "start")
                {
                    if (WorldManager.FindWorldExact("Minefield") != null)
                    {
                        player.Message("&WA game of Minefield is currently running and must first be stopped");
                        return;
                    }
                    else
                    {
                        MineField.GetInstance();
                        MineField.Start(player);
                        return;
                    }
                }
                else if (Option.ToLower() == "stop")
                {
                    if (WorldManager.FindWorldExact("Minefield") == null)
                    {
                        player.Message("&WA game of Minefield is currently not running");
                        return;
                    }
                    MineField.Stop(player, false);
                    return;
                }
            }
            if (GameMode.ToLower() == "prophunt")
            {
                if (Option == null)
                {
                    player.Message("&cYou must choose an option! &astart/stop");
                    return;
                }
                if (Option.ToLower() == "start")
                {
                    PropHunt game = new PropHunt(player.World); //move to world
                    game.Start();
                }
            }
            else
            {
                CdGame.PrintUsage(player);
                return;
            }
        }