Ejemplo n.º 1
0
 /// <summary>
 /// Creates An Instance Of 'Game'
 /// </summary>
 /// <param name="board">Board To Use Defined Rows And Columns</param>
 /// <param name="renderer">Renderer For Displays</param>
 /// <param name="level">
 /// Level To Create The Exit, The Map And The Traps</param>
 /// <param name="player">Player That Moves Through The Board</param>
 public Game(Board board, Renderer renderer, Level level,
             Player player, HighScoreManager highScoreManager)
 {
     Board            = board;
     Renderer         = renderer;
     Level            = level;
     Player           = player;
     HighScoreManager = highScoreManager;
     InventoryManager = new InventoryManager(Player, Level);
     PossibleItems    = new PossibleItems();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates An Instance of 'Level'
        /// </summary>
        /// <param name="board">Board To Use Defined Rows And Columns</param>
        /// <param name="possibleItems">Items That Can Be In The Level</param>
        /// <param name="player">Player To Set It's Initial Position</param>
        public Level(Board board, Player player, PossibleItems possibleItems)
        {
            Board         = board;
            Player        = player;
            PossibleItems = possibleItems;

            CellList = Board.cellList;

            numberOfCells = Board.Rows * Board.Columns;
            trapList      = new List <Trap>();
            weaponList    = new List <Weapon>();
            foodList      = new List <Food>();

            currentLevel = 1;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Displays All Weapons And Their Corresponding Values,
        /// And Displays All Foods And Their Corresponding Values
        /// </summary>
        /// <param name="possibleItems">
        /// Class That Contains The Arrays Of
        /// All Possible Weapons And Food</param>
        public void ShowHelp(PossibleItems possibleItems)
        {
            Console.Clear();

            Console.WriteLine("Weapons");
            Console.WriteLine("-------");

            // Loops Through List Of All Possible Weapons
            // And Displays Their Values, One By One
            for (int i = 0; i < possibleItems.weapons.Length; i++)
            {
                Console.Write($"Name: {possibleItems.weapons[i].Name}\t\t");
                if (i == 0 || i == 1 || i == 4)
                {
                    Console.Write("\t");
                }
                Console.Write($"AttackPower:" +
                              $" {possibleItems.weapons[i].AttackPower}\t\t");
                Console.Write($"Weight: " +
                              $"{possibleItems.weapons[i].Weight}\t\t");
                Console.Write($"Durability: " +
                              $"{possibleItems.weapons[i].Durability}\n");
            }

            Console.WriteLine("\nFood");
            Console.WriteLine("----");

            // Loops Through List Of All Possible Foods
            // And Displays Their Values, One By One
            for (int i = 0; i < possibleItems.foods.Length; i++)
            {
                Console.Write($"Name: {possibleItems.foods[i].Name}\t\t");
                if (i == 1 || i == 3)
                {
                    Console.Write("\t");
                }
                Console.Write($"HPIncrease: " +
                              $"{possibleItems.foods[i].HPIncrease}\t\t");
                Console.Write($"Weight: {possibleItems.foods[i].Weight}\n");
            }
            Console.WriteLine("\n\nPress any key to return");
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Main Method That Runs Program And
        /// Takes Arguments Given In The Console
        /// </summary>
        /// <param name="args">Arguments Given In The Console</param>
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            // Creates An Instance Of 'Renderer' And 'Player'
            Renderer      renderer      = new Renderer();
            Player        player        = new Player();
            PossibleItems possibleItems = new PossibleItems();


            // Instance Variables
            int rows       = 0;
            int columns    = 0;
            int difficulty = 0;


            for (int i = 0; i < args.Length; i++)
            {
                // Interprets Console Arguments
                switch (args[i])
                {
                case "-r":
                    // Checks If It's An Int, Leaves Program If It Isn't
                    if (int.TryParse(args[i + 1], out rows))
                    {
                        break;
                    }
                    else
                    {
                        renderer.HowToUse("ROWS");
                        return;
                    }

                case "-c":
                    // Checks If It's An Int, Leaves Program If It Isn't
                    if (int.TryParse(args[i + 1], out columns))
                    {
                        break;
                    }
                    else
                    {
                        renderer.HowToUse("COLUMN");
                        return;
                    }

                case "-d":
                    // Checks If It's An Int, Leaves Program If It Isn't
                    if (int.TryParse(args[i + 1], out difficulty))
                    {
                        if (difficulty > 10)
                        {
                            difficulty = 10;
                        }
                        if (difficulty < 1)
                        {
                            difficulty = 1;
                        }
                        break;
                    }
                    else
                    {
                        renderer.HowToUse("DIFFICULTY");
                        return;
                    }

                default:
                    break;
                }
            }

            // Creates An Instance Of 'Board', 'Level' And 'Game'
            Board            board            = new Board(rows, columns, difficulty);
            Level            level            = new Level(board, player, possibleItems);
            HighScoreManager highScoreManager =
                new HighScoreManager(board, player);

            Game game = new Game(board, renderer, level,
                                 player, highScoreManager);

            // Runs The Game Loop
            game.MainLoop();
        }