Exemple #1
0
 public Hero(string name, int hitPoints, Position pos, Weapon weapon)
 {
     Name = name;
     HitPoints = hitPoints;
     Pos = pos;
     Weapon = weapon;
 }
Exemple #2
0
 private Monster(string name, int hitPoints, Position pos, Weapon weapon)
 {
     Name = name;
     HitPoints = hitPoints;
     Pos = pos;
     Weapon = weapon;
 }
Exemple #3
0
        public void MoveOnBoard(Position heroPos)
        {
            var foundMonster = false;

            while (!foundMonster)
            {
                var cki = ReadKey();
                switch (cki.Key)
                {
                    case ConsoleKey.RightArrow:
                        if (!PosIsWallOrOutOfBoard(heroPos.X1, heroPos.Y1 + 1, BoardChars))
                        {
                            heroPos.Y1 += 1;
                            BoardChars[heroPos.X1][heroPos.Y1 - 1] = 'o';
                            BoardChars[heroPos.X1][heroPos.Y1] = 'x';
                            NumberOfSteps++;
                            foundMonster = PosIsMonster();
                        }
                        Clear();
                        DisplayBoard();
                        break;
                    case ConsoleKey.LeftArrow:
                        if (!PosIsWallOrOutOfBoard(heroPos.X1, heroPos.Y1 - 1, BoardChars))
                        {
                            heroPos.Y1 -= 1;
                            BoardChars[heroPos.X1][heroPos.Y1 + 1] = 'o';
                            BoardChars[heroPos.X1][heroPos.Y1] = 'x';
                            NumberOfSteps++;
                            foundMonster = PosIsMonster();
                        }
                        Clear();
                        DisplayBoard();
                        break;
                    case ConsoleKey.UpArrow:
                        if (!PosIsWallOrOutOfBoard(heroPos.X1 - 1, heroPos.Y1, BoardChars))
                        {
                            heroPos.X1 -= 1;
                            BoardChars[heroPos.X1 + 1][heroPos.Y1] = 'o';
                            BoardChars[heroPos.X1][heroPos.Y1] = 'x';
                            NumberOfSteps++;
                            foundMonster = PosIsMonster();
                        }
                        Clear();
                        DisplayBoard();
                        break;
                    case ConsoleKey.DownArrow:
                        if (!PosIsWallOrOutOfBoard(heroPos.X1 + 1, heroPos.Y1, BoardChars))
                        {
                            heroPos.X1 += 1;
                            BoardChars[heroPos.X1 - 1][heroPos.Y1] = 'o';
                            BoardChars[heroPos.X1][heroPos.Y1] = 'x';
                            NumberOfSteps++;
                            foundMonster = PosIsMonster();
                        }
                        Clear();
                        DisplayBoard();
                        break;
                    case ConsoleKey.F12:
                        Environment.Exit(0);
                        break;
                }
            }
        }