public Flag(MatrixCoordinates topLeft) : base(topLeft) { this.Image = image; this.Color = Colors.Green; this.Speed = new MatrixCoordinates(-1, 0); }
public Mario(MatrixCoordinates topLeft, MarioImages image) : base(topLeft) { if ((int)image == 0) // Right turned Mario { this.Image = image1; } else // Left turned Mario { this.Image = image2; } }
public virtual void MovePlayerDown() { MatrixCoordinates downSpeed = new MatrixCoordinates(1, 0); MatrixCoordinates newTopLeft = ConsoleEngine.Player.TopLeft + downSpeed; if (IsInVisibleField(newTopLeft, Console.WindowWidth, Console.WindowHeight)) { if (CheckMovingDown(newTopLeft)) { ConsoleEngine.Player.Speed = downSpeed; ConsoleEngine.Player.Move(); } } }
public virtual void MovePlayerRight() { ConsoleEngine.Player.Profile = "right"; MatrixCoordinates rightSpeed = new MatrixCoordinates(0, 1); MatrixCoordinates newTopLeft = ConsoleEngine.Player.TopLeft + rightSpeed; if (IsInVisibleField(newTopLeft, Console.WindowWidth, Console.WindowHeight)) { if (CheckMovingRight(newTopLeft)) { ConsoleEngine.Player.Speed = rightSpeed; ConsoleEngine.Player.Move(); while (!HasSurfaceBelow(newTopLeft)) { this.MovePlayerDown(); newTopLeft.Row++; } } } }
protected GameObjects(MatrixCoordinates topLeft) { this.TopLeft = topLeft; this.Image = image; this.Color = color; }
protected MovingObject(MatrixCoordinates topLeft) : base(topLeft) { }
public virtual void MovePlayerUpRight() { ConsoleEngine.Player.Profile = "right"; MatrixCoordinates upRightSpeed = new MatrixCoordinates(-1, 1); MatrixCoordinates newTopLeft = ConsoleEngine.Player.TopLeft + upRightSpeed; if (IsInVisibleField(newTopLeft, Console.WindowWidth, Console.WindowHeight)) { if (CheckMovingUp(newTopLeft) && CheckMovingRight(newTopLeft)) { ConsoleEngine.Player.Speed = upRightSpeed; ConsoleEngine.Player.Move(); } } }
private bool IsInVisibleField(MatrixCoordinates newTopLeft, int width, int height) { return newTopLeft.Row >= 0 && newTopLeft.Row + ConsoleEngine.Player.Image.GetLength(0) < height && newTopLeft.Column >= 0 && newTopLeft.Column + ConsoleEngine.Player.Image.GetLength(1) < width; }
private bool HasSurfaceBelow(MatrixCoordinates newTopLeft) { if (newTopLeft.Row + 2 == Console.WindowHeight - 1) { throw new MarioException("Game over!", ConsoleEngine.Score); } if (ConsoleEngine.CurrentLevel.LevelGrid[newTopLeft.Row + 1, newTopLeft.Column] != default(char) && ConsoleEngine.CurrentLevel.LevelGrid[newTopLeft.Row + 1, newTopLeft.Column] != ' ') { return true; } return false; }
private bool CheckMovingUp(MatrixCoordinates newTopLeft) { char currentLevelGridSymbol = new char(); for (int col = newTopLeft.Column; col < newTopLeft.Column + 2; col++) { currentLevelGridSymbol = ConsoleEngine.CurrentLevel.LevelGrid[newTopLeft.Row, col]; if (currentLevelGridSymbol == '$') { ConsoleEngine.Score += 100; ConsoleEngine.CurrentLevel.LevelGrid[newTopLeft.Row, col] = ' '; continue; } if (ConsoleEngine.CurrentLevel is CastleLevel && currentLevelGridSymbol == '*') { throw new MarioException("You win!!!", ConsoleEngine.Score); } if (currentLevelGridSymbol != default(char) && currentLevelGridSymbol != ' ') { return false; } } return true; }