Ejemplo n.º 1
0
 public AI(Game.Difficulty diff, Algorith algo)
 {
     _algo  = algo;
     _depth = _algo == Algorith.AlphaBeta
         ? (int)diff * 3
         : (int)diff * 2;
 }
Ejemplo n.º 2
0
        static void checkFishShape(Game.Difficulty diff)
        {
            IBoardShapes boardShape = new BoardFish();

            int[][] fields = boardShape.GetField(diff);
            assert(fields[0].Equals(fields[1]) == false);
        }
Ejemplo n.º 3
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch ((sender as ComboBox).SelectedIndex)
            {
            case 0:
                difficulty = Game.Difficulty.Easy;

                tbHeigth.Enabled  = false;
                tbWidth.Enabled   = false;
                tbNOMines.Enabled = false;
                tbCellH.Enabled   = false;
                tbCellW.Enabled   = false;
                break;

            case 1:
                difficulty = Game.Difficulty.Medium;

                tbHeigth.Enabled  = false;
                tbWidth.Enabled   = false;
                tbNOMines.Enabled = false;
                tbCellH.Enabled   = false;
                tbCellW.Enabled   = false;
                break;

            case 2:
                difficulty = Game.Difficulty.Hard;

                tbHeigth.Enabled  = false;
                tbWidth.Enabled   = false;
                tbNOMines.Enabled = false;
                tbCellH.Enabled   = false;
                tbCellW.Enabled   = false;
                break;

            case 3:
                difficulty = Game.Difficulty.Custom;

                tbHeigth.Enabled  = true;
                tbWidth.Enabled   = true;
                tbNOMines.Enabled = true;
                tbCellH.Enabled   = true;
                tbCellW.Enabled   = true;
                break;

            default:
                difficulty = Game.Difficulty.Medium;

                tbHeigth.Enabled  = false;
                tbWidth.Enabled   = false;
                tbNOMines.Enabled = false;
                tbCellH.Enabled   = false;
                tbCellW.Enabled   = false;
                break;
            }
        }
Ejemplo n.º 4
0
        void startNewGame(Game.Difficulty difficulty, int width, int height)
        {
            time = 0;
            toolStripContainer1.ContentPanel.Controls.Clear( );
            Game game = new Game(width, height, difficulty);

            toolStripContainer1.ContentPanel.Controls.Add(game);
            game.Dock            = DockStyle.Fill;
            game.t.Tick         += new EventHandler(t_Tick);
            toolStripLabel1.Text = game.mineCount( ).ToString( ) + " mines.";
        }
Ejemplo n.º 5
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Game.Difficulty difficulty = (Game.Difficulty)value;

            switch (difficulty)
            {
            case Game.Difficulty.Easy:
                return("Players will have 15 seconds and 5 (3 in ffa) trials to guess");

            case Game.Difficulty.Medium:
                return("Players will have 10 seconds and 5 (3 in ffa) trials to guess");

            case Game.Difficulty.Hard:
                return("Players will have 5 seconds and 5 (3 in ffa) trials to guess");

            default:
                return("");
            }
        }
Ejemplo n.º 6
0
        static void checkDiamondShape(Game.Difficulty diff)
        {
            IBoardShapes boardShape = new BoardDiamond();

            int[][] fields  = boardShape.GetField(diff);
            int     notnull = 0;

            for (int y = 0; y < fields.GetLength(0); y++)
            {
                for (int x = 0; x < fields[y].GetLength(0); x++)
                {
                    if (fields[y][x] == 1)
                    {
                        notnull++;
                    }
                }
            }
            assert((fields.Length * fields[0].Length) + 1 == notnull * 2);
            assert(fields[0][(fields.Length / 2)] == 1 && fields[fields.Length - 1][(fields.Length / 2)] == 1 &&
                   fields[(fields.Length / 2)][0] == 1 && fields[(fields.Length / 2)][fields.Length - 1] == 1);
        }
