/// <summary> /// Gets the total for a stat including its base value and all applicable modifiers /// </summary> /// <param name="stat">What stat to grab</param> /// <returns></returns> public int GetEffectiveStat(Stats stat) { int value = stats[stat]; foreach (Equippable i in equipment) { if (i != null) { EquippableBase temp = ((EquippableBase)Registry.ItemRegistry[i.Name]); if (temp.stats.ContainsKey(stat)) { value += temp.stats[stat]; } } } if (tempStats != null) { StatMod s = tempStats.GetStatMod(stat); value += s.flatChange; value = Mathf.RoundToInt(value * s.multiplier); } if (stat == Stats.MaxMove && value < 0) { value = 0; } return(value); }
/// <summary> /// Displays and updates the item info card if the player is mousing over an item /// </summary> /// <param name="index">The index of the item you are mousing over</param> public override void MouseOverItem(int index) { Text[] children = itemInfo.transform.GetComponentsInChildren <Text>(); itemInfo.SetActive(true); itemInfo.transform.position = Input.mousePosition + new Vector3(2, -2, 0); itemInfo.transform.GetChild(0).GetComponent <Text>().text = itemList[index].Name; //Has to display extra stat information if the item is an equippable if (Registry.ItemRegistry[itemList[index].Name] is EquippableBase) { EquippableBase item = ((EquippableBase)Registry.ItemRegistry[itemList[index].Name]); children[1].text = "Equipment type: " + item.equipSlot.ToString(); foreach (Stats stat in (Stats[])Enum.GetValues(typeof(Stats))) { if (item.stats.ContainsKey(stat)) { string statName = GameStorage.StatToString(stat); bool isPercent = statName.Contains("Effectiveness") || statName.Contains("Receptiveness") || statName.Contains("Lifesteal") || statName.Contains("Chance"); children[1].text += "\n" + statName + ": " + item.stats[stat] + (isPercent ? "%" : ""); } } } else { children[1].text = itemList[index].amount + "/" + Registry.ItemRegistry[itemList[index].Name].MaxStack; } children[1].text += "\n" + Registry.ItemRegistry[itemList[index].Name].FlavorText; children[1].text += "\nSells for: " + Registry.ItemRegistry[itemList[index].Name].SellAmount; base.MouseOverItem(index); }
/// <summary> /// Updates the info panel to show a comparison between the equipped itm for a slot and the unequipped one /// </summary> /// <param name="equipped">The equipped item</param> /// <param name="inInvName">Name of the unequipped item</param> private void UpdateComparison(EquippableBase equipped, string inInvName) { Text[] children = itemInfo.transform.GetComponentsInChildren <Text>(); UpdateBaseInfo(children, inInvName); EquippableBase inInv = ((EquippableBase)Registry.ItemRegistry[inInvName]); //Removes the previous info texts for (int i = 2; i < children.Length; i++) { Destroy(itemInfo.transform.GetChild(i).gameObject); } foreach (Stats stat in (Stats[])Enum.GetValues(typeof(Stats))) { if (equipped.stats.ContainsKey(stat) || inInv.stats.ContainsKey(stat)) { Text text = Instantiate(itemInfoTextPrefab, itemInfo.transform).GetComponent <Text>(); string statName = GameStorage.StatToString(stat); bool isPercent = statName.Contains("Effectiveness") || statName.Contains("Receptiveness") || statName.Contains("Lifesteal") || statName.Contains("Chance"); int equippedStat = equipped.stats.ContainsKey(stat) ? equipped.stats[stat] : 0; int inInvStat = inInv.stats.ContainsKey(stat) ? inInv.stats[stat] : 0; text.text = statName + ": " + ((isPercent && equippedStat > 0) ? "+" : "") + equippedStat + (isPercent ? "%" : "") + " -> " + ((isPercent && inInvStat > 0) ? "+" : "") + inInvStat + (isPercent ? "%" : ""); } } Text flavorText = Instantiate(itemInfoTextPrefab, itemInfo.transform).GetComponent <Text>(); flavorText.text = inInv.FlavorText; Text sellText = Instantiate(itemInfoTextPrefab, itemInfo.transform).GetComponent <Text>(); sellText.text = "Sells for: " + inInv.SellAmount; }
public Equippable(EquippableBase equippableBase) : base(equippableBase) { EnhancementCount = 0; }
/// <summary> /// Compares two item, used when sorting the inventory /// Sorting order: /// Materials (sorted by amount then name if same amount) -> Battle Item (sorted by amount then name if same amount) -> Equippable (sorted by slot then total strength) /// </summary> /// <param name="other">The item to compare this one to</param> /// <returns>1 if the other item is higher up in order, -1 if this item is higher up in order</returns> public int CompareTo(StoredItem other) { if (Registry.ItemRegistry[name] is EquippableBase) { EquippableBase item1 = ((EquippableBase)Registry.ItemRegistry[name]); if (Registry.ItemRegistry[other.name] is EquippableBase) { EquippableBase item2 = ((EquippableBase)Registry.ItemRegistry[other.name]); if (item1.equipSlot > item2.equipSlot) { return(1); } else if (item1.equipSlot < item2.equipSlot) { return(-1); } else { if (item1.subType > item2.subType) { return(1); } else if (item1.subType < item2.subType) { return(-1); } if (item1.TotalStats > item2.TotalStats) { return(-1); } else if (item1.TotalStats < item2.TotalStats) { return(1); } else { return(name.CompareTo(other.name)); } } } else if (Registry.ItemRegistry[other.name] is BattleItemBase) { return(1); } else { return(1); } } else if (Registry.ItemRegistry[name] is BattleItemBase) { if (Registry.ItemRegistry[other.name] is EquippableBase) { return(-1); } else if (Registry.ItemRegistry[other.name] is BattleItemBase) { if (amount > other.amount) { return(-1); } else if (amount < other.amount) { return(1); } else { //for now just sorting by name, might sort by effect at a later junction return(name.CompareTo(other.name)); } } else { return(1); } } else { if (Registry.ItemRegistry[other.name] is EquippableBase) { return(-1); } else if (Registry.ItemRegistry[other.name] is BattleItemBase) { return(-1); } else { if (amount > other.amount) { return(-1); } else if (amount < other.amount) { return(1); } else { return(name.CompareTo(other.name)); } } } }