示例#1
0
        /// <summary>
        /// Lets you purchase from a merchant
        /// </summary>
        /// <param name="universe"></param>
        /// <param name="adventurer"></param>
        public static void MerchantBuy(Universe universe, Adventurer adventurer)
        {
            ConsoleKeyInfo consoleKey;
            bool           keepShopping = true;
            Dictionary <Item.Items, int> itemToPurchase = new Dictionary <Item.Items, int>();

            TextBoxViews.MerchMenu(universe);

            Item.Items item = Item.Items.SlimeGel;
            while (keepShopping)
            {
                bool purchase        = false;
                bool chooseSomething = true;


                int cost = 0;

                while (chooseSomething)
                {
                    consoleKey = Console.ReadKey();

                    switch (consoleKey.Key)
                    {
                    case ConsoleKey.NumPad1:

                        item = Item.Items.HealthPotion;

                        itemToPurchase[item] = HowMany(universe, Item.Items.HealthPotion);

                        cost = 20 * itemToPurchase[item];

                        chooseSomething = false;
                        break;

                    case ConsoleKey.D1:
                        item = Item.Items.HealthPotion;

                        itemToPurchase[item] = HowMany(universe, Item.Items.HealthPotion);

                        cost = 20 * itemToPurchase[item];

                        chooseSomething = false;

                        break;

                    case ConsoleKey.NumPad2:
                        item = Item.Items.ManaPotion;

                        itemToPurchase[item] = HowMany(universe, Item.Items.ManaPotion);

                        cost = 20 * itemToPurchase[item];

                        chooseSomething = false;
                        break;

                    case ConsoleKey.D2:
                        item = Item.Items.ManaPotion;

                        itemToPurchase[item] = HowMany(universe, Item.Items.ManaPotion);

                        cost = 20 * itemToPurchase[item];

                        chooseSomething = false;
                        break;


                    case ConsoleKey.NumPad3:
                        item = Item.Items.Stone;

                        itemToPurchase[item] = HowMany(universe, Item.Items.Stone);

                        cost = 2 * itemToPurchase[item];



                        chooseSomething = false;
                        break;

                    case ConsoleKey.D3:
                        item = Item.Items.Stone;

                        itemToPurchase[item] = HowMany(universe, Item.Items.Stone);

                        cost = 2 * itemToPurchase[item];



                        chooseSomething = false;
                        break;


                    case ConsoleKey.NumPad9:
                        keepShopping    = false;
                        chooseSomething = false;
                        break;

                    case ConsoleKey.D9:
                        keepShopping    = false;
                        chooseSomething = false;
                        break;

                    case ConsoleKey.LeftArrow:
                        keepShopping    = false;
                        chooseSomething = false;
                        break;

                    case ConsoleKey.RightArrow:
                        keepShopping    = false;
                        chooseSomething = false;
                        break;

                    case ConsoleKey.UpArrow:
                        keepShopping    = false;
                        chooseSomething = false;
                        break;

                    case ConsoleKey.DownArrow:
                        keepShopping    = false;
                        chooseSomething = false;
                        break;

                    default:
                        TextBoxViews.ReWriteToMessageBox(universe, "Please choose something I have and not the air please.", true);
                        break;
                    }
                }

                //Prints question
                if (keepShopping == true)
                {
                    TextBoxViews.ReWriteToMessageBox(universe, "So you want to buy " + itemToPurchase[item] + " " + item + "(s) for " + cost + " gold? Yes/No", true);

                    //Gets user input
                    purchase = Validators.ValidYesNo();
                }

                if (keepShopping)
                {
                    //checks if the player has enough coins
                    if (purchase && (adventurer.Coins >= cost))
                    {
                        adventurer.ItemsDictionary[item] += itemToPurchase[item];
                        adventurer.Coins -= cost;

                        TextBoxViews.ReWriteToMessageBox(universe, "Thanks for buyin", true);
                    }

                    else if (purchase && !(adventurer.Coins >= cost))
                    {
                        TextBoxViews.ReWriteToMessageBox(universe, "Hey! You dont have enough to buy that!!!", true);
                    }
                }
                TextBoxViews.DisplayPlayerInfo(adventurer);
            }
        }
