Compare commits
2 Commits
93cbc4a3e5
...
master
Author | SHA1 | Date | |
---|---|---|---|
af23dcc963 | |||
3871cba753 |
@@ -130,19 +130,20 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
attributes:
|
attributes:
|
||||||
health: 10
|
serializedAttributes:
|
||||||
maxHealth: 10
|
- key: 0
|
||||||
moveSpeed: 2
|
- key: 1
|
||||||
luck: 0
|
- key: 2
|
||||||
armor: 0
|
- key: 3
|
||||||
level: 1
|
- key: 4
|
||||||
experience: 0
|
- key: 5
|
||||||
baseExperienceToLevelUp: 100
|
- key: 6
|
||||||
damage: 1
|
- key: 7
|
||||||
rangedDamage: 1
|
- key: 8
|
||||||
meleeDamage: 1
|
- key: 9
|
||||||
attackRange: 1
|
- key: 10
|
||||||
attackSpeed: 1
|
- key: 11
|
||||||
|
- key: 12
|
||||||
--- !u!114 &9093693903318130491
|
--- !u!114 &9093693903318130491
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@@ -7087,20 +7087,281 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 44b572240c4243c9954bd19967bfeb64, type: 3}
|
m_Script: {fileID: 11500000, guid: 44b572240c4243c9954bd19967bfeb64, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
attributes:
|
serializationData:
|
||||||
health: 100
|
SerializedFormat: 2
|
||||||
maxHealth: 100
|
SerializedBytes:
|
||||||
moveSpeed: 5
|
ReferencedUnityObjects: []
|
||||||
luck: 0
|
SerializedBytesString:
|
||||||
armor: 0
|
Prefab: {fileID: 0}
|
||||||
level: 1
|
PrefabModificationsReferencedUnityObjects: []
|
||||||
experience: 0
|
PrefabModifications: []
|
||||||
baseExperienceToLevelUp: 5
|
SerializationNodes:
|
||||||
damage: 1
|
- Name: attributes
|
||||||
rangedDamage: 1
|
Entry: 7
|
||||||
meleeDamage: 1
|
Data: 0|Data.CharacterAttributes, Assembly-CSharp
|
||||||
attackRange: 1
|
- Name: attributes
|
||||||
attackSpeed: 1
|
Entry: 7
|
||||||
|
Data: 1|System.Collections.Generic.Dictionary`2[[Data.Attribute, Assembly-CSharp],[Data.AttributeData`1[[System.Single,
|
||||||
|
mscorlib]], Assembly-CSharp]], mscorlib
|
||||||
|
- Name: comparer
|
||||||
|
Entry: 7
|
||||||
|
Data: 2|System.Collections.Generic.EnumEqualityComparer`1[[Data.Attribute,
|
||||||
|
Assembly-CSharp]], mscorlib
|
||||||
|
- Name:
|
||||||
|
Entry: 12
|
||||||
|
Data: 0
|
||||||
|
- Name:
|
||||||
|
Entry: 13
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 12
|
||||||
|
Data: 13
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 0
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 3|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 100
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 1
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 4|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 100
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 2
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 5|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 5
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 3
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 6|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 0
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 4
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 7|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 1
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 5
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 8|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 1
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 6
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 9|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 1
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 7
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 10|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 1
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 8
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 11|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 2
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 9
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 12|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 1
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 10
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 13|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 0
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 11
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 14|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 0
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 7
|
||||||
|
Data:
|
||||||
|
- Name: $k
|
||||||
|
Entry: 3
|
||||||
|
Data: 12
|
||||||
|
- Name: $v
|
||||||
|
Entry: 7
|
||||||
|
Data: 15|Data.AttributeData`1[[System.Single, mscorlib]], Assembly-CSharp
|
||||||
|
- Name: Value
|
||||||
|
Entry: 4
|
||||||
|
Data: 100
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 13
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
|
- Name:
|
||||||
|
Entry: 8
|
||||||
|
Data:
|
||||||
--- !u!4 &1261447604
|
--- !u!4 &1261447604
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@@ -4,6 +4,7 @@ using KBCore.Refs;
|
|||||||
using Pathfinding;
|
using Pathfinding;
|
||||||
using Systems;
|
using Systems;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Attribute = Data.Attribute;
|
||||||
|
|
||||||
namespace AI
|
namespace AI
|
||||||
{
|
{
|
||||||
@@ -27,7 +28,7 @@ namespace AI
|
|||||||
{
|
{
|
||||||
if (!target || !aiPath) return;
|
if (!target || !aiPath) return;
|
||||||
|
|
||||||
aiPath.maxSpeed = character.attributes.MoveSpeed;
|
aiPath.maxSpeed = character.attributes.Get(Attribute.MoveSpeed);
|
||||||
aiPath.destination = target.position;
|
aiPath.destination = target.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
Assets/Scripts/Data/Attribute.cs
Normal file
19
Assets/Scripts/Data/Attribute.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
namespace Data
|
||||||
|
{
|
||||||
|
public enum Attribute
|
||||||
|
{
|
||||||
|
Health,
|
||||||
|
MaxHealth,
|
||||||
|
MoveSpeed,
|
||||||
|
Luck,
|
||||||
|
Armor,
|
||||||
|
Damage,
|
||||||
|
RangedDamage,
|
||||||
|
MeleeDamage,
|
||||||
|
AttackRange,
|
||||||
|
AttackSpeed,
|
||||||
|
Level,
|
||||||
|
Experience,
|
||||||
|
BaseExperienceToNextLevel,
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Scripts/Data/Attribute.cs.meta
Normal file
3
Assets/Scripts/Data/Attribute.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9587f73172674bd1ad04d9e2327ad882
|
||||||
|
timeCreated: 1754103975
|
29
Assets/Scripts/Data/AttributeData.cs
Normal file
29
Assets/Scripts/Data/AttributeData.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Sirenix.OdinInspector;
|
||||||
|
using Sirenix.Serialization;
|
||||||
|
|
||||||
|
namespace Data
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class AttributeData<T>
|
||||||
|
{
|
||||||
|
[OdinSerialize]
|
||||||
|
public T Value { get; private set; }
|
||||||
|
public event Action<T> OnChanged;
|
||||||
|
|
||||||
|
public void Set(T value)
|
||||||
|
{
|
||||||
|
if (!EqualityComparer<T>.Default.Equals(Value, value))
|
||||||
|
{
|
||||||
|
Value = value;
|
||||||
|
OnChanged?.Invoke(Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Modify(Func<T, T> modifier)
|
||||||
|
{
|
||||||
|
Set(modifier(Value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Scripts/Data/AttributeData.cs.meta
Normal file
3
Assets/Scripts/Data/AttributeData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dd15401c68cc46338799a2718a5e6960
|
||||||
|
timeCreated: 1754104026
|
18
Assets/Scripts/Data/AttributeEntry.cs
Normal file
18
Assets/Scripts/Data/AttributeEntry.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using Sirenix.OdinInspector;
|
||||||
|
|
||||||
|
namespace Data
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class AttributeEntry
|
||||||
|
{
|
||||||
|
[HorizontalGroup("Split", 0.4f)]
|
||||||
|
[LabelWidth(100)]
|
||||||
|
public Attribute key;
|
||||||
|
|
||||||
|
[HorizontalGroup("Split", 0.6f)]
|
||||||
|
[LabelWidth(50)]
|
||||||
|
[InlineProperty]
|
||||||
|
public AttributeData<float> value;
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Scripts/Data/AttributeEntry.cs.meta
Normal file
3
Assets/Scripts/Data/AttributeEntry.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 056d8fc09bcc477fba9ff895cde4bb6e
|
||||||
|
timeCreated: 1754105855
|
@@ -1,11 +1,17 @@
|
|||||||
|
using System;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using Sirenix.Serialization;
|
using Sirenix.Serialization;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Data
|
namespace Data
|
||||||
{
|
{
|
||||||
public class Character : MonoBehaviour
|
public class Character : SerializedMonoBehaviour
|
||||||
{
|
{
|
||||||
[OdinSerialize, InlineProperty] public CharacterAttributes attributes = new();
|
[OdinSerialize, NonSerialized] public CharacterAttributes attributes = new();
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
attributes.Init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,348 +1,113 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using Sirenix.Serialization;
|
using Sirenix.Serialization;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Data
|
namespace Data
|
||||||
{
|
{
|
||||||
public enum Stat
|
|
||||||
{
|
|
||||||
Health,
|
|
||||||
MaxHealth,
|
|
||||||
MoveSpeed,
|
|
||||||
Luck,
|
|
||||||
Armor,
|
|
||||||
Damage,
|
|
||||||
RangedDamage,
|
|
||||||
MeleeDamage,
|
|
||||||
AttackRange,
|
|
||||||
AttackSpeed
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class CharacterAttributes
|
public class CharacterAttributes
|
||||||
{
|
{
|
||||||
[OdinSerialize] public float health = 100f;
|
private float lastLevel = 1f;
|
||||||
[OdinSerialize] public float maxHealth = 100f;
|
|
||||||
[OdinSerialize] public float moveSpeed = 5f;
|
|
||||||
[OdinSerialize] public float luck = 0f;
|
|
||||||
[OdinSerialize] public float armor = 0f;
|
|
||||||
[OdinSerialize] public int level = 1;
|
|
||||||
[OdinSerialize] public int experience = 0;
|
|
||||||
[OdinSerialize] public int baseExperienceToLevelUp = 100;
|
|
||||||
|
|
||||||
[OdinSerialize, PropertyTooltip("This is damage multiplier")]
|
[OdinSerialize, DictionaryDrawerSettings(KeyLabel = "Stat", ValueLabel = "Value", DisplayMode = DictionaryDisplayOptions.OneLine)]
|
||||||
public float damage = 1f;
|
private Dictionary<Attribute, AttributeData<float>> attributes = new();
|
||||||
|
|
||||||
[OdinSerialize, PropertyTooltip("This is damage multiplier for ranged attacks")]
|
|
||||||
public float rangedDamage = 1f;
|
|
||||||
|
|
||||||
[OdinSerialize, PropertyTooltip("This is damage multiplier for melee attacks")]
|
|
||||||
public float meleeDamage = 1f;
|
|
||||||
|
|
||||||
[OdinSerialize] public float attackRange = 16f;
|
|
||||||
[OdinSerialize] public float attackSpeed = 1f;
|
|
||||||
|
|
||||||
public event Action<float> OnHealthChanged;
|
|
||||||
public event Action<float> OnMaxHealthChanged;
|
|
||||||
public event Action<float> OnMoveSpeedChanged;
|
|
||||||
public event Action<float> OnLuckChanged;
|
|
||||||
public event Action<float> OnArmorChanged;
|
|
||||||
public event Action<float> OnDamageChanged;
|
|
||||||
public event Action<float> OnRangedDamageChanged;
|
|
||||||
public event Action<float> OnMeleeDamageChanged;
|
|
||||||
public event Action<float> OnAttackRangeChanged;
|
|
||||||
public event Action<float> OnAttackSpeedChanged;
|
|
||||||
|
|
||||||
public event Action<int> OnExperienceChanged;
|
|
||||||
public event Action<int> OnLevelChanged;
|
|
||||||
public event Action OnLevelUp;
|
public event Action OnLevelUp;
|
||||||
|
|
||||||
public float Health
|
public CharacterAttributes()
|
||||||
{
|
{
|
||||||
get => health;
|
foreach (Attribute attr in Enum.GetValues(typeof(Attribute)))
|
||||||
private set
|
|
||||||
{
|
{
|
||||||
if (Math.Abs(health - value) < float.Epsilon) return;
|
if (!attributes.ContainsKey(attr))
|
||||||
health = value;
|
attributes[attr] = new AttributeData<float>();
|
||||||
OnHealthChanged?.Invoke(health);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float MaxHealth
|
|
||||||
{
|
|
||||||
get => maxHealth;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (Math.Abs(maxHealth - value) < float.Epsilon) return;
|
|
||||||
maxHealth = value;
|
|
||||||
OnMaxHealthChanged?.Invoke(maxHealth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float MoveSpeed
|
|
||||||
{
|
|
||||||
get => moveSpeed;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (Math.Abs(moveSpeed - value) < float.Epsilon) return;
|
|
||||||
moveSpeed = value;
|
|
||||||
OnMoveSpeedChanged?.Invoke(moveSpeed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float Luck
|
|
||||||
{
|
|
||||||
get => luck;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (Math.Abs(luck - value) < float.Epsilon) return;
|
|
||||||
luck = value;
|
|
||||||
OnLuckChanged?.Invoke(luck);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float Armor
|
|
||||||
{
|
|
||||||
get => armor;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (Math.Abs(armor - value) < float.Epsilon) return;
|
|
||||||
armor = value;
|
|
||||||
OnArmorChanged?.Invoke(armor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float Damage
|
|
||||||
{
|
|
||||||
get => damage;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (Math.Abs(damage - value) < float.Epsilon) return;
|
|
||||||
damage = value;
|
|
||||||
OnDamageChanged?.Invoke(damage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float RangedDamage
|
|
||||||
{
|
|
||||||
get => rangedDamage;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (Math.Abs(rangedDamage - value) < float.Epsilon) return;
|
|
||||||
rangedDamage = value;
|
|
||||||
OnRangedDamageChanged?.Invoke(rangedDamage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float MeleeDamage
|
|
||||||
{
|
|
||||||
get => meleeDamage;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (Math.Abs(meleeDamage - value) < float.Epsilon) return;
|
|
||||||
meleeDamage = value;
|
|
||||||
OnMeleeDamageChanged?.Invoke(meleeDamage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float AttackRange
|
|
||||||
{
|
|
||||||
get => attackRange;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (Math.Abs(attackRange - value) < float.Epsilon) return;
|
|
||||||
attackRange = value;
|
|
||||||
OnAttackRangeChanged?.Invoke(attackRange);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float AttackSpeed
|
|
||||||
{
|
|
||||||
get => attackSpeed;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (Math.Abs(attackSpeed - value) < float.Epsilon) return;
|
|
||||||
attackSpeed = value;
|
|
||||||
OnAttackSpeedChanged?.Invoke(attackSpeed);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Experience
|
public float Get(Attribute attr) => attributes[attr].Value;
|
||||||
{
|
|
||||||
get => experience;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (experience == value) return;
|
|
||||||
experience = value;
|
|
||||||
OnExperienceChanged?.Invoke(experience);
|
|
||||||
|
|
||||||
if (experience >= ExperienceToNextLevel())
|
|
||||||
{
|
|
||||||
Level++;
|
|
||||||
experience -= ExperienceToNextLevel();
|
|
||||||
experience = Math.Min(0, experience);
|
|
||||||
}
|
|
||||||
else if (experience < 0)
|
|
||||||
{
|
|
||||||
experience = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Level
|
public void Set(Attribute attr, float value) => attributes[attr].Set(value);
|
||||||
{
|
|
||||||
get => level;
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
if (level == value) return;
|
|
||||||
level = value;
|
|
||||||
OnLevelChanged?.Invoke(level);
|
|
||||||
OnLevelUp?.Invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetHealth(float value)
|
|
||||||
{
|
|
||||||
Health = Math.Clamp(value, 0, MaxHealth);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetMaxHealth(float value)
|
|
||||||
{
|
|
||||||
MaxHealth = Math.Max(value, 0);
|
|
||||||
if (Health > MaxHealth)
|
|
||||||
{
|
|
||||||
Health = MaxHealth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetMoveSpeed(float value)
|
|
||||||
{
|
|
||||||
MoveSpeed = Math.Max(value, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetLuck(float value)
|
|
||||||
{
|
|
||||||
Luck = Math.Max(value, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetArmor(float value)
|
|
||||||
{
|
|
||||||
Armor = Math.Max(value, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetDamage(float value)
|
|
||||||
{
|
|
||||||
Damage = Math.Max(value, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRangedDamage(float value)
|
|
||||||
{
|
|
||||||
RangedDamage = Math.Max(value, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetMeleeDamage(float value)
|
|
||||||
{
|
|
||||||
MeleeDamage = Math.Max(value, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetAttackRange(float value)
|
|
||||||
{
|
|
||||||
AttackRange = Math.Max(value, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetAttackSpeed(float value)
|
|
||||||
{
|
|
||||||
AttackSpeed = Math.Max(value, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetExperience(int value)
|
|
||||||
{
|
|
||||||
Experience = Math.Max(value, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetLevel(int value)
|
public void Modify(Attribute attr, float delta) => attributes[attr].Set(attributes[attr].Value + delta);
|
||||||
{
|
|
||||||
Level = Math.Max(value, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ModifyHealth(float delta)
|
public void Subscribe(Attribute attr, Action<float> listener) => attributes[attr].OnChanged += listener;
|
||||||
{
|
|
||||||
SetHealth(Health + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ModifyMaxHealth(float delta)
|
|
||||||
{
|
|
||||||
SetMaxHealth(MaxHealth + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ModifyMoveSpeed(float delta)
|
|
||||||
{
|
|
||||||
SetMoveSpeed(MoveSpeed + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ModifyLuck(float delta)
|
|
||||||
{
|
|
||||||
SetLuck(Luck + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ModifyArmor(float delta)
|
|
||||||
{
|
|
||||||
SetArmor(Armor + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ModifyDamage(float delta)
|
|
||||||
{
|
|
||||||
SetDamage(Damage + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ModifyRangedDamage(float delta)
|
|
||||||
{
|
|
||||||
SetRangedDamage(RangedDamage + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ModifyMeleeDamage(float delta)
|
|
||||||
{
|
|
||||||
SetMeleeDamage(MeleeDamage + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ModifyAttackRange(float delta)
|
|
||||||
{
|
|
||||||
SetAttackRange(AttackRange + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ModifyAttackSpeed(float delta)
|
|
||||||
{
|
|
||||||
SetAttackSpeed(AttackSpeed + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ModifyExperience(int delta)
|
public void Unsubscribe(Attribute attr, Action<float> listener) => attributes[attr].OnChanged -= listener;
|
||||||
{
|
|
||||||
SetExperience(Experience + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ModifyLevel(int delta)
|
|
||||||
{
|
|
||||||
SetLevel(Level + delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
Health = MaxHealth = 100f;
|
Set(Attribute.Health, Get(Attribute.MaxHealth));
|
||||||
MoveSpeed = 5f;
|
Set(Attribute.MoveSpeed, 5f);
|
||||||
Luck = 0f;
|
Set(Attribute.Luck, 0f);
|
||||||
Armor = 0f;
|
Set(Attribute.Armor, 0f);
|
||||||
Damage = 1f;
|
Set(Attribute.Damage, 1f);
|
||||||
RangedDamage = 1f;
|
Set(Attribute.RangedDamage, 1f);
|
||||||
MeleeDamage = 1f;
|
Set(Attribute.MeleeDamage, 1f);
|
||||||
AttackRange = 16f;
|
Set(Attribute.AttackRange, 1f);
|
||||||
AttackSpeed = 1f;
|
Set(Attribute.AttackSpeed, 1f);
|
||||||
Level = 1;
|
Set(Attribute.Level, 1f);
|
||||||
Experience = 0;
|
Set(Attribute.Experience, 0f);
|
||||||
|
Set(Attribute.BaseExperienceToNextLevel, 100f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* health: 10
|
||||||
|
maxHealth: 10
|
||||||
|
moveSpeed: 2
|
||||||
|
luck: 0
|
||||||
|
armor: 0
|
||||||
|
level: 1
|
||||||
|
experience: 0
|
||||||
|
baseExperienceToLevelUp: 100
|
||||||
|
damage: 1
|
||||||
|
rangedDamage: 1
|
||||||
|
meleeDamage: 1
|
||||||
|
attackRange: 1
|
||||||
|
attackSpeed: 1
|
||||||
|
|
||||||
|
basic enemy btw
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
foreach (Attribute attr in Enum.GetValues(typeof(Attribute)))
|
||||||
|
{
|
||||||
|
if (!attributes.ContainsKey(attr))
|
||||||
|
attributes[attr] = new AttributeData<float>();
|
||||||
|
}
|
||||||
|
|
||||||
|
lastLevel = Get(Attribute.Level);
|
||||||
|
|
||||||
|
Subscribe(Attribute.Experience, OnExperienceChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int ExperienceToNextLevel()
|
private int ExperienceToNextLevel()
|
||||||
{
|
{
|
||||||
return (int)(baseExperienceToLevelUp * Math.Pow(Level, 2));
|
return (int)(Get(Attribute.BaseExperienceToNextLevel) * Math.Pow(Get(Attribute.Level), 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnExperienceChanged(float newExp)
|
||||||
|
{
|
||||||
|
var xpToNext = ExperienceToNextLevel();
|
||||||
|
|
||||||
|
if (newExp >= xpToNext)
|
||||||
|
{
|
||||||
|
Modify(Attribute.Level, 1f);
|
||||||
|
Set(Attribute.Experience, newExp - xpToNext);
|
||||||
|
}
|
||||||
|
else if (newExp < 0)
|
||||||
|
{
|
||||||
|
Set(Attribute.Experience, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
var currentLevel = Get(Attribute.Level);
|
||||||
|
if (currentLevel > lastLevel)
|
||||||
|
{
|
||||||
|
lastLevel = currentLevel;
|
||||||
|
OnLevelUp?.Invoke();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,13 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using Data;
|
using Data;
|
||||||
using Interfaces;
|
using Interfaces;
|
||||||
|
using Attribute = Data.Attribute;
|
||||||
|
|
||||||
namespace Modifiers
|
namespace Modifiers
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class FlatStatModifier : IStatModifier
|
public class FlatStatModifier : IStatModifier
|
||||||
{
|
{
|
||||||
public Stat stat;
|
public Attribute stat;
|
||||||
public float value;
|
public float value;
|
||||||
public string Description => BuildDescription();
|
public string Description => BuildDescription();
|
||||||
|
|
||||||
@@ -30,35 +31,35 @@ namespace Modifiers
|
|||||||
{
|
{
|
||||||
switch (stat)
|
switch (stat)
|
||||||
{
|
{
|
||||||
case Stat.Health:
|
case Attribute.Health:
|
||||||
attributes.ModifyHealth(value);
|
attributes.Modify(Attribute.Health, value);
|
||||||
break;
|
break;
|
||||||
case Stat.MaxHealth:
|
case Attribute.MaxHealth:
|
||||||
attributes.ModifyMaxHealth(value);
|
attributes.Modify(Attribute.MaxHealth, value);
|
||||||
break;
|
break;
|
||||||
case Stat.MoveSpeed:
|
case Attribute.MoveSpeed:
|
||||||
attributes.ModifyMoveSpeed(value);
|
attributes.Modify(Attribute.MoveSpeed, value);
|
||||||
break;
|
break;
|
||||||
case Stat.Luck:
|
case Attribute.Luck:
|
||||||
attributes.ModifyLuck(value);
|
attributes.Modify(Attribute.Luck, value);
|
||||||
break;
|
break;
|
||||||
case Stat.Armor:
|
case Attribute.Armor:
|
||||||
attributes.ModifyArmor(value);
|
attributes.Modify(Attribute.Armor, value);
|
||||||
break;
|
break;
|
||||||
case Stat.Damage:
|
case Attribute.Damage:
|
||||||
attributes.ModifyDamage(value);
|
attributes.Modify(Attribute.Damage, value);
|
||||||
break;
|
break;
|
||||||
case Stat.RangedDamage:
|
case Attribute.RangedDamage:
|
||||||
attributes.ModifyRangedDamage(value);
|
attributes.Modify(Attribute.RangedDamage, value);
|
||||||
break;
|
break;
|
||||||
case Stat.MeleeDamage:
|
case Attribute.MeleeDamage:
|
||||||
attributes.ModifyMeleeDamage(value);
|
attributes.Modify(Attribute.MeleeDamage, value);
|
||||||
break;
|
break;
|
||||||
case Stat.AttackRange:
|
case Attribute.AttackRange:
|
||||||
attributes.ModifyAttackRange(value);
|
attributes.Modify(Attribute.AttackRange, value);
|
||||||
break;
|
break;
|
||||||
case Stat.AttackSpeed:
|
case Attribute.AttackSpeed:
|
||||||
attributes.ModifyAttackSpeed(value);
|
attributes.Modify(Attribute.AttackSpeed, value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
|
@@ -3,6 +3,7 @@ using Data;
|
|||||||
using Interfaces;
|
using Interfaces;
|
||||||
using Systems;
|
using Systems;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Attribute = Data.Attribute;
|
||||||
|
|
||||||
namespace Modifiers
|
namespace Modifiers
|
||||||
{
|
{
|
||||||
@@ -19,7 +20,7 @@ namespace Modifiers
|
|||||||
public void OnKill(GameObject killer, GameObject victim)
|
public void OnKill(GameObject killer, GameObject victim)
|
||||||
{
|
{
|
||||||
killer.TryGetComponent(out Character character);
|
killer.TryGetComponent(out Character character);
|
||||||
character?.attributes.ModifyHealth(value);
|
character?.attributes.Modify(Attribute.Health, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Data;
|
using Data;
|
||||||
using Interfaces;
|
using Interfaces;
|
||||||
|
using Attribute = Data.Attribute;
|
||||||
|
|
||||||
namespace Modifiers
|
namespace Modifiers
|
||||||
{
|
{
|
||||||
@@ -9,51 +10,20 @@ namespace Modifiers
|
|||||||
{
|
{
|
||||||
private float lastAppliedAmount;
|
private float lastAppliedAmount;
|
||||||
|
|
||||||
public Stat stat;
|
public Attribute stat;
|
||||||
public float percent;
|
public float percent;
|
||||||
public string Description => GetDescription();
|
public string Description => GetDescription();
|
||||||
|
|
||||||
public void Apply(CharacterAttributes attributes)
|
public void Apply(CharacterAttributes attributes)
|
||||||
{
|
{
|
||||||
var baseValue = GetBaseValue<float>(attributes);
|
var baseValue = attributes.Get(stat);
|
||||||
lastAppliedAmount = baseValue * percent;
|
lastAppliedAmount = baseValue * percent;
|
||||||
|
attributes.Modify(stat, lastAppliedAmount);
|
||||||
var flatModifier = new FlatStatModifier
|
|
||||||
{
|
|
||||||
value = lastAppliedAmount,
|
|
||||||
stat = stat
|
|
||||||
};
|
|
||||||
|
|
||||||
flatModifier.Apply(attributes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Remove(CharacterAttributes attributes)
|
public void Remove(CharacterAttributes attributes)
|
||||||
{
|
{
|
||||||
var flatModifier = new FlatStatModifier
|
attributes.Modify(stat, -lastAppliedAmount);
|
||||||
{
|
|
||||||
value = -lastAppliedAmount,
|
|
||||||
stat = stat
|
|
||||||
};
|
|
||||||
|
|
||||||
flatModifier.Apply(attributes);
|
|
||||||
}
|
|
||||||
|
|
||||||
private T GetBaseValue<T>(CharacterAttributes attributes)
|
|
||||||
{
|
|
||||||
return stat switch
|
|
||||||
{
|
|
||||||
Stat.Health => (T)(object)attributes.Health,
|
|
||||||
Stat.MaxHealth => (T)(object)attributes.MaxHealth,
|
|
||||||
Stat.MoveSpeed => (T)(object)attributes.MoveSpeed,
|
|
||||||
Stat.Luck => (T)(object)attributes.Luck,
|
|
||||||
Stat.Armor => (T)(object)attributes.Armor,
|
|
||||||
Stat.Damage => (T)(object)attributes.Damage,
|
|
||||||
Stat.RangedDamage => (T)(object)attributes.RangedDamage,
|
|
||||||
Stat.MeleeDamage => (T)(object)attributes.MeleeDamage,
|
|
||||||
Stat.AttackRange => (T)(object)attributes.AttackRange,
|
|
||||||
Stat.AttackSpeed => (T)(object)attributes.AttackSpeed,
|
|
||||||
_ => throw new System.ArgumentOutOfRangeException()
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetDescription()
|
private string GetDescription()
|
||||||
|
@@ -13,12 +13,12 @@ namespace Systems
|
|||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
character.attributes.OnHealthChanged += OnHealthChanged;
|
character.attributes.Subscribe(Attribute.Health, OnHealthChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
character.attributes.OnHealthChanged -= OnHealthChanged;
|
character.attributes.Unsubscribe(Attribute.Health, OnHealthChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnHealthChanged(float newHealth)
|
private void OnHealthChanged(float newHealth)
|
||||||
|
@@ -2,6 +2,7 @@ using System;
|
|||||||
using Interfaces;
|
using Interfaces;
|
||||||
using Sirenix.Serialization;
|
using Sirenix.Serialization;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Attribute = Data.Attribute;
|
||||||
|
|
||||||
namespace Systems
|
namespace Systems
|
||||||
{
|
{
|
||||||
@@ -14,7 +15,7 @@ namespace Systems
|
|||||||
|
|
||||||
public void Die(GameObject killer = null)
|
public void Die(GameObject killer = null)
|
||||||
{
|
{
|
||||||
GameManager.Instance.Player.attributes.ModifyExperience(expReward);
|
GameManager.Instance.Player.attributes.Modify(Attribute.Experience, expReward);
|
||||||
GameManager.Instance.AddCoins(coinReward);
|
GameManager.Instance.AddCoins(coinReward);
|
||||||
|
|
||||||
OnAnyEnemyKilled?.Invoke(killer ?? GameManager.Instance.Player.gameObject, gameObject);
|
OnAnyEnemyKilled?.Invoke(killer ?? GameManager.Instance.Player.gameObject, gameObject);
|
||||||
|
@@ -2,6 +2,7 @@ using System;
|
|||||||
using Data;
|
using Data;
|
||||||
using KBCore.Refs;
|
using KBCore.Refs;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Attribute = Data.Attribute;
|
||||||
|
|
||||||
namespace Systems
|
namespace Systems
|
||||||
{
|
{
|
||||||
@@ -19,15 +20,15 @@ namespace Systems
|
|||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
character.attributes.SetHealth(initialHealth);
|
character.attributes.Set(Attribute.Health, initialHealth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TakeDamage(float damage, GameObject attacker = null)
|
public void TakeDamage(float damage, GameObject attacker = null)
|
||||||
{
|
{
|
||||||
lastAttacker = attacker;
|
lastAttacker = attacker;
|
||||||
|
|
||||||
var effectiveDamage = Math.Max(damage - character.attributes.Armor, 1);
|
var effectiveDamage = Math.Max(damage - character.attributes.Get(Attribute.Armor), 1);
|
||||||
character.attributes.ModifyHealth(-effectiveDamage);
|
character.attributes.Modify(Attribute.Health, -effectiveDamage);
|
||||||
|
|
||||||
if (damageSound)
|
if (damageSound)
|
||||||
{
|
{
|
||||||
|
@@ -3,6 +3,7 @@ using Data;
|
|||||||
using KBCore.Refs;
|
using KBCore.Refs;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
|
using Attribute = Data.Attribute;
|
||||||
|
|
||||||
namespace Systems
|
namespace Systems
|
||||||
{
|
{
|
||||||
@@ -43,7 +44,7 @@ namespace Systems
|
|||||||
{
|
{
|
||||||
if (!rb) return;
|
if (!rb) return;
|
||||||
|
|
||||||
var velocity = new Vector2(movementInput.x, movementInput.y).normalized * character.attributes.MoveSpeed;
|
var velocity = new Vector2(movementInput.x, movementInput.y).normalized * character.attributes.Get(Attribute.MoveSpeed);
|
||||||
rb.linearVelocity = velocity;
|
rb.linearVelocity = velocity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ using Systems;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using Attribute = Data.Attribute;
|
||||||
|
|
||||||
namespace UI
|
namespace UI
|
||||||
{
|
{
|
||||||
@@ -18,11 +19,11 @@ namespace UI
|
|||||||
var player = GameManager.Instance.Player;
|
var player = GameManager.Instance.Player;
|
||||||
if (!player) return;
|
if (!player) return;
|
||||||
|
|
||||||
expText.text = $"EXP: {player.attributes.Experience}";
|
expText.text = $"EXP: {player.attributes.Get(Attribute.Experience)}";
|
||||||
coinsText.text = $"Coins: {GameManager.Instance.Coins}";
|
coinsText.text = $"Coins: {GameManager.Instance.Coins}";
|
||||||
roundTimeLeftText.text = $"{GameManager.Instance.RoundTimeLeft:F1}s";
|
roundTimeLeftText.text = $"{GameManager.Instance.RoundTimeLeft:F1}s";
|
||||||
healthSlider.maxValue = player.attributes.MaxHealth;
|
healthSlider.maxValue = player.attributes.Get(Attribute.MaxHealth);
|
||||||
healthSlider.value = player.attributes.Health;
|
healthSlider.value = player.attributes.Get(Attribute.Health);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -5,11 +5,13 @@ using KBCore.Refs;
|
|||||||
using Shop;
|
using Shop;
|
||||||
using Systems;
|
using Systems;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Attribute = Data.Attribute;
|
||||||
|
|
||||||
namespace UI
|
namespace UI
|
||||||
{
|
{
|
||||||
public class LevelUpHud : MonoBehaviour
|
public class LevelUpHud : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
private float previousLevel = 1f;
|
||||||
private List<UpgradeSlot> currentSlots = new();
|
private List<UpgradeSlot> currentSlots = new();
|
||||||
private List<StatModifierItem> currentItemChoices = new();
|
private List<StatModifierItem> currentItemChoices = new();
|
||||||
private List<WeaponItem> currentWeaponChoices = new();
|
private List<WeaponItem> currentWeaponChoices = new();
|
||||||
|
@@ -4,6 +4,7 @@ using Interfaces;
|
|||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using Sirenix.Serialization;
|
using Sirenix.Serialization;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Attribute = Data.Attribute;
|
||||||
|
|
||||||
namespace Weapons
|
namespace Weapons
|
||||||
{
|
{
|
||||||
@@ -27,18 +28,18 @@ namespace Weapons
|
|||||||
|
|
||||||
private float GetFinalAttackSpeed()
|
private float GetFinalAttackSpeed()
|
||||||
{
|
{
|
||||||
return character.attributes.AttackSpeed * weaponStats.attackSpeed;
|
return character.attributes.Get(Attribute.AttackSpeed) * weaponStats.attackSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected float GetFinalDamage()
|
protected float GetFinalDamage()
|
||||||
{
|
{
|
||||||
return weaponStats.damage + character.attributes.Damage *
|
return weaponStats.damage + character.attributes.Get(Attribute.Damage) *
|
||||||
(weaponStats.damageType == DamageType.Melee ? character.attributes.MeleeDamage : character.attributes.RangedDamage);
|
(weaponStats.damageType == DamageType.Melee ? character.attributes.Get(Attribute.MeleeDamage) : character.attributes.Get(Attribute.RangedDamage));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected float GetFinalRange()
|
protected float GetFinalRange()
|
||||||
{
|
{
|
||||||
return weaponStats.range * character.attributes.AttackRange;
|
return weaponStats.range * character.attributes.Get(Attribute.AttackRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void PlayShotSound()
|
protected void PlayShotSound()
|
||||||
|
Reference in New Issue
Block a user