Пример #1
0
        public void TryToStep(Direction direction)
        {
            RememberLast = false;
            BaseCell cellToMove = null;

            var hero = Player.GetPlayer;

            switch (direction)
            {
            case Direction.Up:
                cellToMove = this[hero.Coordinates.X, hero.Coordinates.Y - 1];
                break;

            case Direction.Right:
                cellToMove = this[hero.Coordinates.X + 1, hero.Coordinates.Y];
                break;

            case Direction.Down:
                cellToMove = this[hero.Coordinates.X, hero.Coordinates.Y + 1];
                break;

            case Direction.Left:
                cellToMove = this[hero.Coordinates.X - 1, hero.Coordinates.Y];
                break;
            }

            if (cellToMove?.TryToStep() ?? false)
            {
                hero.Coordinates = cellToMove.Coordinates;
            }

            if (Cells[Cells.FindIndex(n => n.Coordinates.X == hero.Coordinates.X & n.Coordinates.Y == hero.Coordinates.Y)].Skin == ExitCell.Skin())
            {
                LastExitX        = hero.Coordinates.X;
                LastExitY        = hero.Coordinates.Y;
                hero.Coordinates = Cells[0].Coordinates;
                GenerateNew      = true;
            }

            if (Cells[Cells.FindIndex(n => n.Coordinates.X == hero.Coordinates.X & n.Coordinates.Y == hero.Coordinates.Y)].Skin == LastMazeCell.Skin())
            {
                hero.Coordinates = Cells[0].Coordinates;
                RememberLast     = true;
            }
        }
Пример #2
0
 public void CheckSkin()
 {
     Assert.AreEqual(ExitCell.Skin(), skin);
 }