Ejemplo n.º 1
0
        public void ValidMove()
        {
            if (CheckIfOutOfBounds())
            {
                Console.WriteLine("Move would put turtle out of bounds, invalid move.");
            }
            else
            {
                int[] currentLocation = GameTurtle.Location.Split(',').Select(h => Int32.Parse(h)).ToArray();

                int[] newLocation = GameTurtle.GetNewLocation();

                GameTurtle.MoveTurtle();

                Board[currentLocation[0], currentLocation[1]].IsTurtle = false;
                Board[newLocation[0], newLocation[1]].IsTurtle         = true;

                if (Board[newLocation[0], newLocation[1]].IsMine)
                {
                    Console.WriteLine("The turtle stepped on a mine!");
                    Board[newLocation[0], newLocation[1]].IsMine = false;
                    GameTurtle.IsDead = true;
                }
                else if (Board[newLocation[0], newLocation[1]].IsExit)
                {
                    Console.WriteLine("The turtle made it to the exit!");
                    Board[newLocation[0], newLocation[1]].IsExit = false;
                    IsGameWon = true;
                }
                else
                {
                    Console.WriteLine("The turtle moved safely!");
                }
            }
        }
Ejemplo n.º 2
0
        public bool CheckIfOutOfBounds()
        {
            int[] Coordinates = GameTurtle.GetNewLocation();

            if (Coordinates[0] < 0 || Coordinates[1] < 0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
 public void RotateTurtle()
 {
     GameTurtle.ChangeDirection();
 }