public float GetItemAttribute(TypeOfAttributes typeOfAttributes) { switch (typeOfAttributes) { case TypeOfAttributes.HEALTH: return(health); case TypeOfAttributes.SHIELD: return(shield); case TypeOfAttributes.ATTACK: return(attackPower); case TypeOfAttributes.DEFENCE: return(defensePower); case TypeOfAttributes.CRITCHANCE: return(critChance); case TypeOfAttributes.CRITMULTIPLIER: return(critMultiplier); case TypeOfAttributes.SPEED: return(speed); default: return(0); } }
/// <summary> /// Get player attribute scriptable object /// </summary> public AttributeUI_SO GetAttribute(TypeOfAttributes typeOfAttributes) { foreach (var item in attributes) { if (item.attributeType == typeOfAttributes) { return(item); } } return(null); }
/// <summary> /// Set player attribute level in player data /// </summary> public void AddAttributeLevel(TypeOfAttributes typeOfAttributes) { for (int i = 0; i < playerData.playerAttributes.Count; i++) { TypeOfAttributes key = playerData.playerAttributes.ElementAt(i).Key; if (key == typeOfAttributes) { playerData.playerAttributes[key]++; return; } } }
/// <summary> /// Get total player attribute /// </summary> public float GetTotalAttributeLevel(TypeOfAttributes typeOfAttributes) { foreach (var item in playerData.playerAttributes) { if (item.Key == typeOfAttributes) { float baseStat = GetAttributeLevel(item.Key, out bool maxed); float weaponStat = EquipmentManager.Instance.GetEquipmentStat(item.Key); return(baseStat + weaponStat); } } return(0); }
/// <summary> /// Get player attribute level from player data /// </summary> public float GetAttributeLevel(TypeOfAttributes typeOfAttributes, out bool maxed) { foreach (var item in playerData.playerAttributes) { if (item.Key == typeOfAttributes) { float value = playerStat.GetDefaultStat(typeOfAttributes) + (item.Value * GetAttribute(typeOfAttributes).addValue); maxed = (value >= GetAttribute(typeOfAttributes).maxValue); return(value); } } maxed = false; return(0); }
/// <summary> /// get requipment stat total /// </summary> public float GetEquipmentStat(TypeOfAttributes typeOfAttributes) { float sum = 0; if (equipmentItems.Count > 0) { foreach (var item in equipmentItems) { sum += InventoryManager.Instance.items[item].GetItemAttribute(typeOfAttributes); } } return(sum); }