private void UpdateShopStageSelect()
    {
        shopSelect.sprite = Time.time % 0.5f < 0.25f ? selectFlashShop1 : selectFlashShop2;

        shopSelect.transform.position = new Vector3(shopSelectorOrigin.x + shopIndex.x * 32,
                                                    shopSelectorOrigin.y - (shopIndex.y - shopIndex.z) * 48,
                                                    shopSelect.transform.position.z);

        if (purchaseCooldown > 0.0f)
        {
            purchaseCooldown -= Time.deltaTime;
        }
        else if (Input.GetButtonDown("Start"))
        {
            if ((shopIndex.y) * 6 + shopIndex.x >= Item.itemList.Length)
            {
                return;
            }

            Item.Items item = itemCatalog[(shopIndex.y) * 6 + shopIndex.x];
            if (GameManager.bolts >= Item.itemList[(int)item].boltCost)
            {
                Item.AddItemQuantity(item, 1);
                GameManager.bolts -= Item.itemList[(int)item].boltCost;
                Helper.PlaySound(stageAudioConfirm);
            }
            else
            {
                Helper.PlaySound(stageAudioCancel);
            }

            purchaseCooldown = 0.25f;
        }
    }
Esempio n. 2
0
        /// <summary>
        /// Asks the user how many of the item they wish to buy
        /// </summary>
        /// <param name="universe"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public static int HowMany(Universe universe, Item.Items item)
        {
            TextBoxViews.ReWriteToMessageBox(universe, "How many " + item + "s would you like?", true);


            return(Validators.ValidInt());
        }
Esempio n. 3
0
 public Item RemoveItem(Item.Items it)
 {
     if (CurrentItem != null)
     {
         Item temp = CurrentItem;
         CurrentItem = null;
         return(temp);
     }
     return(null);
 }
Esempio n. 4
0
 public bool AddItem(Item.Items key, Item it)
 {
     if (!(Inventory.ContainsKey(key)))
     {
         Inventory.Add(key, it);
         foreach (SlotContainer obj in SlotContainers)
         {
             if (obj.AddItem(it))
             {
                 break;
             }
         }
         return(true);
     }
     return(false);
 }
Esempio n. 5
0
 public Item AddItem(Item.Items it)
 {
     if (!(Inventory.ContainsKey(it)))
     {
         Item item = new Item(it);
         Inventory.Add(it, item);
         foreach (SlotContainer obj in SlotContainers)
         {
             if (obj.AddItem(item))
             {
                 break;
             }
         }
         return(item);
     }
     return(null);
 }
Esempio n. 6
0
    public void PickupItem(Item.Items type)
    {
        // Find first item of same type in inventory
        int index = -1;

        for (int i = 0; i < inv.Count; i++)
        {
            if (inv[i].itemType != null && inv[i].itemType.type == type)
            {
                index = i;
                break;
            }
        }
        //index = -1;
        if (index > -1)
        {
            inv[index].count++;
        }
        else
        {
            // Else find first empty slot and add new item
            for (int i = 0; i < inv.Count; i++)
            {
                if (inv[i].itemType == null)
                {
                    index = i;
                    break;
                }
                if (index > -1)
                {
                    inv[index].itemType      = new Item();
                    inv[index].itemType.type = type;
                    inv[index].count         = 1;
                }
            }
        }
    }
Esempio n. 7
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);
            }
        }
Esempio n. 8
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);
        }