Exemplo n.º 1
0
        /// <summary>
        /// Runs the game loop. Moving tokens and otherwise
        /// </summary>
        /// <param name="difficulty">Current Game Difficulty</param>
        /// <param name="map">The Current Map</param>
        /// <param name="newPlayer">The Current Player</param>
        /// <param name="dronePile">All of the enemies currently being placed onto the map</param>
        /// <returns></returns>
        public bool RunGameLoop(int difficulty, Map map, PlayerCharacter newPlayer, List <Drone> dronePile)
        {
            bool winState = false;
            bool gameOver = false;

            Console.Clear();
            DisplayMap(difficulty, map);
            int tickCounter = 0;

            while (!winState && !gameOver)                                          //Runs
            {
                if (tickCounter % 100 == 0 && tickCounter != 0 && difficulty >= 10) //Dupication logic for Agrgressive Drone Boss
                {
                    EnemyDroneDiggerAggressive newBossDrone = new EnemyDroneDiggerAggressive(map);
                    dronePile.Add(newBossDrone);
                }
                Console.CursorVisible = false;
                newPlayer.Move(map);
                foreach (Drone enemyDrone in dronePile) //Moves each drone which was added to the list of them.
                {
                    enemyDrone.Move(map);
                }
                map.Display = map.BuildMapDisplay(newPlayer); //Sets the display string to the Built Map display with the new locations.

                DisplayMap(difficulty, map);                  // Sets the display of the map.

                //Console.WriteLine(map.Display);
                bool hitDrone = true;
                for (int i = 0; i < map.MapArrayOfArrays.Length; i++)
                {
                    for (int j = 0; j < map.MapArrayOfArrays[i].Length; j++)
                    {
                        if (map.MapArrayOfArrays[i][j] == newPlayer.Value)
                        {
                            hitDrone = false; //Checks the entire map for the player value. If the value exists then it did not hit the drone.
                        }
                    }
                }

                if (hitDrone)
                {
                    gameOver = true;
                }

                if (newPlayer.Position[0] == map.MapArrayOfArrays.Length - 2 &&
                    newPlayer.Position[1] == map.MapArrayOfArrays[map.MapArrayOfArrays.Length - 2].Length - 2)    //If the player has made it to the end They win
                {
                    winState = true;
                }
                tickCounter++; //Counts each loop.
            }
            return(winState);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Runs the logic around the game loop
        /// </summary>
        /// <param name="difficulty">Difficulty of the game</param>
        /// <param name="newPlayer">The current player</param>
        /// <returns>Whether or not the game will continue</returns>
        public bool RunGame(int difficulty, PlayerCharacter newPlayer)
        {
            bool retry = false;

            do
            {
                newPlayer.Position[0] = 1;
                newPlayer.Position[1] = 1;
                retry = false;
                Console.WriteLine("Loading New Map...");
                Console.WriteLine("This may take up to 60 seconds...");
                int height = 10;
                if (difficulty < 3)
                {
                    height = difficulty * 6;
                }
                int width;
                if (difficulty > 5)
                {
                    width  = difficulty * 15;
                    height = difficulty * 2;
                }
                else
                {
                    width = 50;
                }
                Map          map       = new Map(width, height, newPlayer);
                List <Drone> dronePile = new List <Drone>();
                for (int i = 0; i < difficulty * 2; i++)
                {
                    EnemyDroneRandom newDrone = new EnemyDroneRandom(map);
                    dronePile.Add(newDrone);
                }
                for (int i = 0; i < difficulty / 2; i++)
                {
                    EnemyDroneDigger newDiggerDrone = new EnemyDroneDigger(map);
                    dronePile.Add(newDiggerDrone);
                }
                for (int i = 0; i < difficulty / 10; i++)
                {
                    EnemyDroneDiggerAggressive newDiggerDrone = new EnemyDroneDiggerAggressive(map);
                    dronePile.Add(newDiggerDrone);
                }

                map.Display = map.BuildMapDisplay(newPlayer);
                bool didWin = false;

                didWin = RunGameLoop(difficulty, map, newPlayer, dronePile);
                if (didWin)
                {
                    Console.WriteLine("-----CONGRATS YOU WIN-----");
                    if (difficulty < 10)
                    {
                        Console.WriteLine("There are still challenges left would you like to try the next difficulty (y/n)?");
                        string input = Console.ReadLine().ToLower();
                        if (input == "y")
                        {
                            return(true);
                        }
                        else
                        {
                            Console.WriteLine("Thanks for playing!");
                            Console.ReadLine();
                        }
                    }
                    else
                    {
                        if (difficulty == 10)
                        {
                            Console.WriteLine($"YOU BEAT LEVEL 10... {newPlayer.Name} YOU ARE HEREBY DUBBED RNGESUS!!!");
                        }
                        Console.WriteLine("Thanks for playing!");
                        Console.ReadLine();
                    }
                }
                else
                {
                    Console.WriteLine("-----GAME OVER-----");
                    Console.WriteLine("Would you like to try again (y/n)?");
                    string input = Console.ReadLine().ToLower();
                    if (input == "y")
                    {
                        retry = true;
                    }
                    else
                    {
                        Console.WriteLine("Thanks for playing!");
                        Console.ReadLine();
                    }
                }
            } while (retry);

            return(false);
        }