Exemplo n.º 1
0
        public Inventory()
        {
            _Consumable = new Consumable[20];
            _Equipment  = new Equipment[20];
            _ConsumableNextFreeIndex = 0;
            _EquipmentNextFreeIndex  = 0;
            _ItemFactory             = new ItemFactory();

            for (int x = 0; x < 20; x++)
            {
                _Consumable[x] = new NullItemConsumable();
                _Equipment[x]  = new NullItemEquipment();
            }
            initialInventoryPopulate();
        }
Exemplo n.º 2
0
        public Item removeFromConsumable(int indexOfItem)
        {
            if (_ConsumableNextFreeIndex == 0)
            {
                return(new NullItemConsumable());
            }

            else
            {
                Item item = findConsumableByIndex(indexOfItem);
                _Consumable[indexOfItem] = new NullItemConsumable();
                _ConsumableNextFreeIndex--;
                return(item);
            }
        }
        //-----------------------------//
        //public ItemFactory()
        //{
        //    if (randomNumber == null)
        //    {
        //        randomNumber = new Random();
        //    }
        //}

        public Consumable createConsumable(int tierLevel)
        {
            Consumable newItem = new NullItemConsumable();

            if (tierLevel == 1)
            {
                int choice = _randomNumber.Next(9) + 1;

                if (choice == 1)
                {
                    return(new LesserPotionOfHealth());
                }

                else if (choice == 2)
                {
                    return(new LesserPotionOfMana());
                }

                else if (choice == 3)
                {
                    return(new LesserPotionOfDefense());
                }

                else if (choice == 4)
                {
                    return(new LesserPotionOfResistance());
                }

                else if (choice == 5)
                {
                    return(new LesserPotionOfMagic());
                }

                else if (choice == 6)
                {
                    return(new LesserPotionOfPower());
                }

                else if (choice == 7)
                {
                    return(new LesserPotionOfRejuvenation());
                }

                else if (choice == 8)
                {
                    return(new LesserPotionOfHealthRegeneration());
                }

                else if (choice == 9)
                {
                    return(new LesserPotionOfManaRegeneration());
                }
            }

            else if (tierLevel == 2)
            {
                int choice = _randomNumber.Next(9) + 1;

                if (choice == 1)
                {
                    return(new PotionOfDefense());
                }

                else if (choice == 2)
                {
                    return(new PotionOfResistance());
                }

                else if (choice == 3)
                {
                    return(new PotionOfHealth());
                }

                else if (choice == 4)
                {
                    return(new PotionOfMana());
                }

                else if (choice == 5)
                {
                    return(new PotionOfPower());
                }

                else if (choice == 6)
                {
                    return(new PotionOfMagic());
                }

                else if (choice == 7)
                {
                    return(new PotionOfHealthRegeneration());
                }

                else if (choice == 8)
                {
                    return(new PotionOfManaRegeneration());
                }

                else if (choice == 9)
                {
                    return(new PotionOfRejuvenation());
                }
            }

            else if (tierLevel == 3)
            {
                int choice = _randomNumber.Next(9) + 1;

                if (choice == 1)
                {
                    return(new GreaterPotionOfHealth());
                }

                else if (choice == 2)
                {
                    return(new GreaterPotionOfMana());
                }

                else if (choice == 3)
                {
                    return(new GreaterPotionOfDefense());
                }

                else if (choice == 4)
                {
                    return(new GreaterPotionOfResistance());
                }

                else if (choice == 5)
                {
                    return(new GreaterPotionOfMagic());
                }

                else if (choice == 6)
                {
                    return(new GreaterPotionOfPower());
                }

                else if (choice == 7)
                {
                    return(new GreaterPotionOfHealthRegeneration());
                }

                else if (choice == 8)
                {
                    return(new GreaterPotionOfManaRegeneration());
                }

                else if (choice == 9)
                {
                    return(new GreaterPotionOfRejuvenation());
                }
            }

            return(newItem);
        }