コード例 #1
0
        private static void SlimeATK(Adventurer adventurer, Universe universe, Slime slime, bool blocked)
        {
            //Setup
            Random random = new Random();
            int    attack = random.Next(1, 4);
            int    damage = 0;
            bool   tOb    = true;//tOb is here to help

            //If else statement to handle what happens next
            if (!slime.PowerAttack)
            {
                if (attack == 1)
                {
                    TextBoxViews.ReWriteToMessageBox(universe, "The slime jumps at you and lands on your foot...");
                    damage = random.Next(5, slime.Damage);
                }
                else if (attack == 2)
                {
                    TextBoxViews.ReWriteToMessageBox(universe, "The slime jumps at you and hits you in the chest...");
                    damage = random.Next(5, slime.Damage);
                }
                else if (attack == 3)
                {
                    TextBoxViews.ReWriteToMessageBox(universe, "The slime readies to do a very powerful attack...");
                    slime.PowerAttack = true;
                    tOb = false;
                }

                else
                {
                    TextBoxViews.WriteToMessageBox(universe, "Error: No attack defined...");
                }
            }
            else if (slime.PowerAttack)
            {
                damage = random.Next(20, slime.Damage * 3);

                TextBoxViews.ReWriteToMessageBox(universe, "The slime slams into you with a lot of force.");
            }
            else
            {
                TextBoxViews.ReWriteToMessageBox(universe, "Not supposed to HAPPEN");
            }



            if (tOb)
            {
                if (blocked)
                {
                    TextBoxViews.ReWriteToMessageBox(universe, "You blocked the slime's attack");
                    slime.PowerAttack = false;
                }
                else if (slime.PowerAttack)
                {
                    if (damage > 29)
                    {
                        TextBoxViews.ReWriteToMessageBox(universe, "The slime hits you for a whopping " + damage + " damage! Thats a lot of damage.");
                    }
                    else
                    {
                        TextBoxViews.ReWriteToMessageBox(universe, "The slime hits you for a whopping " + damage + " damage!");
                    }
                    slime.PowerAttack  = false;
                    adventurer.Health -= damage;
                }
                else
                {
                    TextBoxViews.ReWriteToMessageBox(universe, $"The slime deals {damage} damage.");
                    adventurer.Health = adventurer.Health - damage;
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Winterpaw22/SlimeFighter
        static void BattleLoop(Player player, Slime slime, Ally ally)
        {
            Random random = new Random();

            do
            {
                ScreenWindows.ClearPlayerTextBox();
                if (slime.KingSlime)
                {
                    ScreenWindows.DisplayKingSlime();
                }
                else
                {
                    ScreenWindows.DisplaySlime(slime);
                }
                ScreenWindows.SlimeAndChatColor(slime);

                Player(player, slime, ally);
                Thread.Sleep(1000);
                ScreenWindows.ClearPlayerTextBox();
                if (slime.Health > 0)
                {
                    SlimeATK(player, slime);
                }
            } while ((player.Health > 0) && (slime.Health > 0));



            ScreenWindows.ClearPlayerTextBox();
            Console.ForegroundColor = ConsoleColor.Yellow;
            #region Gold and Experience
            int goldDrop;
            int exp;
            if (slime.KingSlime)
            {
                goldDrop = random.Next(60, 100);
                exp      = random.Next(200, 500);
            }
            else if (slime.Color == "red")
            {
                goldDrop = random.Next(20, 30);
                exp      = random.Next(100, 150);
            }
            else if (slime.Color == "blue")
            {
                goldDrop = random.Next(10, 15);
                exp      = random.Next(60, 100);
            }
            else if (slime.Color == "green")
            {
                goldDrop = random.Next(4, 7);
                exp      = random.Next(20, 60);
            }
            else
            {
                goldDrop = random.Next(2, 5);
                exp      = random.Next(2, 30);
            }
            Console.SetCursorPosition(27, 33);
            Console.Write($"You have succeeded in battle and have recieved {goldDrop} Gold!");
            Console.SetCursorPosition(27, 34);
            Console.Write($"You gained {exp} Experience Points!");
            #endregion



            if (slime.HasCharm)
            {
                InitializeAlly(ally, slime, player);
                Console.SetCursorPosition(27, 34);
                Console.Write("You picked up a Slime charm... You put it around your neck.");
                Thread.Sleep(1000);
                Console.SetCursorPosition(27, 35);
                Console.Write("A little slime appears next to you and jumps on your head");
                Thread.Sleep(1000);
                switch (ally.Charm)
                {
                case Ally.Charms.REDCHARM:
                    Console.SetCursorPosition(27, 36);
                    Console.Write("It appears the slime is wielding its own sword");
                    Thread.Sleep(2500);
                    Console.SetCursorPosition(27, 37);
                    Console.WriteLine("The slime fights along side you!");
                    Thread.Sleep(1000);
                    break;

                case Ally.Charms.BLUECHARM:
                    Console.SetCursorPosition(27, 36);
                    Console.Write("The slime makes a small shield out of its own goo, ");
                    Thread.Sleep(2500);
                    Console.SetCursorPosition(27, 37);
                    Console.WriteLine("It seems to be trying to protect you...");
                    Thread.Sleep(1000);
                    break;

                case Ally.Charms.PINKCHARM:
                    Console.SetCursorPosition(27, 36);
                    Console.Write("You feel your injuries heal slightly");
                    Thread.Sleep(2500);
                    Console.SetCursorPosition(27, 37);
                    Console.WriteLine("You regained 5 health!");
                    Thread.Sleep(1000);
                    player.Health = player.Health + 5;
                    if (player.Health > player.MaxHealth)
                    {
                        player.Health = player.MaxHealth;
                    }
                    break;

                case Ally.Charms.GREENCHARM:
                    Console.SetCursorPosition(27, 36);
                    Console.Write("You start remembering more about your battle");
                    Thread.Sleep(2500);
                    Console.SetCursorPosition(27, 37);
                    Console.WriteLine("Experience boost!");
                    Thread.Sleep(1000);
                    break;

                default:
                    Console.SetCursorPosition(27, 36);
                    Console.Write("BROKEN ERROR ERROR ERROR ERROR");
                    Thread.Sleep(2500);
                    Console.SetCursorPosition(27, 37);
                    Console.WriteLine("SOME SHIT WENT DOWN NOW FIX OR WAIT A YEAR ");
                    Thread.Sleep(99999999);
                    break;
                }


                ScreenWindows.DisplayContinuePrompt(103, 38);
                ScreenWindows.ClearPlayerTextBox();
            }
            Console.ForegroundColor = ConsoleColor.Gray;
            player.Gold             = player.Gold + goldDrop;
            ScreenWindows.DisplayContinuePrompt(103, 38);
        }
コード例 #3
0
        private static bool Attack(Adventurer adventurer, Universe universe, Slime slime)
        {
            Random random    = new Random();
            int    damage    = adventurer.Damage;
            bool   blocking  = false;
            bool   tOb       = true;
            string attackMsg = "You slap the slime, YEAH F*** THAT GUY. WOOOOOOOOOOOOOOOOOO";

            if ((adventurer.PlayerWeapon == Adventurer.Weapon.BroadSword) || (adventurer.PlayerWeapon == Adventurer.Weapon.Sword))
            {
                attackMsg = "You swing your " + adventurer.PlayerWeapon + " at the slime";
            }
            else if ((adventurer.PlayerWeapon == Adventurer.Weapon.Dagger))
            {
                attackMsg = "You stabb the slime with your " + adventurer.PlayerWeapon;
            }
            else if ((adventurer.PlayerWeapon == Adventurer.Weapon.Bow))
            {
                attackMsg = "You shoot the slime with an arrow";
            }
            else if ((adventurer.PlayerWeapon == Adventurer.Weapon.Mace))
            {
                attackMsg = "You hit the slime with your " + adventurer.PlayerWeapon;
            }
            else if ((adventurer.PlayerWeapon == Adventurer.Weapon.Staff))
            {
                attackMsg = "You cast a fire spell on the slime.";
            }
            //
            // PLAYER MENU
            //


            //New method for handling

            TextBoxViews.DisplayCustom(universe, new string[4] {
                " Attack", " Throw a Rock : " + adventurer.ItemsDictionary[Item.Items.Stone], " Block", "Use a potion : " + adventurer.ItemsDictionary[Item.Items.HealthPotion]
            });

            TextBoxViews.ReWriteToMessageBox(universe, "Please choose an action...", true);

            while (tOb)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                switch (key.Key)
                {
                case ConsoleKey.D1:
                    TextBoxViews.ReWriteToMessageBox(universe, attackMsg + " You dealt " + damage + " damage.");
                    slime.Health -= damage;
                    tOb           = false;
                    break;

                case ConsoleKey.D2:
                    if (adventurer.ItemsDictionary[Item.Items.Stone] >= 1)
                    {
                        adventurer.ItemsDictionary[Item.Items.Stone]--;
                        damage = 2;
                        TextBoxViews.ReWriteToMessageBox(universe, "You throw a stone at the slime and deal " + damage.ToString() + " damage.");
                        slime.Health -= damage;
                        tOb           = false;
                    }
                    else
                    {
                        TextBoxViews.ReWriteToMessageBox(universe, "You dont have any rocks to throw", true);
                    }
                    break;

                case ConsoleKey.D3:
                    TextBoxViews.ReWriteToMessageBox(universe, "You get ready to block the slime's next attack.");
                    blocking = true;
                    tOb      = false;
                    break;

                case ConsoleKey.D4:
                    if (adventurer.ItemsDictionary[Item.Items.HealthPotion] > 0)
                    {
                        adventurer.ItemsDictionary[Item.Items.HealthPotion]--;
                        Adventurer.PlayerPotionHeal(adventurer, universe);
                        tOb = false;
                    }
                    else
                    {
                        TextBoxViews.WriteToMessageBox(universe, "You don't have any health potions left");
                    }
                    break;



                case ConsoleKey.NumPad1:
                    TextBoxViews.ReWriteToMessageBox(universe, attackMsg + " You dealt " + damage + " damage.");
                    tOb = false;
                    break;

                case ConsoleKey.NumPad2:
                    if (adventurer.ItemsDictionary[Item.Items.Stone] > 0)
                    {
                        adventurer.ItemsDictionary[Item.Items.Stone]--;
                        damage = 2;
                        TextBoxViews.ReWriteToMessageBox(universe, "You throw a stone at the slime and deal " + damage.ToString() + " damage.");
                        slime.Health -= damage;
                        tOb           = false;
                    }
                    else
                    {
                        TextBoxViews.ReWriteToMessageBox(universe, "You dont have any stones to throw!");
                    }
                    break;

                case ConsoleKey.NumPad3:
                    TextBoxViews.ReWriteToMessageBox(universe, "You get ready to block the slime's next attack.");
                    blocking = true;
                    tOb      = false;
                    break;

                case ConsoleKey.NumPad4:
                    if (adventurer.ItemsDictionary[Item.Items.HealthPotion] > 0)
                    {
                        adventurer.ItemsDictionary[Item.Items.HealthPotion]--;
                        Adventurer.PlayerPotionHeal(adventurer, universe);
                        tOb = false;
                    }
                    else
                    {
                        TextBoxViews.WriteToMessageBox(universe, "You don't have any health potions left");
                    }
                    break;


                default:
                    TextBoxViews.ReWriteToMessageBox(universe, "Please Choose an attack using the numbers on your keyboard.", true);
                    break;
                }
            }
            return(blocking);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Winterpaw22/SlimeFighter
        //-----------------------------Slime PASSIVE-------------------------------------

        static void SlimePassive(Player player, Slime slime, Ally ally)
        {
            //Some setup
            ScreenWindows.DisplayGameScreen();
            ScreenWindows.DisplayTextBoxPlayer();
            ScreenWindows.SlimeAndChatColor(slime);
            ScreenWindows.DisplaySlime(slime);
            Random random       = new Random();
            int    slimePassive = random.Next(1, 4);
            bool   fight        = false;

            //The chances to happen
            ScreenWindows.ClearPlayerTextBox();
            if (slimePassive == 1)
            {
                Console.SetCursorPosition(27, 33);
                Console.Write("The slime slides around in a circle");
            }

            else if (slimePassive == 2)
            {
                Console.SetCursorPosition(27, 33);
                Console.Write("The slime lunges at you but misses...");

                Thread.Sleep(1000);
                Console.SetCursorPosition(27, 34);
                Console.Write("It seems to want to play");
                Thread.Sleep(2000);
            }
            else if (slimePassive == 3)
            {
                Console.SetCursorPosition(27, 33);
                Console.Write("The slime jiggles it's body");
                Thread.Sleep(1000);
                Console.SetCursorPosition(27, 34);
                Console.Write("It seems to be taunting you");
            }
            else
            {
            }
            Thread.Sleep(2000);
            ScreenWindows.ClearPlayerTextBox();

            Console.SetCursorPosition(27, 31);
            Console.Write("Would you like to fight the slime minding its own buisness?");


            ConsoleKeyInfo keyPress;
            bool           optionSelected = false;

            Console.CursorVisible = false;
            //Options
            Console.SetCursorPosition(33, 33);
            Console.Write("Yes");
            Console.SetCursorPosition(33, 34);
            Console.Write("No");
            ScreenWindows.DisplayTextBoxPlayer();
            fight = true;
            Console.SetCursorPosition(29, 33);
            Console.Write("->");
            int tOb     = 33;
            int tObLast = 33;

            while (!optionSelected)
            {
                keyPress = Console.ReadKey();

                if (keyPress.Key == ConsoleKey.UpArrow)
                {
                    tOb = 33;
                    Console.SetCursorPosition(29, tObLast);
                    Console.Write("   ");
                    Console.SetCursorPosition(29, tOb);
                    Console.Write("-> ");
                    fight   = true;
                    tObLast = tOb;
                }
                if (keyPress.Key == ConsoleKey.DownArrow)
                {
                    tOb = 34;
                    Console.SetCursorPosition(29, tObLast);
                    Console.Write("   ");
                    Console.SetCursorPosition(29, tOb);
                    Console.Write("-> ");
                    fight   = false;
                    tObLast = tOb;
                }
                if (keyPress.Key == ConsoleKey.Enter)
                {
                    optionSelected = true;
                }
            }
            ScreenWindows.ClearPlayerTextBox();

            Console.SetCursorPosition(27, 33);
            if (fight)
            {
                BattleLoop(player, slime, ally);
            }
            else if (!fight)
            {
                Console.Write("You continue on...");
            }
            Thread.Sleep(2000);
            Console.ForegroundColor = ConsoleColor.Gray;
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: Winterpaw22/SlimeFighter
        //#------------------------------The actual game--------------------------
        static int GameLoop(Player player, Slime slime, Ally ally)
        {
            ScreenWindows.DisplayTextBoxPlayer();
            Random random = new Random();
            int    end    = 2;

            Console.Clear();
            ScreenWindows.DisplayGameScreen();
            ScreenWindows.DisplayTextBoxPlayer();
            int  KingEncounter = 0;
            bool kingKilled    = false;

            int nothing = 0;

            while ((player.Health > 0) && !kingKilled)
            {
                Thread.Sleep(1000);
                Console.SetCursorPosition(27, 32);
                Console.Write("You walk down a cave corridor...");

                int slimechance = random.Next(1, 4);
                Console.SetCursorPosition(27, 33);
                Thread.Sleep(2000);
                if (slimechance == 1)
                {
                    Console.Write("A slime Attacks!");
                    Thread.Sleep(1000);



                    Slime.InitializeNewSlime(slime, ally);
                    ScreenWindows.DisplaySlime(slime);
                    BattleLoop(player, slime, ally);
                    nothing = 0;
                }
                if (slimechance == 2)
                {
                    Thread.Sleep(2000);
                    Slime.InitializeNewSlime(slime, ally);
                    Console.Write($"You have spotted a {slime.Color} slime minding its own buisness");
                    Thread.Sleep(1000);
                    ScreenWindows.DisplaySlime(slime);
                    SlimePassive(player, slime, ally);
                    nothing = 0;
                }

                else if (slimechance == 3)
                {
                    Console.Write("You got lucky and encountered no slimes");
                    Thread.Sleep(1000);
                    nothing++;
                }
                else
                {
                    Console.Write("Nothing happend and you move on");
                    nothing++;
                }

                if (nothing > 5)
                {
                    Console.WriteLine("A slime dropped onto your head and suprized you");
                    BattleLoop(player, slime, ally);
                    nothing = 0;
                }
                if (KingEncounter > 20)
                {
                    ScreenWindows.ClearPlayerTextBox();
                    Console.SetCursorPosition(27, 33);
                    Console.Write("You feel an intense presense up ahead");
                    for (int dot = 0; dot < 4; dot++)
                    {
                        Console.Write(".");
                        Thread.Sleep(1000);
                    }
                    Console.SetCursorPosition(27, 34);
                    Console.Write("You get a glimpse of a regal slime hiding behind");
                    Console.SetCursorPosition(27, 35);
                    Console.Write("a nearby pillar... you enter the room filled with");
                    Console.SetCursorPosition(27, 36);
                    Console.Write("a powerful presence.");

                    ScreenWindows.DisplayContinuePrompt(103, 38);
                    slime.KingSlime = true;
                    Slime.InitializeNewSlime(slime, ally);

                    BattleLoop(player, slime, ally);
                    kingKilled = true;
                    end        = 3;
                }
                KingEncounter++;
                Thread.Sleep(2500);
                ScreenWindows.ClearPlayerTextBox();
                Console.ForegroundColor = ConsoleColor.Gray;
                ScreenWindows.ClearSlime();
            }
            return(end);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: Winterpaw22/SlimeFighter
        /// <summary>
        ///
        /// Created by John Sabins
        /// Application name: Slime fighter
        ///
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            int windowHeight = 55;
            int windowWidth  = 133;

            Console.SetWindowSize(windowWidth, windowHeight);
            int playTheGame = 1;

            playTheGame = MainMenu(playTheGame);
            if (playTheGame == 1)
            {
                Slime  slime  = new Slime();
                Player player = new Player();
                Ally   ally   = new Ally();
                // programmer: John Sabins
                // Program: Slime Fighter
                Console.Clear();

                ScreenWindows.DisplayTextboxMain();
                Console.SetCursorPosition(38, 14);
                Console.CursorVisible = true;
                bool   nameSet    = false;
                string playername = "Bob";
                while (!nameSet)
                {
                    Console.Write("What is your name young slime fighter:");
                    playername = Console.ReadLine();
                    if (playername.Length < 1)
                    {
                        Console.SetCursorPosition(38, 15);
                        Console.Write("Please enter a name... ");
                    }
                    else if (playername.Length >= 2)
                    {
                        nameSet = true;
                    }
                    Console.SetCursorPosition(38, 14);
                }

                Console.CursorVisible = false;

                #region intro
                Thread.Sleep(1000);
                Console.Clear();
                ScreenWindows.DisplayTextboxMain();
                Console.SetCursorPosition(38, 10);
                Console.WriteLine($"Welcome, {playername}");
                Thread.Sleep(1000);
                Console.SetCursorPosition(38, 11);
                Console.WriteLine("to an endless cave that only has slimes.");
                Thread.Sleep(1000);
                Console.SetCursorPosition(38, 12);
                Console.WriteLine("Slimes are said to be one of the easiest enemies. ");
                Thread.Sleep(1000);
                Console.SetCursorPosition(38, 13);
                Console.WriteLine("Lets see if thats true.");
                Thread.Sleep(1000);
                Console.SetCursorPosition(38, 14);
                Console.WriteLine("Fight an onslaught of slimes to claim the Slime Crown.");
                Thread.Sleep(1000);
                Console.SetCursorPosition(38, 15);
                Console.WriteLine("A precious relic with immense healing capabilities.");
                Thread.Sleep(1000);
                #endregion

                ScreenWindows.DisplayContinuePrompt(90, 17);
                //----------------------Define player and attributes-----------


                InitializePlayer(player, playername);


                ScreenWindows.DisplayTextBoxPlayer();
                Console.SetCursorPosition(27, 32);
                Console.Write("You enter the cave and start walking down an endless corridor");
                Console.SetCursorPosition(27, 33);
                Console.Write("that you see no end to...");
                Thread.Sleep(2000);
                playTheGame = GameLoop(player, slime, ally);
            }

            if (playTheGame == 2)
            {
                Console.SetCursorPosition(55, 16); Console.WriteLine("Thanks for playing"); Thread.Sleep(2500);
            }
            else if (playTheGame == 3)
            {
                ScreenWindows.DisplayTextboxMain();
                Console.SetCursorPosition(59, 13);
                Console.Write("\\\\\\YOU WIN///");
                Console.SetCursorPosition(55, 14);
                Console.WriteLine("Thank you for playing");
                Console.ReadKey();
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: Winterpaw22/SlimeFighter
        //-----------------------------Player Menu-------------------------------

        static void Player(Player player, Slime slime, Ally ally)
        {
            Random random = new Random();
            int    damage = 1;

            //
            // PLAYER MENU
            //
            Console.Clear();
            ScreenWindows.DisplayGameScreen();
            ScreenWindows.DisplayTextBoxPlayer();
            int action;

            Console.CursorVisible = true;
            Console.SetCursorPosition(29, 33);
            Console.Write($" 1  Attack");
            Console.SetCursorPosition(50, 33);
            Console.Write($"{player.Name} : {player.Health}");
            Console.SetCursorPosition(29, 34);
            Console.Write($" 2  Throw a stick");
            Console.SetCursorPosition(50, 34);

            Console.Write($"Slime:{slime.Health}");
            if (ally.Active)
            {
                Console.SetCursorPosition(29, 35);
                Console.WriteLine($" 3  Ally");
            }
            Console.SetCursorPosition(34, 36);
            Console.WriteLine("Gold: " + player.Gold);
            Console.SetCursorPosition(34, 37);
            Console.WriteLine("Experience: " + player.Experience);

            int            tOb     = 33;
            int            tObLast = 33;
            ConsoleKeyInfo keyPress;
            bool           optionSelected = false;

            Console.CursorVisible = true;
            action = 1;
            Console.SetCursorPosition(26, 33);
            Console.Write("->");
            while (!optionSelected)
            {
                keyPress = Console.ReadKey();

                if (keyPress.Key == ConsoleKey.UpArrow)
                {
                    if (action == 2)
                    {
                        action--;
                        tOb--;
                    }
                    else if (action == 3)
                    {
                        action--;
                        tOb--;
                    }
                    Console.SetCursorPosition(26, tObLast);
                    Console.Write("  ");
                    Console.SetCursorPosition(26, tOb);
                    Console.Write("->");
                    tObLast = tOb;
                }
                if (keyPress.Key == ConsoleKey.DownArrow)
                {
                    if (action == 1)
                    {
                        action++;
                        tOb++;
                    }

                    if (ally.Active)
                    {
                        if (action == 2)
                        {
                            action++;
                            tOb++;
                        }
                    }

                    Console.SetCursorPosition(26, tObLast);
                    Console.Write("  ");
                    Console.SetCursorPosition(26, tOb);
                    Console.Write("->");
                    tObLast = tOb;
                }
                if (keyPress.Key == ConsoleKey.Enter)
                {
                    optionSelected = true;
                }
                Console.SetCursorPosition(26, tObLast);
            }
            //
            // END PLAYER MENU
            //
            Console.CursorVisible = false;
            ScreenWindows.ClearPlayerTextBox();
            if (action == 1)
            {
                damage = random.Next(player.Damage[0], player.Damage[1]);
                //switch to visual effects (NOT DONE)
                Console.SetCursorPosition(27, 33);
                Console.Write($"You slash your sword at the slime and deal {damage} damage!");
                Thread.Sleep(1000);
                slime.Health = slime.Health - damage;
            }
            else if (action == 2)
            {
                //switch to visual effects (NOT DONE)
                Console.SetCursorPosition(27, 33);
                Console.Write("You throw a stick at the slime for no reason...");
                Console.SetCursorPosition(27, 33);
                Console.Write("It did nothing...");
                Thread.Sleep(1000);
            }
            else if (action == 3)
            {
                int healAmt = random.Next(2, 10);
                player.Health = player.Health + healAmt;
                Console.SetCursorPosition(27, 33);
                Console.Write($"You let {ally.Name} heal you.");
                Console.SetCursorPosition(27, 34);
                Console.Write($"You healed for {healAmt} health!");
            }
        }
コード例 #8
0
        static void InitializeNewSlime(Slime slime, bool passive, Ally ally)
        {
            //A random system to handle the slime
            Random random = new Random();
            int slimeType = random.Next(1, 5);
            int charmChance = random.Next(1, 10);

            //Green Slime Builder
            if (slimeType == 1)
            {
                slime.Health = 20;
                slime.Damage = 2;
                slime.Color = "green";

                if (charmChance < 5 && ally.Active)
                {
                    ally.Charm = Ally.Charms.GREENCHARM;
                    slime.HasCharm = true;
                }
                else slime.HasCharm = false;
            }
            //Red Slime Builder
            else if (slimeType == 2)
            {
                slime.Health = 20;
                slime.Damage = 5;
                slime.Color = "red";

                if (charmChance < 5 && ally.Active)
                {
                    ally.Charm = Ally.Charms.REDCHARM;
                    slime.HasCharm = true;
                }
                else slime.HasCharm = false;
            }
            //Blue Slime Builder
            else if (slimeType == 3)
            {
                slime.Health = 30;
                slime.Damage = 4;
                slime.Color = "blue";

                if (charmChance < 5 && ally.Active)
                {
                    ally.Charm = Ally.Charms.BLUECHARM;
                    slime.HasCharm = true;
                }
                else slime.HasCharm = false;
            }
            //Pink Slime Builder
            else if (slimeType == 4)
            {
                slime.Health = 45;
                slime.Damage = 3;
                slime.Color = "pink";

                if (charmChance < 5 && ally.Active)
                {
                    ally.Charm = Ally.Charms.PINKCHARM;
                    slime.HasCharm = true;
                }
                else slime.HasCharm = false;

            }
            //Pine Slime Builder
            else
            {
                //just in case something goes wrong a slime is still initialized, although a weak one
                slime.Health = 10;
                slime.Damage = 1;
                slime.Color = "pine";
                slime.HasCharm = false;

            }
            //King Slime builder
            if (slime.KingSlime)
            {
                slime.HasCharm = false;
                slime.Health = 55;
                slime.Damage = 10;
                slime.Color = "purple";
                //if (charmChance < 5 && ally.Active)
                //{
                //    ally.Charm = Ally.Charms.GREENCHARM;
                //    slime.HasCharm = true;
                //}
                //else slime.HasCharm = false;
            }


        }
コード例 #9
0
        static void Player(Player player, Slime slime, Ally ally)
        {
            Random random = new Random();
            int damage = 1;
            //
            // PLAYER MENU
            //
            Console.Clear();
            DisplayGameScreen();
            DisplayTextBoxPlayer();
            int action;
            Console.CursorVisible = true;
            Console.SetCursorPosition(29, 33);
            Console.Write($" 1  Attack");
            Console.SetCursorPosition(50, 33);
            Console.Write($"{player.Name} : {player.Health}");
            Console.SetCursorPosition(29, 34);
            Console.Write($" 2  Throw a stick");
            Console.SetCursorPosition(50, 34);

            Console.Write($"Slime:{slime.Health}");
            if (ally.Active)
            {
                Console.SetCursorPosition(29, 35);
                Console.WriteLine($" 3  Ally");
            }
            Console.SetCursorPosition(34, 36);
            Console.WriteLine("Gold: " + player.Gold);
            Console.SetCursorPosition(34, 37);
            Console.WriteLine("Experience: " + player.Experience);

            int tOb = 33;
            int tObLast = 33;
            ConsoleKeyInfo keyPress;
            bool optionSelected = false;
            Console.CursorVisible = true;
            action = 1;
            Console.SetCursorPosition(26, 33);
            Console.Write("->");
            while (!optionSelected)
            {
                keyPress = Console.ReadKey();

                if (keyPress.Key == ConsoleKey.UpArrow)
                {

                    if (action == 2)
                    {
                        action--;
                        tOb--;
                    }
                    else if (action == 3)
                    {
                        action--;
                        tOb--;
                    }
                    Console.SetCursorPosition(26, tObLast);
                    Console.Write("  ");
                    Console.SetCursorPosition(26, tOb);
                    Console.Write("->");
                    tObLast = tOb;
                }
                if (keyPress.Key == ConsoleKey.DownArrow)
                {
                    if (action == 1)
                    {
                        action++;
                        tOb++;
                    }

                    if (ally.Active)
                    {
                        if (action == 2)
                        {
                            action++;
                            tOb++;
                        }
                    }

                    Console.SetCursorPosition(26, tObLast);
                    Console.Write("  ");
                    Console.SetCursorPosition(26, tOb);
                    Console.Write("->");
                    tObLast = tOb;
                }
                if (keyPress.Key == ConsoleKey.Enter)
                {
                    optionSelected = true;
                }
                Console.SetCursorPosition(26, tObLast);

            }
コード例 #10
0
        /// <summary>
        /// lets you talk to NPC's
        /// Cycles through set text each npc has
        /// </summary>
        /// <param name="adventurer"></param>
        /// <param name="universe"></param>
        public static void NPCTalk(Adventurer adventurer, Universe universe)
        {
            int xPos = adventurer.Xpos;
            int yPos = adventurer.Ypos;


            if (adventurer.InaHouse && adventurer.InHouseName == House.houseName.Market)
            {
                switch (adventurer.LookDirection)
                {
                case Humanoid.Direction.LEFT:
                    xPos -= 2;
                    break;

                case Humanoid.Direction.RIGHT:
                    xPos++;
                    break;

                case Humanoid.Direction.UP:
                    yPos--;
                    break;

                case Humanoid.Direction.DOWN:
                    yPos++;
                    break;

                default:

                    break;
                }
            }
            else
            {
                switch (adventurer.LookDirection)
                {
                case Humanoid.Direction.LEFT:
                    xPos--;
                    break;

                case Humanoid.Direction.RIGHT:
                    xPos++;
                    break;

                case Humanoid.Direction.UP:
                    yPos--;
                    break;

                case Humanoid.Direction.DOWN:
                    yPos++;
                    break;

                default:

                    break;
                }
            }

            bool trig = true;

            string text = "There is no-one to talk with in front of you, Are you going insane?";

            foreach (NPC npc in universe.NPCList)
            {
                if (npc.Xpos == xPos && npc.Ypos == yPos)
                {
                    TextBoxViews.RedrawBox(universe, 7);
                    TextBoxViews.WriteToNpcNameBox(npc.Name);

                    text = npc.messages[npc.listCurrent];
                    npc.listCurrent++;
                    if (npc.MapLocation == adventurer.MapLocation)
                    {
                        if (npc.Name == "Merchant")
                        {
                            TextBoxViews.MerchantMessage(universe, adventurer);
                            trig = false;
                            QuestTrigger(adventurer, universe, Adventurer.Quest.GoShopping);
                        }
                        else if (npc.Name == "OLD MAN")
                        {
                            QuestTrigger(adventurer, universe, Adventurer.Quest.MeetTheOldMan);
                        }
                        else if (npc.Name == "Cerri")
                        {
                            if (adventurer.ItemsDictionary[Item.Items.Parcel] >= 1)
                            {
                                TextBoxViews.WriteToMessageBox(universe, "Oh? You found my parcel! Thank you!");
                                adventurer.ItemsDictionary[Item.Items.Parcel]--;
                                TextBoxViews.WriteToMessageBox(universe, "Here is a few Health potions for your troubles.");
                                adventurer.ItemsDictionary[Item.Items.HealthPotion] += 2;
                                trig = false;
                                QuestTrigger(adventurer, universe, Adventurer.Quest.DeliverTheParcel);
                            }
                        }
                        else if (npc.Name == "Arista")
                        {
                            adventurer.Health = adventurer.MaxHealth;
                        }
                    }
                    else if (adventurer.InHouseName == npc.InHouseName)
                    {
                        if (npc.Name == "Merchant")
                        {
                            TextBoxViews.MerchantMessage(universe, adventurer);
                            trig = false;
                            QuestTrigger(adventurer, universe, Adventurer.Quest.GoShopping);
                        }
                        else if (npc.Name == "OLD MAN")
                        {
                            QuestTrigger(adventurer, universe, Adventurer.Quest.MeetTheOldMan);
                        }
                        else if (npc.Name == "Cerri")
                        {
                            if (adventurer.ItemsDictionary[Item.Items.Parcel] >= 1)
                            {
                                TextBoxViews.WriteToMessageBox(universe, "Oh? You found my parcel! Thank you!");
                                adventurer.ItemsDictionary[Item.Items.Parcel]--;
                                TextBoxViews.WriteToMessageBox(universe, "Here is a few Health potions for your troubles.");
                                adventurer.ItemsDictionary[Item.Items.HealthPotion] += 2;
                                trig = false;
                                QuestTrigger(adventurer, universe, Adventurer.Quest.DeliverTheParcel);
                            }
                        }
                        else if (npc.Name == "Arista")
                        {
                            adventurer.Health = adventurer.MaxHealth;
                        }
                    }



                    if (npc.listCurrent >= npc.listMax)
                    {
                        npc.listCurrent = 0;
                    }
                    TextBoxViews.RemoveBox(universe, 7);
                    TextBoxViews.RemoveContent(universe, 7);
                }
            }
            if (adventurer.MapLocation == Humanoid.Location.Cave)
            {
                foreach (var enemy in universe.TripleTrouble)
                {
                    if (!enemy.Defeated && (enemy.Ypos == yPos) && (enemy.Xpos == xPos))
                    {
                        TextBoxViews.WriteToMessageBox(universe, "I will Beat you!!!");
                        enemy.Defeated = true;
                        Slime slime = new Slime();
                        Slime.InitializeNewSlime(slime, true);
                        adventurer.diedOnFinal = !Battle.BattleLoop(adventurer, universe, slime);
                    }
                }
            }
            if (trig)
            {
                TextBoxViews.WriteToMessageBox(universe, text);
            }
        }