コード例 #1
0
        static void OldMain(string[] args)
        {
            Random      random;
            GameState   GameState = new GameState();
            TitleScreen TS        = new TitleScreen();

            switch (TitleScreen.Display())
            {
            case 1:
                //start a new game
                GameState.init();
                break;

            case 2:
                //load a game
                GameState.LoadGame();
                break;

            case 4:
                //check for updates
                Update update = new Update();
                update.StartUpdate();
                //var updateProcess = System.Diagnostics.Process.Start(@"..\win10-x64-Update\Update.exe");
                //updateProcess.WaitForExit();
                break;
            }

            /*
             * struct HighScore{
             *  int highScore = 0;
             *  String highScoreName = "None";
             * }
             */
            Time time = new Time();

            time.initTime();
            //UNCOMMENT THE LINES BELOW TO START THE CLOCK
            Thread timeThread = new Thread(new ThreadStart(time.runTime));

            timeThread.IsBackground = true;
            timeThread.Start();
            Player p1 = new Player();

            p1 = GameState.Player;
            p1.APPointPlacement();
            //GAME LOOP
            Console.WriteLine("\nWelcome to the Dungeon \n Survive all 7 days to win!");
            Console.WriteLine("\nWould you like the Tutorial? y/n");
            if (Console.ReadLine() == "y")
            {
                Tutorial(p1);
            }
            while (!p1.getdead() || !time.endTime())
            {
                p1.CalculateHungry(time.day, time.hour);
                if (p1.dead == true)
                {
                    break;
                }
                Console.WriteLine("\n1. Walk deeper into the cave.");
                Console.WriteLine("2. Eat some food.");
                Console.WriteLine("3. Rest.");
                Console.WriteLine("4. Quit");
                switch (Console.ReadLine())
                {
                case "1":
                    random = new Random();
                    //int whatE = random.Next(1, numEnemies);
                    //Console.WriteLine("whatE = {0}", whatE);
                    Enemy e = newEnemy(time.day, time.hour);
                    if (e.name.Contains("Chad"))
                    {
                        FinalBoss(p1, e);
                        p1.score += 2;
                        Console.WriteLine("Score = {0}", p1.score);
                        return;
                    }
                    Console.WriteLine("You decide to keep walking further into the depths.");
                    Console.WriteLine("All of the sudden you get ambushed by a {0}", e.name);
                    Battle(p1, e);
                    if (e.name.Contains("Boss"))
                    {
                        time.day++;
                        time.hour = 0;
                    }
                    if (p1.dead == true)
                    {
                        break;
                    }
                    p1.score++;
                    p1.Exp(1 * e.area);
                    Console.WriteLine("Score = {0}", p1.score);
                    int whatToDrop = random.Next(1, 3);
                    if (whatToDrop == 1)
                    {
                        int item = e.DropItem();
                        if (item == 0)     //no item dropped
                        {
                            Console.WriteLine("Nothin useful was found");
                            break;
                        }
                        else if (item == 1)      //food dropped
                        {
                            Console.WriteLine("{0} dropped some food!", e.name);
                            p1.numFood++;
                        }
                        else if (item == 2)      //health potion Dropped
                        {
                            Console.WriteLine("{0} dropped a health potion!", e.name);
                            p1.numHealthPotions++;
                        }
                        else
                        {
                            Console.WriteLine("ERROR: invalid item dropped, item num = {0}", whatToDrop);
                        }
                    }
                    else if (whatToDrop == 2)
                    {
                        Weapon NewWeapon = e.DropWeapon();
                        if (NewWeapon.name != "Empty")
                        {
                            Console.WriteLine("{0} dropped a {1}", e.name, NewWeapon.name);
                            p1.getWeapon(NewWeapon);
                        }
                        else if (NewWeapon.name == "Empty")
                        {
                            Console.WriteLine("Nothin useful was found");
                        }
                    }
                    else
                    {
                        Console.WriteLine("ERROR: No Drop Option with number {0}", whatToDrop);
                    }
                    time.hour++;
                    Console.WriteLine("day {0} at hour {1}", time.day, time.hour);
                    break;

                case "2":
                    if (p1.numFood > 0)
                    {
                        Console.WriteLine("You ate some food, it helps keep away the hunger");
                        p1.eat(time.day, time.hour);
                    }
                    else
                    {
                        Console.WriteLine("You have no food to eat");
                    }
                    break;

                case "3":
                    Console.WriteLine("You decide to take a break for a bit");
                    random = new Random();
                    int sleepAttack = random.Next(0, 10);
                    if (sleepAttack < 8)
                    {
                        p1.HealFist();
                        if (time.hour + 4 > 23)
                        {
                            time.hour = 23;
                        }
                        else
                        {
                            time.hour += 4;
                        }
                        p1.stamina += 2;
                        p1.health  += 15;
                    }
                    else
                    {
                        time.hour += 2;
                        Console.WriteLine("You hear something in your sleep. You awaken to find you are surrounded by shadowy figures!");
                        Console.WriteLine("You're able to fend them off but you did take some damage");
                        p1.health = Convert.ToInt32(Math.Floor(p1.health * .75));
                    }
                    break;

                case "4":
                    Console.WriteLine("Are you sure you want to quit? y/n");
                    if (Console.ReadLine() == "y")
                    {
                        return;
                    }
                    else
                    {
                        break;
                    }

                default:
                    Console.WriteLine("Invalid option, try something else.");
                    break;
                }
            }
            Console.WriteLine("Score: {0}", p1.score);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            //Random random;
            GameState   GameState = new GameState();
            TitleScreen TS        = new TitleScreen();

            switch (TitleScreen.Display())
            {
            case 1:
                //start a new game
                GameState = GameState.init();
                break;

            case 2:
                //load a game
                GameState = GameState.LoadGame();
                break;

            case 4:
                //check for updates
                Update update = new Update();
                update.StartUpdate();
                //var updateProcess = System.Diagnostics.Process.Start(@"..\win10-x64-Update\Update.exe");
                //updateProcess.WaitForExit();
                break;
            }

            /*
             * struct HighScore{
             *  int highScore = 0;
             *  String highScoreName = "None";
             * }
             */
            Time   time       = GameState.time;
            Thread timeThread = new Thread(new ThreadStart(time.runTime));

            timeThread.IsBackground = true;
            timeThread.Start();
            Player p1 = GameState.Player;

            Console.WriteLine("p1 health = {0}", p1.health);
            Console.WriteLine("\nWelcome to the Dungeon \n Survive all 7 days to win!");
            Console.WriteLine("\nWould you like the Tutorial? y/n");
            if (Console.ReadLine() == "y")
            {
                Tutorial Tutorial = new Tutorial();
                Tutorial.run(p1);
            }
            //TODO: Make overworld Menu class and loop
            OverWorldMenu Menu       = new OverWorldMenu();
            int           GameResult = Menu.Menu(p1, time, GameState); //this is where the main game gameplay loop is

            if (GameResult == 0)
            {
                //Console.Clear();
                Console.WriteLine("Chad falls to the floor, having used all of his energy he turns to chrimson dust and blows away");
                Console.WriteLine("Congrats, you are now the king of Hell.");
            }
            Console.WriteLine("#############################################");
            Console.WriteLine("#             Thanks For Playing            #");
            Console.WriteLine("#        Find this project on GitHub        #");
            Console.WriteLine("# https://github.com/BoneKing/Dungeon-Redux #");
            Console.WriteLine("#     This game was made by Andy Mahoney    #");
            Console.WriteLine("#            Last Updated 10/20/2020        #");
            Console.WriteLine("#############################################");
        }