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); } }
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; } }
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; }
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); }
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)); }
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 ); } }
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; } }