//to add something we must find the index availables for such item (if there are only //30 items and we removed 3, we cannot go to the 31 after deleting because we are //limiting that dictionary to a fixed size public bool AddToInventory(InfoItem i) { if (_itemsInInventory.Count >= _maxItemsInPossesion) { return(false); } int index = 0; if (_freeIntItems.Count > 0) { index = _freeIntItems[0]; _freeIntItems.RemoveAt(0); } else { index = _itemsInInventory.Count; } if (i.TypeItem == TypeItem.Important) { _inventoryPanel.AddToInventory(InventorySlotType.Important, i.ModelName, index); } else { _inventoryPanel.AddToInventory(InventorySlotType.Item, i.ModelName, index); } _itemsInInventory.Add(index, i); return(true); }
private void PopulateDrop(TypeDrop actualDrop) { switch (actualDrop) { case TypeDrop.Gold: { StatsManager.Instance.AddGold(CostDrop()); break; } case TypeDrop.Weapon: { InfoWeapon iw = new InfoWeapon(); iw.SetValues("Weapon", (float)RarityStats(), false, WeaponType.SimpleSword, WeaponEffect(), actualRarityDrop, 1f, CostDrop(), "/Weapons/" + IconNameWeapon()); if (InventoryManager.Instance.AvailableWeaponSpace > 0) { InventoryManager.Instance.AddToInventory(iw); } else { StatsManager.Instance.AddGold(iw.SellValue); } break; } case TypeDrop.Armor: { InfoArmor ia = new InfoArmor(); EquippedInSlot slot = SlotArmor(); Stats stats = ArmorStats(); ia.SetValues("Armadura", false, slot, CostDrop(), "Some description randomly to be implemented", stats, "/Armors/" + slot.ToString() + "/" + IconNameArmor(slot)); if (InventoryManager.Instance.AvailableArmorSpace > 0) { InventoryManager.Instance.AddToInventory(ia); } else { StatsManager.Instance.AddGold(ia.SellValue); } break; } case TypeDrop.Item: { InfoItem ii = new InfoItem(); ii.SetValues("Item", TypeItem.Other, "Some description randomly generated", ConsumeEffect.None, CostDrop(), 1, "/Items/" + IconNameItem()); if (InventoryManager.Instance.AvailableItemSpace > 0) { InventoryManager.Instance.AddToInventory(ii); } else { StatsManager.Instance.AddGold(ii.SellValue); } break; } } }
/********************************METHODS OF CLASS****************************************/ public InfoItemsDatabase GetAllItemsInInventory() { InfoItem[] items = new InfoItem[_itemsInInventory.Count]; _itemsInInventory.Values.CopyTo(items, 0); InfoItemsDatabase iid = new InfoItemsDatabase(); foreach (InfoItem ii in items) { iid.DataBase.Add(ii); } return(iid); }
private void BattleEnded() { if (_playerIsDead) { _expGained = Mathf.RoundToInt(_expGained * 0.5f); _goldGained = Mathf.RoundToInt(_goldGained * 0.5f); } if (_bossBattle == true) { if (!(InventoryManager.Instance.PlayerHas("The Golden Key") || StatsManager.Instance.InfoPlayer.IsGameEnded == true)) { InfoItem key = new InfoItem(); key.SetValues("The Golden Key", TypeItem.Important, "A forgotten key, cursed, everyone who touched it before is now dead", ConsumeEffect.None, 0, 1, "/Items/Important/GoldenKey"); if (InventoryManager.Instance.AvailableItemSpace > 0) { InventoryManager.Instance.AddToInventory(key); } } _expGained = Mathf.RoundToInt(_expGained * _playerCombat.LuckAfterBattle); _goldGained = Mathf.RoundToInt(_goldGained * _playerCombat.LuckAfterBattle); } DungeonManager.Instance.CombatEnded(_enemiesInCombat.Count, _playerIsDead); _actualTurn = ActualTurn.None; _turnInProgress = false; _playerIsDead = false; _playerTurnInProgress = false; _combatUpdater.ResetSlots(); _enemiesAlive.Clear(); _enemiesInCombat.Clear(); _enemiesAddToBattle.Clear(); _bossBattle = false; _preloadTurn = ActualTurn.None; _startedBattle = false; _canEnemiesBeAdded = false; _enemyAttacked = -1; _enemyDoingAction = -1; GameManager.Instance.SwapContextToDungeonFromCombat(); }