Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var window = WindowFactory.CreateDefault(600, 600);
            var w      = 20;
            var h      = 20;
            var mc     = w * h * 0.15f;

            using var game = new MinesweeperGame(
                      window,
                      w,
                      h,
                      (uint)mc
                      );

            window.KeyPressed += (sender, eventArgs) =>
            {
                if (eventArgs.Code == Keyboard.Key.R)
                {
                    game.Reset();
                }
            };

            game.Initialize();
            game.Start();
        }
Exemplo n.º 2
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (MinesweeperGame game = new MinesweeperGame())
     {
         game.Run();
     }
 }
        public CustomGameMenuScreen(MinesweeperGame game)
            : base(game, "Custom Game:")
        {
            GameplayScreen screen = Game.GameplayScreen;
            tempHeight = screen.Height;
            tempWidth = screen.Width;
            tempMines = screen.Mines;
            screen = null;

            heightMI = new MenuItem("Height");
            heightMI.backed = false;
            Add(0, heightMI);
            widthMI = new MenuItem("Width");
            widthMI.backed = false;
            Add(1, widthMI);
            minesMI = new MenuItem("Mines");
            minesMI.backed = false;
            Add(2, minesMI);
            ok = new MenuItem("OK");
            ok.Clicked += () => NewGame(tempHeight, tempWidth, tempMines);
            Add(4, ok);
            back = new MenuItem("Back");
            back.Clicked += new ItemClick(Back);
            Add(5, back);
        }
Exemplo n.º 4
0
        public static void Move(MinesweeperGame game, int row, int col)
        {
            var result = game.Move(row, col);

            if (result == GameEnding.Won)
            {
                game.Ranking();
                Console.WriteLine("\nBRAVOOOS! Otvri " + PointsForWinningGame + " kletki bez kapka kryv.");
                game.PrintBoardWithBombs();
                Console.WriteLine("Daj si imeto, batka: ");

                game.TryAddingPlayerToChampions(Console.ReadLine(), game.Points);

                game.Ranking();

                game.Restart();
            }

            if (result == GameEnding.BombHit)
            {
                game.PrintBoardWithBombs();
                Console.Write("\nHrrrrrr! Umria gerojski s {0} to4ki. " + "Daj si niknejm: ", game.Points);
                game.TryAddingPlayerToChampions(Console.ReadLine(), game.Points);

                game.Ranking();

                game.Restart();
            }
        }
Exemplo n.º 5
0
        public static void Move(MinesweeperGame game, int row, int col)
        {
            var result = game.Move(row, col);
            if (result == GameEnding.Won)
            {
                game.Ranking();
                Console.WriteLine("\nBRAVOOOS! Otvri " + PointsForWinningGame + " kletki bez kapka kryv.");
                game.PrintBoardWithBombs();
                Console.WriteLine("Daj si imeto, batka: ");

                game.TryAddingPlayerToChampions(Console.ReadLine(), game.Points);

                game.Ranking();

                game.Restart();
            }

            if (result == GameEnding.BombHit)
            {
                game.PrintBoardWithBombs();
                Console.Write("\nHrrrrrr! Umria gerojski s {0} to4ki. " + "Daj si niknejm: ", game.Points);
                game.TryAddingPlayerToChampions(Console.ReadLine(), game.Points);

                game.Ranking();

                game.Restart();
            }

        }
Exemplo n.º 6
0
        //general setup whenever a new game is started
        private void SetUpGame()
        {
            //time setup
            timePassedInSeconds = 0;
            TimeLabel.Text      = "000";
            GameTimer.Interval  = (1000);   //set the timer to count passed time in seconds
            GameTimer.Enabled   = false;

            //gamefield setup
            GameStatusLabel.Visible = false;
            GameField.Controls.Clear();
            GameField.Enabled = true;
            paused            = false;

            //resize controls to their base size
            GameStatusLabel.Size = new System.Drawing.Size(247, 89);
            MenuPanel.Size       = new System.Drawing.Size(320, 66);
            GameField.Size       = new System.Drawing.Size(320, 335);
            ClientSize           = new System.Drawing.Size(346, 470);
            AutoScaleDimensions  = new System.Drawing.SizeF(6F, 13F);

            //minesweeper setup
            game = new MinesweeperGame(GameField, SetDifficulty());
            game.MineCounterChanged += new EventHandler <GameEvent>(MineCounterChange);
            game.GameStatusChange   += new EventHandler <GameEvent>(GameStatusChanged);
            MineLabel.Text           = game.Mines.ToString();
        }
