private Item LoadDefensiveItem(ItemDefensiveStatsSaveData _data, ItemsDataBase _itemsDataBase) { DefensiveStatsAlteration.ModificationType statType = (DefensiveStatsAlteration.ModificationType)_data.statType; Item defItem = null; switch (statType) { case DefensiveStatsAlteration.ModificationType.HealthMax: defItem = _itemsDataBase.hpMax.FromSaveData(_data); break; case DefensiveStatsAlteration.ModificationType.HealthRegen: defItem = _itemsDataBase.hpRegeneration.FromSaveData(_data); break; case DefensiveStatsAlteration.ModificationType.StaminaMax: defItem = _itemsDataBase.staminaMax.FromSaveData(_data); break; case DefensiveStatsAlteration.ModificationType.StaminaRegen: defItem = _itemsDataBase.staminaRegeneration.FromSaveData(_data); break; case DefensiveStatsAlteration.ModificationType.Armor: defItem = _itemsDataBase.armor.FromSaveData(_data); break; default: break; } return(defItem); }
private Item LoadOffensiveItem(ItemOffensiveStatsSaveData _data, ItemsDataBase _itemsDataBase) { OffensiveStatsAlteration.ModificationType statType = (OffensiveStatsAlteration.ModificationType)_data.statType; Item offItem = null; switch (statType) { case OffensiveStatsAlteration.ModificationType.NormalDamage: offItem = _itemsDataBase.normalDamages.FromSaveData(_data); break; case OffensiveStatsAlteration.ModificationType.CapacityDamage: offItem = _itemsDataBase.capacitiesDamages.FromSaveData(_data); break; case OffensiveStatsAlteration.ModificationType.CooldownReduction: offItem = _itemsDataBase.cooldownReduction.FromSaveData(_data); break; case OffensiveStatsAlteration.ModificationType.CriticalDamage: offItem = _itemsDataBase.critDamages.FromSaveData(_data); break; case OffensiveStatsAlteration.ModificationType.CriticalChance: offItem = _itemsDataBase.critChances.FromSaveData(_data); break; default: break; } return(offItem); }
// Asigna un ítem a un determinado slot public void Equip(EquipableId equipableId, int slot) { Equipable current = (slot == 0) ? itemAt0 : itemAt1; if (current) { if (current.itemId == equipableId) { // Si ya tenemos equipado este item en el slot correspondiente no hacemos nada return; } } // Obtenemos una nueva instancia del equipable de la base de datos y lo asociamos a este jugador Equipable newEquipable = ItemsDataBase.GetInstance().GetEquipable(equipableId); newEquipable.transform.SetParent(transform, false); if (slot == 0) { itemAt0 = newEquipable; } else { itemAt1 = newEquipable; } }
public void LoadToEquipment(EquipmentUI _equipment, ItemsDataBase _itemsDataBase) { foreach (ItemDefensiveStatsSaveData itemData in itemDefensives) { Item toAdd = LoadDefensiveItem(itemData, _itemsDataBase); if (toAdd != null && toAdd.isSaved) { _equipment.EquipItemTo(toAdd, toAdd.slotIndex); } } foreach (ItemOffensiveStatsSaveData itemData in itemOffensives) { Item toAdd = LoadOffensiveItem(itemData, _itemsDataBase); if (toAdd != null && toAdd.isSaved) { _equipment.EquipItemTo(toAdd, toAdd.slotIndex); } } foreach (ItemCapacitySaveData itemData in itemCapacities) { Item toAdd = LoadCapacityItem(itemData, _itemsDataBase); if (toAdd != null && toAdd.isSaved) { _equipment.EquipItemTo(toAdd, toAdd.slotIndex); } } }
public void LoadToInventory(Inventory _inventory, ItemsDataBase _itemsDataBase) { _inventory.AddMoney(moneyAmount); int lineToAdd = ((slotAvailable - _inventory.slotsAvailable) / _inventory.MinItemNumber); _inventory.UnlockInventorySlots(lineToAdd); foreach (ItemDefensiveStatsSaveData itemData in itemDefensives) { Item toAdd = LoadDefensiveItem(itemData, _itemsDataBase); if (toAdd != null && toAdd.isSaved) { _inventory.AddItem(toAdd, toAdd.slotIndex); } } foreach (ItemOffensiveStatsSaveData itemData in itemOffensives) { Item toAdd = LoadOffensiveItem(itemData, _itemsDataBase); if (toAdd != null && toAdd.isSaved) { _inventory.AddItem(toAdd, toAdd.slotIndex); } } foreach (ItemCapacitySaveData itemData in itemCapacities) { Item toAdd = LoadCapacityItem(itemData, _itemsDataBase); if (toAdd != null && toAdd.isSaved) { _inventory.AddItem(toAdd, toAdd.slotIndex); } } }
private void Awake() { if (instance != null) { Debug.LogWarning("Il y a plus d'une instance de ItemsDataBase dans la scène"); return; } instance = this; }
private void Awake() { if (instance != null) { Debug.Log("There more than one instance of ItemsDataBase"); return; } instance = this; }
private void LoadInventory() { foreach (EquipableId id in itemsInInventory) { GameObject item = Object.Instantiate(inventorySlotPrefab); item.transform.SetParent(gameObject.transform, false); item.GetComponent <Image>().sprite = ItemsDataBase.GetInstance().GetSprite(id); item.GetComponent <Button>().onClick.AddListener(delegate { inventorySystem.SelectItemAndCloseInventory(id); }); } }
public static void LoadEquipment(EquipmentUI _equipment, ItemsDataBase _itemsDataBase) { if (File.Exists(SAVE_PATH + EQUIPMENT_FILE)) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = new FileStream(SAVE_PATH + EQUIPMENT_FILE, FileMode.Open); EquipmentSaveData equipData = bf.Deserialize(file) as EquipmentSaveData; equipData.LoadToEquipment(_equipment, _itemsDataBase); file.Close(); } }
public static void LoadInventory(Inventory _inventory, ItemsDataBase _itemsDataBase) { if (File.Exists(SAVE_PATH + INVENTORY_FILE)) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = new FileStream(SAVE_PATH + INVENTORY_FILE, FileMode.Open); InventorySaveData invData = bf.Deserialize(file) as InventorySaveData; invData.LoadToInventory(_inventory, _itemsDataBase); file.Close(); } }
private Item LoadCapacityItem(ItemCapacitySaveData _data, ItemsDataBase _itemsDataBase) { Item skillItem = null; switch (_data.skillType) { case Item_Skill.SkillType.Fury: skillItem = _itemsDataBase.fury.FromSaveData(_data); break; case Item_Skill.SkillType.Shield: skillItem = _itemsDataBase.shield.FromSaveData(_data); break; case Item_Skill.SkillType.SonicBoom: skillItem = _itemsDataBase.sonicBoom.FromSaveData(_data); break; default: break; } return(skillItem); }
public void LoadDataBases() { itemsDataBase = Resources.Load <ItemsDataBase>("Data/Items/ItemDataBase"); difficultyDataBase = Resources.Load <DifficultyDataBase>("Data/DifficultyData"); }
public void ChangeIcon(EquipableId id) { image.sprite = ItemsDataBase.GetInstance().GetSprite(id); }