Ejemplo n.º 1
0
        public CombatStats GetCombinedCombatStats()
        {
            CombatStats combined = new CombatStats();

            combined.Vitality     = BaseStats.Vitality + InvestedStats.Vitality;
            combined.Inteligence  = BaseStats.Inteligence + InvestedStats.Inteligence;
            combined.Strength     = BaseStats.Strength + InvestedStats.Strength;
            combined.Agility      = BaseStats.Agility + InvestedStats.Agility;
            combined.MeleeDefence = BaseStats.MeleeDefence + InvestedStats.MeleeDefence;
            combined.RangeDefence = BaseStats.RangeDefence + InvestedStats.RangeDefence;
            combined.MagicDefence = BaseStats.MagicDefence + InvestedStats.MagicDefence;

            for (int i = 0; i < _equipment.Length; i++)
            {
                if (_equipment[i] != 0)
                {
                    ItemData data = ItemData.GetItemData(_equipment[i] - 1);
                    combined.Vitality     += (int)data.GetItemStat("VitalityBonus");
                    combined.Inteligence  += (int)data.GetItemStat("InteligenceBonus");
                    combined.Strength     += (int)data.GetItemStat("StrengthBonus");
                    combined.Agility      += (int)data.GetItemStat("AgilityBonus");
                    combined.MeleeDefence += (int)data.GetItemStat("MeleeDefenceBonus");
                    combined.RangeDefence += (int)data.GetItemStat("RangeDefenceBonus");
                    combined.MagicDefence += (int)data.GetItemStat("MagicDefenceBonus");
                }
            }

            return(combined);
        }
