302 lines
11 KiB
C#
302 lines
11 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public enum WeaponType
|
|
{
|
|
// Two-Handed Weapons (Build-defining)
|
|
Staff,
|
|
Spear,
|
|
Scythe,
|
|
Hammer,
|
|
Bow,
|
|
Crossbow,
|
|
Axe,
|
|
|
|
// One-Handed Weapons (Flexible)
|
|
Sword,
|
|
Shield,
|
|
Dagger,
|
|
Book
|
|
}
|
|
|
|
public static class WeaponTypeExtensions
|
|
{
|
|
private static readonly HashSet<WeaponType> TwoHandedWeapons = new()
|
|
{
|
|
WeaponType.Staff,
|
|
WeaponType.Spear,
|
|
WeaponType.Scythe,
|
|
WeaponType.Hammer,
|
|
WeaponType.Bow,
|
|
WeaponType.Crossbow,
|
|
WeaponType.Axe
|
|
};
|
|
|
|
public static bool IsTwoHanded(this WeaponType weaponType)
|
|
{
|
|
return TwoHandedWeapons.Contains(weaponType);
|
|
}
|
|
|
|
public static bool IsOneHanded(this WeaponType weaponType)
|
|
{
|
|
return !IsTwoHanded(weaponType);
|
|
}
|
|
}
|
|
|
|
namespace Kryz.CharacterStats.Examples
|
|
{
|
|
public enum EquipmentType
|
|
{
|
|
Helmet,
|
|
Shoulder,
|
|
Chest,
|
|
Belt,
|
|
Legs,
|
|
Bracers,
|
|
Gloves,
|
|
Boots,
|
|
|
|
Weapon1,
|
|
Weapon2,
|
|
|
|
//Accessory,
|
|
//Amulet,
|
|
}
|
|
|
|
|
|
[CreateAssetMenu]
|
|
public class EquippableItem : Item
|
|
{
|
|
public int AttackDamageBonus;
|
|
public int SpellDamageBonus;
|
|
//no flat attack speed bonus, only %
|
|
public int CritChanceBonus;
|
|
public int CritDamageBonus;
|
|
|
|
public int MaxHealthBonus;
|
|
public int HealthRegenBonus;
|
|
public int MaxManaBonus;
|
|
public int ManaRegenBonus;
|
|
|
|
public int ArmorBonus;
|
|
public int MagicResistanceBonus;
|
|
//no flat dodge
|
|
//no flat block chance
|
|
//no flat block effectiveness
|
|
|
|
//no flat area
|
|
//no flat cdr
|
|
//no flat movespeed
|
|
|
|
//no flat rep gains
|
|
//no flat gold cost reduction
|
|
|
|
[Space]
|
|
public float AttackDamagePercentBonus;
|
|
public float SpellDamagePercentBonus;
|
|
|
|
public float AttackSpeedPercentBonus;
|
|
|
|
public float CritChancePercentBonus;
|
|
public float CritDamagePercentBonus;
|
|
|
|
public float MaxHealthPercentBonus;
|
|
public float HealthRegenPercentBonus;
|
|
public float MaxManaPercentBonus;
|
|
public float ManaRegenPercentBonus;
|
|
|
|
|
|
public float ArmorPercentBonus;
|
|
public float MagicResistancePercentBonus;
|
|
public float DodgeChancePercentBonus;
|
|
public float BlockChancePercentBonus;
|
|
public float BlockEffectivenessPercentBonus;
|
|
|
|
|
|
public float AreaEffectivenessPercentBonus;
|
|
public float CooldownReductionPercentBonus;
|
|
public float MovementSpeedPercentBonus;
|
|
public float ReputationGainIncreasePercentBonus;
|
|
public float GoldCostReductionPercentBonus;
|
|
|
|
|
|
public EquipmentType EquipmentType;
|
|
[Space]
|
|
// NEW: Add WeaponType for weapon items
|
|
public WeaponType WeaponType;
|
|
|
|
// Updated EquippableItemInstance helper properties
|
|
public bool IsWeapon => EquipmentType == EquipmentType.Weapon1 || EquipmentType == EquipmentType.Weapon2;
|
|
// NEW: Helper property to check if this weapon is two-handed
|
|
public bool IsTwoHandedWeapon => IsWeapon && WeaponType.IsTwoHanded();
|
|
|
|
// NEW: Helper property to check if this weapon is one-handed
|
|
public bool IsOneHandedWeapon => IsWeapon && WeaponType.IsOneHanded();
|
|
|
|
[Space]
|
|
public bool CraftableBase = false;
|
|
[Space(20f)]
|
|
[Header("Crafting-ish")]
|
|
public int MinAttackDamageBonus;
|
|
public int MaxAttackDamageBonus;
|
|
[Space]
|
|
public int MinSpellDamageBonus;
|
|
public int MaxSpellDamageBonus;
|
|
[Space]
|
|
public int MinCritChanceBonus;
|
|
public int MaxCritChanceBonus;
|
|
[Space]
|
|
public int MinCritDamageBonus;
|
|
public int MaxCritDamageBonus;
|
|
[Space]
|
|
public int MinMaxHealthBonus;
|
|
public int MaxMaxHealthBonus;
|
|
[Space]
|
|
public int MinArmorBonus;
|
|
public int MaxArmorBonus;
|
|
[Space]
|
|
public int MinMagicResistanceBonus;
|
|
public int MaxMagicResistanceBonus;
|
|
[Space]
|
|
[Space]
|
|
public float MinAttackDamagePercentBonus;
|
|
public float MaxAttackDamagePercentBonus;
|
|
[Space]
|
|
public float MinSpellDamagePercentBonus;
|
|
public float MaxSpellDamagePercentBonus;
|
|
[Space]
|
|
public float MinCritChancePercentBonus;
|
|
public float MaxCritChancePercentBonus;
|
|
[Space]
|
|
public float MinCritDamagePercentBonus;
|
|
public float MaxCritDamagePercentBonus;
|
|
[Space]
|
|
public float MinMaxHealthPercentBonus;
|
|
public float MaxMaxHealthPercentBonus;
|
|
[Space]
|
|
public float MinArmorPercentBonus;
|
|
public float MaxArmorPercentBonus;
|
|
[Space]
|
|
public float MinMagicResistancePercentBonus;
|
|
public float MaxMagicResistancePercentBonus;
|
|
[Space]
|
|
[Space]
|
|
[Tooltip("Can only increase up to this number of unique stats in a single item instance.")]
|
|
public int MaxTotalUniqueStatsIncreasedByStones;
|
|
|
|
|
|
public void Equip(PlayerCharacterStats c)
|
|
{
|
|
|
|
if (AttackDamageBonus != 0)
|
|
c.AttackDamage.AddModifier(new StatModifier(AttackDamageBonus, StatModType.Flat, this));
|
|
if (SpellDamageBonus != 0)
|
|
c.SpellDamage.AddModifier(new StatModifier(SpellDamageBonus, StatModType.Flat, this));
|
|
|
|
if (CritChanceBonus != 0)
|
|
c.CritChance.AddModifier(new StatModifier(CritChanceBonus, StatModType.Flat, this));
|
|
if (CritDamageBonus != 0)
|
|
c.CritDamage.AddModifier(new StatModifier(CritDamageBonus, StatModType.Flat, this));
|
|
|
|
if (MaxHealthBonus != 0)
|
|
c.MaxHealth.AddModifier(new StatModifier(MaxHealthBonus, StatModType.Flat, this));
|
|
if (HealthRegenBonus != 0)
|
|
c.HealthRegen.AddModifier(new StatModifier(HealthRegenBonus, StatModType.Flat, this));
|
|
|
|
if (MaxManaBonus != 0)
|
|
c.MaxMana.AddModifier(new StatModifier(MaxManaBonus, StatModType.Flat, this));
|
|
if (ManaRegenBonus != 0)
|
|
c.ManaRegen.AddModifier(new StatModifier(ManaRegenBonus, StatModType.Flat, this));
|
|
|
|
|
|
if (ArmorBonus != 0)
|
|
c.Armor.AddModifier(new StatModifier(ArmorBonus, StatModType.Flat, this));
|
|
if (MagicResistanceBonus != 0)
|
|
c.MagicResistance.AddModifier(new StatModifier(MagicResistanceBonus, StatModType.Flat, this));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (AttackDamagePercentBonus != 0)
|
|
c.AttackDamage.AddModifier(new StatModifier(AttackDamagePercentBonus, StatModType.PercentAdd, this));
|
|
if (SpellDamagePercentBonus != 0)
|
|
c.SpellDamage.AddModifier(new StatModifier(SpellDamagePercentBonus, StatModType.PercentAdd, this));
|
|
|
|
if (AttackSpeedPercentBonus != 0)
|
|
c.AttackSpeed.AddModifier(new StatModifier(AttackSpeedPercentBonus, StatModType.PercentAdd, this));
|
|
|
|
if (CritChancePercentBonus != 0)
|
|
c.CritChance.AddModifier(new StatModifier(CritChancePercentBonus, StatModType.PercentAdd, this));
|
|
if (CritDamagePercentBonus != 0)
|
|
c.CritDamage.AddModifier(new StatModifier(CritDamagePercentBonus, StatModType.PercentAdd, this));
|
|
|
|
|
|
|
|
if (MaxHealthPercentBonus != 0)
|
|
c.MaxHealth.AddModifier(new StatModifier(MaxHealthPercentBonus, StatModType.PercentAdd, this));
|
|
if (HealthRegenPercentBonus != 0)
|
|
c.HealthRegen.AddModifier(new StatModifier(HealthRegenPercentBonus, StatModType.PercentAdd, this));
|
|
|
|
if (MaxManaPercentBonus != 0)
|
|
c.MaxMana.AddModifier(new StatModifier(MaxManaPercentBonus, StatModType.PercentAdd, this));
|
|
if (ManaRegenPercentBonus != 0)
|
|
c.ManaRegen.AddModifier(new StatModifier(ManaRegenPercentBonus, StatModType.PercentAdd, this));
|
|
|
|
|
|
if (ArmorPercentBonus != 0)
|
|
c.Armor.AddModifier(new StatModifier(ArmorPercentBonus, StatModType.PercentAdd, this));
|
|
if (MagicResistancePercentBonus != 0)
|
|
c.MagicResistance.AddModifier(new StatModifier(MagicResistancePercentBonus, StatModType.PercentAdd, this));
|
|
if (DodgeChancePercentBonus != 0)
|
|
c.DodgeChance.AddModifier(new StatModifier(DodgeChancePercentBonus, StatModType.PercentAdd, this));
|
|
if (BlockChancePercentBonus != 0)
|
|
c.BlockChance.AddModifier(new StatModifier(BlockChancePercentBonus, StatModType.PercentAdd, this));
|
|
if (BlockEffectivenessPercentBonus != 0)
|
|
c.BlockEffectiveness.AddModifier(new StatModifier(BlockEffectivenessPercentBonus, StatModType.PercentAdd, this));
|
|
|
|
|
|
if (AreaEffectivenessPercentBonus != 0)
|
|
c.AreaEffectiveness.AddModifier(new StatModifier(AreaEffectivenessPercentBonus, StatModType.PercentAdd, this));
|
|
if (CooldownReductionPercentBonus != 0)
|
|
c.CooldownReduction.AddModifier(new StatModifier(CooldownReductionPercentBonus, StatModType.PercentAdd, this));
|
|
if (MovementSpeedPercentBonus != 0)
|
|
c.MovementSpeed.AddModifier(new StatModifier(MovementSpeedPercentBonus, StatModType.PercentAdd, this));
|
|
if (ReputationGainIncreasePercentBonus != 0)
|
|
c.ReputationGainIncrease.AddModifier(new StatModifier(ReputationGainIncreasePercentBonus, StatModType.PercentAdd, this));
|
|
if (GoldCostReductionPercentBonus != 0)
|
|
c.GoldCostReduction.AddModifier(new StatModifier(GoldCostReductionPercentBonus, StatModType.PercentAdd, this));
|
|
}
|
|
|
|
public void Unequip(PlayerCharacterStats c)
|
|
{
|
|
|
|
c.AttackDamage.RemoveAllModifiersFromSource(this);
|
|
c.SpellDamage.RemoveAllModifiersFromSource(this);
|
|
|
|
c.AttackSpeed.RemoveAllModifiersFromSource(this);
|
|
|
|
c.CritChance.RemoveAllModifiersFromSource(this);
|
|
c.CritDamage.RemoveAllModifiersFromSource(this);
|
|
|
|
c.MaxHealth.RemoveAllModifiersFromSource(this);
|
|
c.HealthRegen.RemoveAllModifiersFromSource(this);
|
|
c.MaxMana.RemoveAllModifiersFromSource(this);
|
|
c.ManaRegen.RemoveAllModifiersFromSource(this);
|
|
|
|
c.Armor.RemoveAllModifiersFromSource(this);
|
|
c.MagicResistance.RemoveAllModifiersFromSource(this);
|
|
c.DodgeChance.RemoveAllModifiersFromSource(this);
|
|
c.BlockChance.RemoveAllModifiersFromSource(this);
|
|
c.BlockEffectiveness.RemoveAllModifiersFromSource(this);
|
|
|
|
c.AreaEffectiveness.RemoveAllModifiersFromSource(this);
|
|
c.CooldownReduction.RemoveAllModifiersFromSource(this);
|
|
c.MovementSpeed.RemoveAllModifiersFromSource(this);
|
|
c.ReputationGainIncrease.RemoveAllModifiersFromSource(this);
|
|
c.GoldCostReduction.RemoveAllModifiersFromSource(this);
|
|
}
|
|
|
|
}
|
|
} |