Ejemplo n.º 1
0
        public static bool BattleLoop(Adventurer adventurer, Universe universe, Slime slime)
        {
            TextBoxViews.ClearMapBox();
            TextBoxViews.RedrawBox(universe, 6);

            bool blocked;
            bool stillAlive = true;

            TextBoxViews.ReWriteToMessageBox(universe, "A slime attacks!");
            Random random = new Random();

            do
            {
                TextDrawings.DisplaySlime(slime);

                TextBoxViews.WriteToEvent("Slime : " + slime.Health);
                TextBoxViews.DisplayPlayerInfo(adventurer);

                blocked = Attack(adventurer, universe, slime);

                TextBoxViews.WriteToEvent("Slime : " + slime.Health);

                if (slime.Health > 0)
                {
                    SlimeATK(adventurer, universe, slime, blocked);
                }
            } while ((adventurer.Health > 0) && (slime.Health > 0));
            if (adventurer.Health > 0)
            {
                int coinDrop;
                int gelDrop;
                int expGain;

                coinDrop = random.Next(10, 30);
                gelDrop  = random.Next(5, 15);
                expGain  = random.Next(10, slime.ExpGiv);

                TextBoxViews.WriteToMessageBox(universe, $"You have succeeded in battle and have recieved {coinDrop} coins and {gelDrop} gel.");

                adventurer.Coins += coinDrop;
                adventurer.ItemsDictionary[Item.Items.SlimeGel] += gelDrop;
                adventurer.Experinece += expGain;
                if (adventurer.Experinece >= adventurer.MaxExperience)
                {
                    Adventurer.PlayerLevelUp(adventurer, universe);
                }
            }
            else
            {
                stillAlive = false;
            }
            TextBoxViews.ClearMapBox();
            TextBoxViews.RemoveContent(universe, 3);
            TextBoxViews.DisplayMenu(universe);
            TextBoxViews.DisplayPlayerInfo(adventurer);

            return(stillAlive);
        }
