示例#1
0
        public void GameInstantiatesWithPlayerStartingAt01()
        {
            var gameToTest = GenerateGame.GenerateAGame(8, 8, 5, 5, 0, 1);

            Assert.AreEqual(0, gameToTest.Player.CurrentPosition.Horizontal);
            Assert.AreEqual(1, gameToTest.Player.CurrentPosition.Vertical);
        }
示例#2
0
    void Start()
    {
        instance  = this;
        boardSize = 8;
        rows      = Mathf.RoundToInt((float)boardSize / 3);

        createBoard(8);
        pieces = GlobalVariables.instance.getPiece();
    }
示例#3
0
        public void GameContinues()
        {
            var gameToTest = GenerateGame.GenerateAGame(8, 8, 5, 3, 0, 1);
            var dummyEvent = new PlayerEvents
            {
                GameOver = false
            };

            gameToTest.HandlePlayerEvent(this, dummyEvent);

            Assert.AreEqual(false, gameToTest.GameOver);
        }
示例#4
0
        public void GameStopsOnGameOver()
        {
            var gameToTest = GenerateGame.GenerateAGame(8, 8, 5, 3, 0, 1);
            var dummyEvent = new PlayerEvents
            {
                GameOver = true
            };

            gameToTest.HandlePlayerEvent(this, dummyEvent);

            Assert.AreEqual(true, gameToTest.GameOver);
        }
示例#5
0
 //create singleton of class
 void Awake()
 {
     if (GenerateGameSingle == null)
     {
         //DontDestroyOnLoad(gameObject);
         GenerateGameSingle = this;
     }
     else if (GenerateGameSingle != this)
     {
         Destroy(gameObject);
     }
 }
示例#6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Minesweeper");
            Console.WriteLine("Use the arrow keys only to navigate and esc to quit");
            //Create the Game
            var theGame = GenerateGame.GenerateAGame(8, 8, 50, 3, 0, 1);

            Console.WriteLine("You are on " + theGame.Board.HorizontalArray.Length.ToString() + "x" +
                              theGame.Board.VerticalAxis.ToString() + " board starting from " +
                              theGame.Board.HorizontalArray[theGame.Player.CurrentPosition.Horizontal] +
                              theGame.Player.CurrentPosition.Vertical.ToString());

            Console.WriteLine("Good luck!");
            Console.WriteLine("Oh and there are " + theGame.Board.NumberOfMines.ToString() + " mines");


            while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
            {
                var input = Console.ReadKey();


                //Check for Game Over
                if (theGame.GameOver)
                {
                    Console.WriteLine("Game Over");
                    break;
                }

                if (input.Key == ConsoleKey.UpArrow || input.Key == ConsoleKey.DownArrow || input.Key == ConsoleKey.LeftArrow || input.Key == ConsoleKey.RightArrow)
                {
                    theGame.Player.ProcessKeyStroke(input.Key.ToString());
                }
                else if (input.Key == ConsoleKey.Escape)
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Invalid key");
                }
            }
        }
示例#7
0
        public void GameInstantiatesWithAPlayer3Lives()
        {
            var gameToTest = GenerateGame.GenerateAGame(8, 8, 5, 3, 0, 1);

            Assert.AreEqual(3, gameToTest.Player.NoOfLives);
        }
示例#8
0
        public void GameInstantiatesWith30Mines()
        {
            var gameToTest = GenerateGame.GenerateAGame(8, 8, 30, 5, 0, 1);

            Assert.AreEqual(30, gameToTest.Board.NumberOfMines);
        }
示例#9
0
 // Use this for initialization
 void Awake()
 {
     instance = this;
 }