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