Ejemplo n.º 2
0
        public bool SpaceInInventory(int itemID, int count)
        {
            ItemData data = ItemData.GetItemData(itemID);

            if (data != null)
            {
                int canAdd = 0;
                for (int i = 0; i < _inventory.Count; i++)
                {
                    if (_inventory[i].Item1 == itemID)
                    {
                        canAdd += data.GetMaxStack() - _inventory[i].Item2;
                    }
                }

                int freeSlots = InventorySize - _inventory.Count;
                for (int i = 0; i < freeSlots; i++)
                {
                    canAdd += data.GetMaxStack();
                }

                if (canAdd >= count)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
            public override string ToString()
            {
                string   name;
                ItemData data = ItemData.GetItemData(ItemID);

                if (data != null)
                {
                    name = data.Name;
                }
                else
                {
                    name = "None";
                }
                name += ", " + Cost;
                return(name);
            }
Ejemplo n.º 4
0
            public override string ToString()
            {
                string text = "";

                ItemData data = ItemData.GetItemData(ItemID);

                if (data != null)
                {
                    text += "Item: " + data.Name;
                }
                else
                {
                    text += "Item: None";
                }
                text += " {" + ItemCount;
                text += ", " + Chance + "}";

                return(text);
            }
Ejemplo n.º 5
0
            public List <string> GetItemRewardNames()
            {
                List <string> names = new List <string>();

                for (int i = 0; i < ItemRewards.Count; i++)
                {
                    int      itemID   = ItemRewards[i].Item1;
                    ItemData itemData = ItemData.GetItemData(itemID);
                    string   itemName;
                    if (itemData == null)
                    {
                        itemName = "None";
                    }
                    else
                    {
                        itemName = itemData.Name;
                    }
                    names.Add(itemName + ", " + ItemRewards[i].Item2);
                }
                return(names);
            }
Ejemplo n.º 6
0
 public int ConsumeAmmo()
 {
     if (_equipedAmmo.Item1 != -1)
     {
         ItemData data       = ItemData.GetItemData(_equipedAmmo.Item1);
         int      projectile = (int)data.GetItemStat("ProjectileID");
         if (projectile != -1)
         {
             int amount = _equipedAmmo.Item2 - 1;
             if (amount == 0)
             {
                 _equipedAmmo = new Tuple <int, int>(-1, 0);
             }
             else
             {
                 _equipedAmmo = new Tuple <int, int>(_equipedAmmo.Item1, amount);
             }
             return(projectile);
         }
     }
     return(-1);
 }
Ejemplo n.º 7
0
        public void RemoveInventoryItem(int itemID, int count)
        {
            if (count < 1 || itemID < 0)
            {
                return;
            }
            ItemData data = ItemData.GetItemData(itemID);

            if (data == null)
            {
                return;
            }

            for (int i = 0; i < _inventory.Count; i++)
            {
                if (_inventory[i].Item1 == itemID)
                {
                    if (_inventory[i].Item2 >= count)
                    {
                        int remainder = _inventory[i].Item2 - count;
                        if (remainder == 0)
                        {
                            _inventory.RemoveAt(i);
                        }
                        else
                        {
                            _inventory[i] = new Tuple <int, int>(itemID, remainder);
                        }
                        return;
                    }
                    else
                    {
                        count -= _inventory[i].Item2;
                        _inventory.RemoveAt(i);
                        i--;
                    }
                }
            }
        }
Ejemplo n.º 8
0
 public bool EquipItem(int itemIndex)
 {
     if (itemIndex >= 0 && itemIndex < _inventory.Count)
     {
         ItemData data = ItemData.GetItemData(_inventory[itemIndex].Item1);
         if (data.Equipable())
         {
             EquipmentSlot slot = (EquipmentSlot)data.GetItemStat("EquipmentSlot");
             int           prev = GetEquipedItemID(slot);
             EquipItem(slot, _inventory[itemIndex].Item1);
             if (prev != -1)
             {
                 _inventory[itemIndex] = new Tuple <int, int>(prev, 1);
             }
             else
             {
                 _inventory.RemoveAt(itemIndex);
             }
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 9
0
 public void EquipAmmo(int itemIndex)
 {
     if (itemIndex >= 0 && itemIndex < _inventory.Count)
     {
         Tuple <int, int> itemInfo = _inventory[itemIndex];
         ItemData         data     = ItemData.GetItemData(itemInfo.Item1);
         if (data.GetItemType() == ItemData.ItemType.Ammo)
         {
             if (_equipedAmmo.Item1 == -1)
             {
                 _equipedAmmo = itemInfo;
                 _inventory.RemoveAt(itemIndex);
             }
             else if (_equipedAmmo.Item1 == itemInfo.Item1)
             {
                 int max    = data.GetMaxStack() - _equipedAmmo.Item2;
                 int amount = itemInfo.Item2 > max ? max : itemInfo.Item2;
                 _equipedAmmo = new Tuple <int, int>(_equipedAmmo.Item1, _equipedAmmo.Item2 + amount);
                 int remainder = itemInfo.Item2 - amount;
                 if (remainder == 0)
                 {
                     _inventory.RemoveAt(itemIndex);
                 }
                 else
                 {
                     _inventory[itemIndex] = new Tuple <int, int>(itemInfo.Item1, itemInfo.Item2 - amount);
                 }
             }
             else
             {
                 _inventory.RemoveAt(itemIndex);
                 _inventory.Add(_equipedAmmo);
                 _equipedAmmo = itemInfo;
             }
         }
     }
 }
Ejemplo n.º 10
0
            public int AddItem(int itemID, int count)
            {
                if (count < 1 || itemID < 0)
                {
                    return(0);
                }

                ItemData data = ItemData.GetItemData(itemID);

                if (data == null)
                {
                    return(0);
                }
                if (data.GetItemType() == ItemData.ItemType.Quest)
                {
                    return(0);
                }

                int max         = data.GetMaxStack();
                int added       = 0;
                int amountToAdd = count;

                for (int i = 0; i < _items.Count; i++)
                {
                    if (_items[i].Item1 == itemID)
                    {
                        if (_items[i].Item2 < max)
                        {
                            int amountCanAdd = max - _items[i].Item2;
                            if (amountToAdd <= amountCanAdd)
                            {
                                _items[i]   = new Tuple <int, int>(itemID, _items[i].Item2 + amountToAdd);
                                added      += amountToAdd;
                                amountToAdd = 0;
                            }
                            else
                            {
                                _items[i]    = new Tuple <int, int>(itemID, _items[i].Item2 + amountCanAdd);
                                added       += amountCanAdd;
                                amountToAdd -= amountCanAdd;
                            }
                        }
                    }

                    if (amountToAdd < 1)
                    {
                        break;
                    }
                }

                while (amountToAdd > 0)
                {
                    if (_items.Count < MaxItems)
                    {
                        if (amountToAdd <= max)
                        {
                            _items.Add(new Tuple <int, int>(itemID, amountToAdd));
                            added += amountToAdd;
                            break;
                        }
                        else
                        {
                            _items.Add(new Tuple <int, int>(itemID, max));
                            added       += max;
                            amountToAdd -= max;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                return(added);
            }