Ejemplo n.º 2
0
        public static void StartGame()
        {
            bool didjaWin;

            Console.CursorVisible = false;
            Windows[] windows = new Windows[6];
            Console.BackgroundColor = ConsoleColor.Gray;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.SetWindowSize(150, 60);
            //WindowConfig.NumbersOnScreen();
            TextBoxViews.SplashScreen(40, 25);

            Console.ReadLine();
            Console.Clear();
            windows = InitializeWindowScreens();
            Universe universe = new Universe();

            universe = universe.InitializeUniverse(windows);

            TextBoxViews.WriteToMessageBox(universe, "After defeating the slime king peace was returned to the land. But not all peace lasts forever, and a group of bandits have set up camp in a nearby cave and it is your job to take them out...");

            Adventurer adventurer = new Adventurer();

            adventurer = TextBoxViews.GetPlayerInfo(universe);



            TextBoxViews.DisplayMenu(universe);
            didjaWin = GameLoop(adventurer, universe);


            TextBoxViews.RedrawBox(universe, 5);
            if (adventurer.playerWin)
            {
                TextBoxViews.WriteToMessageBox(universe, "YOU WIN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            }
            else if (adventurer.diedOnFinal)
            {
                TextBoxViews.WriteToMessageBox(universe, "So close...");
            }
            TextBoxViews.WriteToMessageBox(universe, "Game Over");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets up an inventory to display in the Menu
        /// </summary>
        /// <param name="adventurer"></param>
        public static void InventoryManagment(Adventurer adventurer, Universe universe)
        {
            bool           usingInventory = true;
            ConsoleKeyInfo key;
            Dictionary <Item.Items, int> itemList = new Dictionary <Item.Items, int>();

            Item.Items[] itemarray = new Item.Items[10];
            int          i         = 0;

            foreach (var item in adventurer.ItemsDictionary)
            {
                itemList.Add(item.Key, item.Value);
                itemarray[i] = item.Key;

                i++;
            }

            Item.Items itemToUse = Item.Items.Nothing;

            while (usingInventory)
            {
                TextBoxViews.RemoveContent(universe, 3);
                TextBoxViews.DisplayInventory(itemList);
                bool error = false;
                key = Console.ReadKey();
                try
                {
                    //remove use item from temp inventory
                    switch (key.Key)
                    {
                    case ConsoleKey.D1:
                        itemList[itemarray[0]] -= 1;
                        itemToUse = itemarray[0];
                        break;

                    case ConsoleKey.D2:
                        itemList[itemarray[1]] -= 1;
                        itemToUse = itemarray[1];
                        break;

                    case ConsoleKey.D3:
                        itemList[itemarray[2]] -= 1;
                        itemToUse = itemarray[2];
                        break;

                    case ConsoleKey.D4:
                        itemList[itemarray[3]] -= 1;
                        itemToUse = itemarray[3];
                        break;

                    case ConsoleKey.D5:
                        itemList[itemarray[4]] -= 1;
                        itemToUse = itemarray[4];
                        break;

                    case ConsoleKey.D6:
                        itemList[itemarray[5]] -= 1;
                        itemToUse = itemarray[5];
                        break;

                    case ConsoleKey.D7:
                        itemList[itemarray[6]] -= 1;
                        itemToUse = itemarray[6];
                        break;

                    case ConsoleKey.D8:
                        itemList[itemarray[7]] -= 1;
                        itemToUse = itemarray[7];
                        break;

                    case ConsoleKey.D9:
                        usingInventory = false;
                        break;

                    case ConsoleKey.NumPad1:
                        itemList[itemarray[0]] -= 1;
                        itemToUse = itemarray[0];
                        break;

                    case ConsoleKey.NumPad2:
                        itemList[itemarray[1]] -= 1;
                        itemToUse = itemarray[1];
                        break;

                    case ConsoleKey.NumPad3:
                        itemList[itemarray[2]] -= 1;
                        itemToUse = itemarray[2];
                        break;

                    case ConsoleKey.NumPad4:
                        itemList[itemarray[3]] -= 1;
                        itemToUse = itemarray[3];
                        break;

                    case ConsoleKey.NumPad5:
                        itemList[itemarray[4]] -= 1;
                        itemToUse = itemarray[4];
                        break;

                    case ConsoleKey.NumPad6:
                        itemList[itemarray[5]] -= 1;
                        itemToUse = itemarray[5];
                        break;

                    case ConsoleKey.NumPad7:
                        itemList[itemarray[6]] -= 1;
                        itemToUse = itemarray[6];
                        break;

                    case ConsoleKey.NumPad8:
                        itemList[itemarray[7]] -= 1;
                        itemToUse = itemarray[7];
                        break;

                    case ConsoleKey.NumPad9:
                        usingInventory = false;
                        break;


                    case ConsoleKey.LeftArrow:
                        usingInventory = false;
                        break;

                    case ConsoleKey.RightArrow:
                        usingInventory = false;
                        break;

                    case ConsoleKey.UpArrow:
                        usingInventory = false;
                        break;

                    case ConsoleKey.DownArrow:
                        usingInventory = false;
                        break;



                    default:
                        break;
                    }
                }
                catch (Exception)
                {
                    error = true;
                    //No throwing in here
                }
                finally
                {
                    //I decided im not dealing with the program deciding to add to nothing. tOb can keep trying though
                    try
                    {
                        if (!error && !(key.Key == ConsoleKey.D9 || key.Key == ConsoleKey.NumPad9) && !(adventurer.ItemsDictionary[itemToUse] <= 0))
                        {
                            switch (itemToUse)
                            {
                            case Item.Items.HealthPotion:
                                Adventurer.PlayerPotionHeal(adventurer, universe);
                                adventurer.ItemsDictionary[itemToUse] = itemList[itemToUse];
                                break;

                            case Item.Items.ManaPotion:
                                TextBoxViews.WriteToMessageBox(universe, "You feel all tingly inside");
                                adventurer.ItemsDictionary[itemToUse] = itemList[itemToUse];
                                break;

                            case Item.Items.Stone:
                                TextBoxViews.WriteToMessageBox(universe, "You throw the stone and it vanishes into the distance...");
                                adventurer.ItemsDictionary[itemToUse] = itemList[itemToUse];
                                break;

                            case Item.Items.SlimeGel:
                                TextBoxViews.WriteToMessageBox(universe, "You cannot use slime...");
                                itemList[itemToUse]++;
                                break;

                            case Item.Items.Parcel:
                                TextBoxViews.WriteToMessageBox(universe, "You cannot use the parcel you are delivering!");
                                itemList[itemToUse]++;
                                break;

                            case Item.Items.Nothing:
                                TextBoxViews.WriteToMessageBox(universe, "There is nothing there");
                                break;

                            default:
                                break;
                            }
                        }

                        else if (!(key.Key == ConsoleKey.D9 || key.Key == ConsoleKey.NumPad9) && (itemList[itemToUse] < 0))
                        {
                            TextBoxViews.WriteToMessageBox(universe, "You dont have that item");

                            itemList[itemToUse]++;
                        }
                        else if (!(key.Key == ConsoleKey.D9 || key.Key == ConsoleKey.NumPad9))
                        {
                            TextBoxViews.WriteToMessageBox(universe, "You dont have that item");
                        }
                    }
                    catch (Exception)
                    {
                    } //End try catch inventory navigation
                }     //end finally
            }         //end using inventory while


            TextBoxViews.DisplayMenu(universe);
        }