Exemplo n.º 7
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (MinesweeperGame game = new MinesweeperGame())
     {
         game.Run();
     }
 }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            MinesweeperGame game = new MinesweeperGame(10, 10, 15);

            game.Print();

            while (true)
            {
                Console.Write("> ");
                string[] commandArgs = Console.ReadLine().Split(" ");
                string   command     = commandArgs[0].ToLower().Trim();
                if (command == "open")
                {
                    int  x    = int.Parse(commandArgs[1]) - 1;
                    int  y    = int.Parse(commandArgs[2]) - 1;
                    Tile tile = game.GetTile(x, y);
                    if (tile.IsFlagged)
                    {
                        Console.Write("You have flagged this tile as a potential bomb. Are you sure you want to open this (y/n) ");
                        bool open = Console.ReadLine().ToLower().Trim() == "y";
                        if (open)
                        {
                            game.Open(x, y, out bool wasBombTile);
                            if (wasBombTile)
                            {
                                Console.WriteLine("Game over, you hit a bomb!");
                                game.Print();
                                break;
                            }
                            else
                            {
                                game.Print();
                            }
                        }
                    }
                    else
                    {
                        game.Open(x, y, out bool wasBombTile);
                        if (wasBombTile)
                        {
                            Console.WriteLine("Game over, you hit a bomb!");
                            game.Print();
                            break;
                        }
                        else
                        {
                            game.Print();
                        }
                    }
                }
                else if (command == "flag")
                {
                    int x = int.Parse(commandArgs[1]) - 1;
                    int y = int.Parse(commandArgs[2]) - 1;
                    game.Flag(x, y);
                    game.Print();
                }
            }
        }
Exemplo n.º 9
0
        public GameplayScreen(MinesweeperGame game)
        {
            this.Game = game;
            TransitionOnTime = TimeSpan.FromSeconds(0.0);
            TransitionOffTime = TimeSpan.FromSeconds(0.0);

            SetGame(9, 9, 10);
        }