Ejemplo n.º 7
0
        public Square(int xPos, int yPos, Game.Difficulty d)
        {
            if (Program.random((int)d) == 0)
            {
                isMine = true;
            }

            this.FlatStyle  = FlatStyle.Popup;
            this.Appearance = Appearance.Button;
            this.AutoCheck  = false;
            this.BackColor  = Color.Green;

            this.Width  = SIZE;
            this.Height = SIZE;
            this.Left   = xPos * SIZE;
            this.Top    = yPos * SIZE;
            this.Font   = new System.Drawing.Font(new System.Drawing.FontFamily(System.Drawing.Text.GenericFontFamilies.SansSerif), 10, System.Drawing.FontStyle.Bold);

            _X = xPos;
            _Y = yPos;



            ContextMenuStrip = new ContextMenuStrip( );

            EventHandler ehDig = new EventHandler(Menu_Dig);

            ContextMenuStrip.Items.Add(new ToolStripMenuItem("Dig", Minesweeper.Properties.Resources.down, ehDig));


            EventHandler ehFlag = new EventHandler(Menu_Flag);

            ContextMenuStrip.Items.Add(new ToolStripMenuItem("Flag", Minesweeper.Properties.Resources.flag, ehFlag));

            EventHandler ehTrigger = new EventHandler(Menu_TriggerSurrounding);

            ContextMenuStrip.Items.Add(new ToolStripMenuItem("Trigger Surroundings", Minesweeper.Properties.Resources.redled, ehTrigger));

            ContextMenuStrip.Items[2].Enabled = false;
        }
Ejemplo n.º 8
0
 void startNewGame(Game.Difficulty difficulty)
 {
     startNewGame(difficulty, 20, 15);
 }
