Update Class structure to not require the need to convert enum to int
This commit is contained in:
parent
0b33a81284
commit
0107e33438
@ -26,7 +26,7 @@ public class ClassBase {
|
||||
protected FloatingTextSpawner TextPopUp;
|
||||
/// <summary>Always in the order of Up, Down, Left, Right</summary>
|
||||
public string AnimationToPlay = "";
|
||||
public Dictionary<int, ClassSkill> Skills = new Dictionary<int, ClassSkill>();
|
||||
public Dictionary<Enum, ClassSkill> Skills = new Dictionary<Enum, ClassSkill>();
|
||||
[SerializeField] private List<ClassSkill> AvailableSkills = new List<ClassSkill>();
|
||||
|
||||
public ClassBase(Player player) {
|
||||
@ -36,20 +36,20 @@ public class ClassBase {
|
||||
TextPopUp = new FloatingTextSpawner(player.transform);
|
||||
}
|
||||
|
||||
public void GenerateAvailableSkillsList() {
|
||||
AvailableSkills.AddRange(Skills.Values);
|
||||
}
|
||||
|
||||
virtual public void Tick() {
|
||||
TimeElapsed = Time.time;
|
||||
ClassSkill.TimeElapsed = TimeElapsed;
|
||||
AvailableSkills.ForEach((x) => x.UpdateCooldown());
|
||||
foreach (var skill in Skills.Values) { skill.UpdateCooldown(); }
|
||||
}
|
||||
|
||||
virtual public void HandlePrimaryAttack() { }
|
||||
virtual public void HandleSecondaryAttack() { }
|
||||
|
||||
|
||||
public void GenerateAvailableSkillsList() => AvailableSkills.AddRange(Skills.Values);
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class ClassSkill {
|
||||
public static float TimeElapsed;
|
||||
|
||||
@ -22,9 +22,9 @@ public class MeleeFighterClass : ClassBase {
|
||||
|
||||
|
||||
public MeleeFighterClass(Player player) : base(player) {
|
||||
Skills.Add((int)AttackState.PhaseCleave, new ClassSkill("PhaseCleave", 2f, 3));
|
||||
Skills.Add((int)AttackState.BladeVortex, new ClassSkill("BladeVortex", 2f, 3));
|
||||
Skills.Add((int)AttackState.Shockwave, new ClassSkill("Shockwave", 2f, 3));
|
||||
Skills.Add(AttackState.PhaseCleave, new ClassSkill("PhaseCleave", 2f, 3));
|
||||
Skills.Add(AttackState.BladeVortex, new ClassSkill("BladeVortex", 2f, 3));
|
||||
Skills.Add(AttackState.Shockwave, new ClassSkill("Shockwave", 2f, 3));
|
||||
GenerateAvailableSkillsList();
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ public class MeleeFighterClass : ClassBase {
|
||||
|
||||
case AttackState.BasicAttack1:
|
||||
if (!AllowBladeVortex) return;
|
||||
if (!Skills[(int)AttackState.BladeVortex].IsReady()) {
|
||||
if (!Skills[AttackState.BladeVortex].IsReady()) {
|
||||
ChangeState(AttackState.None);
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user