示例#2
0
        public static bool movement(Adventurer adventurer, Universe universe)
        {
            ConsoleKeyInfo keyPress;

            keyPress = Console.ReadKey();
            bool playing = true;

            int[] lastPosition = new int[2];

            lastPosition[0] = adventurer.Xpos;
            lastPosition[1] = adventurer.Ypos;

            Console.SetCursorPosition(lastPosition[0], lastPosition[1]);
            Console.Write(" ");
            switch (keyPress.Key)
            {
            case ConsoleKey.LeftArrow:
                adventurer.LookDirection = Humanoid.Direction.LEFT;

                if (adventurer.LastDirection == adventurer.LookDirection)
                {
                    MovementRestriction(adventurer, universe, adventurer.LookDirection);
                }

                adventurer.LastDirection = adventurer.LookDirection;

                Console.SetCursorPosition(adventurer.Xpos, adventurer.Ypos);
                Console.Write("☺");
                break;

            case ConsoleKey.UpArrow:
                adventurer.LookDirection = Humanoid.Direction.UP;

                if (adventurer.LastDirection == adventurer.LookDirection)
                {
                    MovementRestriction(adventurer, universe, adventurer.LookDirection);
                }

                adventurer.LastDirection = adventurer.LookDirection;
                Console.SetCursorPosition(adventurer.Xpos, adventurer.Ypos);
                Console.Write("☺");
                break;

            case ConsoleKey.RightArrow:

                adventurer.LookDirection = Humanoid.Direction.RIGHT;

                if (adventurer.LastDirection == adventurer.LookDirection)
                {
                    MovementRestriction(adventurer, universe, adventurer.LookDirection);
                }

                adventurer.LastDirection = adventurer.LookDirection;
                Console.SetCursorPosition(adventurer.Xpos, adventurer.Ypos);
                Console.Write("☺");
                break;

            case ConsoleKey.DownArrow:
                adventurer.LookDirection = Humanoid.Direction.DOWN;

                if (adventurer.LastDirection == adventurer.LookDirection)
                {
                    MovementRestriction(adventurer, universe, adventurer.LookDirection);
                }

                adventurer.LastDirection = adventurer.LookDirection;
                Console.SetCursorPosition(adventurer.Xpos, adventurer.Ypos);
                Console.Write("☺");
                break;

            case ConsoleKey.NumPad0:
                break;

            case ConsoleKey.NumPad1:
                NPCTalk(adventurer, universe);
                break;

            case ConsoleKey.NumPad2:
                TextBoxViews.DisplayTownDesc(universe);
                break;

            case ConsoleKey.NumPad3:
                PlayerLocationss(adventurer, universe);
                break;

            case ConsoleKey.NumPad4:
                InventoryManagment(adventurer, universe);
                break;

            case ConsoleKey.NumPad5:
                Check.CheckAndPickupItem(universe, adventurer);
                break;

            case ConsoleKey.NumPad6:
                break;

            case ConsoleKey.NumPad7:
                break;

            case ConsoleKey.NumPad8:
                break;

            case ConsoleKey.NumPad9:
                playing = false;
                break;


            case ConsoleKey.D1:
                NPCTalk(adventurer, universe);
                break;

            case ConsoleKey.D2:
                TextBoxViews.DisplayTownDesc(universe);
                break;

            case ConsoleKey.D3:
                PlayerLocationss(adventurer, universe);
                break;

            case ConsoleKey.D4:
                InventoryManagment(adventurer, universe);
                break;

            case ConsoleKey.D5:
                Check.CheckAndPickupItem(universe, adventurer);
                break;

            case ConsoleKey.D9:
                playing = false;
                break;

            default:
                break;
            }


            return(playing);
        }
示例#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);
        }
示例#4
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);
            }
        }