Exemplo n.º 10
0
        //**********************************************************
        //** ctor:
        //**********************************************************

        public MinesweeperRenderer(MinesweeperGame minesweeperGame, RenderTarget renderTarget)
        {
            _minesweeperGame            = minesweeperGame;
            _renderTarget               = renderTarget;
            _mineShape.OutlineThickness = -2;
            _mineShape.OutlineColor     = Color.Black;
            _text.Font = Fonts.Roboto;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CmdShowScores"/> class.
        /// </summary>
        /// <param name="game">The <see cref="MinesweeperGame"/> object on which the action will be invoked.</param>
        public CmdShowScores(MinesweeperGame game)
        {
            if (game == null)
            {
                throw new ArgumentNullException("game");
            }

            this.game = game;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CmdFlagCell"/> class.
        /// </summary>
        /// <param name="game">The <see cref="MinesweeperGame"/> object on which the action will be invoked.</param>
        /// <param name="targetCell">The position of the cell on which the action will be invoked.</param>
        public CmdFlagCell(MinesweeperGame game, CellPos targetCell)
        {
            if (game == null)
            {
                throw new ArgumentNullException("game");
            }

            this.game       = game;
            this.targetCell = targetCell;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CmdOpenCell"/> class.
        /// </summary>
        /// <param name="game">The <see cref="MinesweeperGame"/> object on which the action will be invoked.</param>
        /// <param name="cellToOpen">The position of the cell on which the action will be invoked.</param>
        public CmdOpenCell(MinesweeperGame game, CellPos cellToOpen)
        {
            if (game == null)
            {
                throw new ArgumentNullException("game");
            }

            this.game       = game;
            this.cellToOpen = cellToOpen;
        }
Exemplo n.º 14
0
        private static void Main()
        {
            var    game = new MinesweeperGame(GameRows, GameCows, PointsForWinningGame);
            int    row = 0, col = 0;
            string command = string.Empty;

            Console.WriteLine(
                "Hajde da igraem na “Mini4KI”. Probvaj si kasmeta da otkriesh poleteta bez mini4ki."
                + " Komanda 'top' pokazva klasiraneto, 'restart' po4va nova igra, 'exit' izliza i hajde 4ao!");

            game.PrintBoard();
            do
            {
                Console.Write("Command: ");
                command = Console.ReadLine().Trim();
                Console.WriteLine(command);
                if (command.Length >= 3)
                {
                    if (int.TryParse(command[0].ToString(), out row) && int.TryParse(command[2].ToString(), out col) &&
                        row < 5 && col < 10)
                    {
                        command = "turn";
                    }
                }

                switch (command)
                {
                case "top":
                    game.Ranking();
                    break;

                case "restart":
                    game.Restart();
                    break;

                case "exit":
                    Console.WriteLine("4a0, 4a0, 4a0!");
                    break;

                case "turn":
                    Move(game, row, col);
                    break;

                default:
                    Console.WriteLine("\nGreshka! nevalidna Komanda\n");
                    break;
                }
            }while (command != "exit");
            Console.WriteLine("Made in Bulgaria - Uauahahahahaha!");
            Console.WriteLine("AREEEEEEeeeeeee.");
            Console.Read();
        }
Exemplo n.º 15
0
        private static void Main()
        {
            var game = new MinesweeperGame(GameRows, GameCows, PointsForWinningGame);
            int row = 0, col = 0;
            string command = string.Empty;

            Console.WriteLine(
                "Hajde da igraem na “Mini4KI”. Probvaj si kasmeta da otkriesh poleteta bez mini4ki."
                + " Komanda 'top' pokazva klasiraneto, 'restart' po4va nova igra, 'exit' izliza i hajde 4ao!");

            game.PrintBoard();
            do
            {
                Console.Write("Command: ");
                command = Console.ReadLine().Trim();
                Console.WriteLine(command);
                if (command.Length >= 3)
                {
                    if (int.TryParse(command[0].ToString(), out row) && int.TryParse(command[2].ToString(), out col)
                        && row < 5 && col < 10)
                    {
                        command = "turn";
                    }
                }

                switch (command)
                {
                    case "top":
                        game.Ranking();
                        break;
                    case "restart":
                        game.Restart();
                        break;
                    case "exit":
                        Console.WriteLine("4a0, 4a0, 4a0!");
                        break;
                    case "turn":
                        Move(game, row, col);
                        break;
                    default:
                        Console.WriteLine("\nGreshka! nevalidna Komanda\n");
                        break;
                }

            }
            while (command != "exit");
            Console.WriteLine("Made in Bulgaria - Uauahahahahaha!");
            Console.WriteLine("AREEEEEEeeeeeee.");
            Console.Read();
        }
Exemplo n.º 16
0
        public OptionsMenuScreen(MinesweeperGame game)
            : base(game, "Options:")
        {
            oldOptions = new Options(Game.options.FlagWithPlay, Game.options.UseTouch, Game.options.SelectedSkin);

            flagButton = new MenuItem("Flag tiles with Play button", true, true, true);
            flagButton.Clicked += () => Game.options.FlagWithPlay = !Game.options.FlagWithPlay;
            Add(0, flagButton);
            useTouchMI = new MenuItem("Touch control off", false, false, true);
            useTouchMI.Clicked += () => Game.options.UseTouch = !Game.options.UseTouch;
            Add(1, useTouchMI);
            changeSkin = new MenuItem("Change Skin");
            changeSkin.Clicked += () => ScreenManager.AddScreen(new SkinMenuScreen(Game));
            Add(2, changeSkin);
            back = new MenuItem("Back");
            back.Clicked += new ItemClick(Back);
            Add(5, back);
        }
Exemplo n.º 17
0
 public MainMenuScreen(MinesweeperGame game, bool resumable)
     : base(game)
 {
     resume = new MenuItem("Resume", resumable);
     resume.Clicked += new ItemClick(Back);
     Add(0, resume);
     newGame = new MenuItem("New Game");
     newGame.Clicked += () => ScreenManager.AddScreen(new NewGameMenuScreen(Game));
     Add(1, newGame);
     music = new MenuItem("Music");
     music.Clicked += new ItemClick(Guide.Show);
     Add(2, music);
     bestTimes = new MenuItem("Best Times");
     bestTimes.Clicked += () => ScreenManager.AddScreen(new BestTimesMenuScreen(Game));
     Add(3, bestTimes);
     options = new MenuItem("Options");
     options.Clicked += () => ScreenManager.AddScreen(new OptionsMenuScreen(Game));
     Add(4, options);
     exit = new MenuItem("Exit");
     exit.Clicked += new ItemClick(Game.Exit);
     Add(5, exit);
 }
Exemplo n.º 18
0
        public SkinMenuScreen(MinesweeperGame game)
            : base(game, "Skin:")
        {
            skinNames = Game.skins.Keys.ToArray();
            for (int i = 0; i < skinNames.Length; i++)
            {
                if (skinNames[i] == Game.options.SelectedSkin)
                {
                    tempSelectedSkin = i;
                    break;
                }
            }

            skinMI = new MenuItem(skinNames[tempSelectedSkin]);
            Add(0, skinMI);
            change = new MenuItem("Change");
            change.Clicked += () => Game.options.SelectedSkin = skinNames[tempSelectedSkin];
            Add(4, change);
            back = new MenuItem("Back");
            back.Clicked += new ItemClick(Back);
            Add(5, back);
        }
Exemplo n.º 19
0
 public BestTimesMenuScreen(MinesweeperGame game)
     : base(game, "Best Times:")
 {
     bestBeginnerMI = new MenuItem("Beginner:", false, true);
     bestBeginnerMI.backed = false;
     Add(0, bestBeginnerMI);
     bestIntermediateMI = new MenuItem("Intermed.:", false, true);
     bestIntermediateMI.backed = false;
     Add(1, bestIntermediateMI);
     bestExpertMI = new MenuItem("Expert:", false, true);
     bestExpertMI.backed = false;
     Add(2, bestExpertMI);
     bestZuneMI = new MenuItem("Zune Fit:", false, true);
     bestZuneMI.backed = false;
     Add(3, bestZuneMI);
     resetMI = new MenuItem("Reset Times");
     resetMI.Clicked += new ItemClick(ResetClick);
     Add(4, resetMI);
     back = new MenuItem("Back");
     back.Clicked += new ItemClick(Back);
     Add(5, back);
 }
Exemplo n.º 20
0
 public NewGameMenuScreen(MinesweeperGame game)
     : base(game, "New Game:")
 {
     beginner = new MenuItem("Beginner");
     beginner.Clicked += () => NewGame(9, 9, 10);
     Add(0, beginner);
     intermediate = new MenuItem("Intermediate");
     intermediate.Clicked += () => NewGame(16, 16, 40);
     Add(1, intermediate);
     expert = new MenuItem("Expert");
     expert.Clicked += () => NewGame(24, 30, 99);
     Add(2, expert);
     zune = new MenuItem("Zune Fit");
     zune.Clicked += () => NewGame(15, 14, 30);
     Add(3, zune);
     custom = new MenuItem("Custom");
     custom.Clicked += () => ScreenManager.AddScreen(new CustomGameMenuScreen(Game));
     Add(4, custom);
     back = new MenuItem("Back");
     back.Clicked += new ItemClick(Back);
     Add(5, back);
 }
Exemplo n.º 21
0
 public MenuScreen(MinesweeperGame game)
 {
     this.Game = game;
 }
Exemplo n.º 22
0
 public MenuScreen(MinesweeperGame game, string title)
     : this(game)
 {
     this.title = title;
 }
Exemplo n.º 23
0
 static void Main()
 {
     using (var game = new MinesweeperGame())
         game.Run();
 }