Ejemplo n.º 9
0
        public static void CreateNewGameMenu()
        {
            MenuElement       root = new MenuElement();
            MenuSpriteElement bg   = new MenuSpriteElement("GUI/newgame_menu.jpg", new Rectangle(0, 0, GameManager.Width, GameManager.Height));

            root.AddChild(bg);

            {
                Rectangle exitRect = new Rectangle(GameManager.Width - 152, 1, 151, 71);
                MenuButtonElement exitButton = new MenuButtonElement(exitRect, delegate()
                {
                    CreateMainMenu();
                });
                exitButton.AddChild(new MenuSpriteElement("GUI/button_bg", exitRect, "BACK"));
                bg.AddChild(exitButton);
            }

            Rectangle musicRect = new Rectangle(GameManager.Width - 500, 1, 151, 71);
            MenuButtonElement musicButton = new MenuButtonElement(musicRect, delegate()
            {
                if (!music)
                {
                    music     = true;
                    musicText = "MUSIC: ON";
                }
                else
                {
                    music     = false;
                    musicText = "MUSIC: OFF";
                }
                musicSpriteElement.Text = musicText;
            });

            musicSpriteElement = new MenuSpriteElement("GUI/button_bg", musicRect, musicText);
            musicButton.AddChild(musicSpriteElement);
            bg.AddChild(musicButton);

            Rectangle vibRect = new Rectangle(GameManager.Width - 345, 1, 190, 71);
            MenuButtonElement vibButton = new MenuButtonElement(vibRect, delegate()
            {
                if (!vibration)
                {
                    vibration = true;
                    vibText   = "VIBRATION: ON";
                }
                else
                {
                    vibration = false;
                    vibText   = "VIBRATION: OFF";
                }
                vibrationSpriteElement.Text = vibText;
            });

            vibrationSpriteElement = new MenuSpriteElement("GUI/button_bg", vibRect, vibText);
            vibButton.AddChild(vibrationSpriteElement);
            bg.AddChild(vibButton);



            {
                DifficultySelector selector = new DifficultySelector();
                bg.AddChild(selector);

                int baseX = Convert.ToInt32(0.279 * GameManager.Width);
                int baseY = Convert.ToInt32(0.359 * GameManager.Height);
                int YDiff = Convert.ToInt32(0.085 * GameManager.Height);
                {
                    Rectangle easyRect = new Rectangle(baseX,
                                                       baseY + YDiff * 0,
                                                       Convert.ToInt32(0.078 * GameManager.Width),
                                                       Convert.ToInt32(0.077 * GameManager.Height));
                    MenuButtonElement easyButton = new MenuButtonElement(easyRect, delegate()
                    {
                        selectedDifficulty = Game.Difficulty.EASY;
                    });
                    easyButton.AddChild(new MenuSpriteElement(null, easyRect, "EASY", 1.5f));
                    selector.AddElementForDifficulty(Game.Difficulty.EASY, easyButton);
                }

                {
                    Rectangle easyRect = new Rectangle(baseX, baseY + YDiff * 1, Convert.ToInt32(0.078 * GameManager.Width), Convert.ToInt32(0.077 * GameManager.Height));
                    MenuButtonElement easyButton = new MenuButtonElement(easyRect, delegate()
                    {
                        selectedDifficulty = Game.Difficulty.NORMAL;
                    });
                    easyButton.AddChild(new MenuSpriteElement(null, easyRect, "NORMAL", 1.5f));
                    selector.AddElementForDifficulty(Game.Difficulty.NORMAL, easyButton);
                }

                {
                    Rectangle easyRect = new Rectangle(baseX, baseY + YDiff * 2, Convert.ToInt32(0.078 * GameManager.Width), Convert.ToInt32(0.077 * GameManager.Height));
                    MenuButtonElement easyButton = new MenuButtonElement(easyRect, delegate()
                    {
                        selectedDifficulty = Game.Difficulty.HARD;
                    });
                    easyButton.AddChild(new MenuSpriteElement(null, easyRect, "HARD", 1.5f));
                    selector.AddElementForDifficulty(Game.Difficulty.HARD, easyButton);
                }
            }

            {
                GameModeSelector selector = new GameModeSelector();
                bg.AddChild(selector);

                int baseX = Convert.ToInt32(0.1 * GameManager.Width);
                int baseY = Convert.ToInt32(0.388 * GameManager.Height);
                int YDiff = Convert.ToInt32(0.085 * GameManager.Height);
                {
                    Rectangle easyRect = new Rectangle(baseX, baseY + YDiff * 0, Convert.ToInt32(0.078 * GameManager.Width), Convert.ToInt32(0.077 * GameManager.Height));
                    MenuButtonElement easyButton = new MenuButtonElement(easyRect, delegate()
                    {
                        selectedGameMode = Game.GameMode.NORMAL;
                    });
                    easyButton.AddChild(new MenuSpriteElement(null, easyRect, "NORMAL", 1.5f));
                    selector.AddElementForDifficulty(Game.GameMode.NORMAL, easyButton);
                }

                {
                    Rectangle easyRect = new Rectangle(baseX, baseY + YDiff * 1, Convert.ToInt32(0.078 * GameManager.Width), Convert.ToInt32(0.077 * GameManager.Height));
                    MenuButtonElement easyButton = new MenuButtonElement(easyRect, delegate()
                    {
                        selectedGameMode = Game.GameMode.ENDLESS;
                    });
                    easyButton.AddChild(new MenuSpriteElement(null, easyRect, "ENDLESS", 1.5f));
                    selector.AddElementForDifficulty(Game.GameMode.ENDLESS, easyButton);
                }

                {
                    Rectangle easyRect = new Rectangle(baseX, baseY + YDiff * 2, Convert.ToInt32(0.078 * GameManager.Width), Convert.ToInt32(0.077 * GameManager.Height));
                    MenuButtonElement easyButton = new MenuButtonElement(easyRect, delegate()
                    {
                        selectedGameMode = Game.GameMode.TIME;
                    });
                    easyButton.AddChild(new MenuSpriteElement(null, easyRect, "TIME", 1.5f));
                    selector.AddElementForDifficulty(Game.GameMode.TIME, easyButton);
                }
            }

            {
                Rectangle playRect = new Rectangle(Convert.ToInt32(0.78125 * GameManager.Width), Convert.ToInt32(0.444 * GameManager.Height), Convert.ToInt32(0.114 * GameManager.Width), Convert.ToInt32(0.0583 * GameManager.Height));
                MenuButtonElement playButton = new MenuButtonElement(playRect,
                                                                     delegate()
                {
                    //GameManager.Instance.SwitchScene(new Prototype());
                    GameManager.Instance.SwitchScene(new Game.GameModel(imageDatabase, selectedGameMode, selectedDifficulty, music, vibration));
                }
                                                                     );
                bg.AddChild(playButton);
                playButton.AddChild(new MenuSpriteElement("GUI/button_play.png", playRect));
            }

            GameManager.Instance.SwitchScene(new Menu(root));
        }
Ejemplo n.º 10
0
 public void AddElementForDifficulty(Game.Difficulty diff, MenuElement elem)
 {
     elements[diff] = elem;
     AddChild(elem);
 }