void ExecuteCanalise() { if (CurrentSpell != null) { bool canCast = true; float[] costs = SpellsManager.GetSpellByID(CurrentSpell.GetSpell().ID).OnCastCosts; if (((HumorsComponent)LinkedEntity.GetComponent(typeof(HumorsComponent))).GetBlood() < costs[0]) { canCast = false; } if (((HumorsComponent)LinkedEntity.GetComponent(typeof(HumorsComponent))).GetPhlegm() < costs[1]) { canCast = false; } if (((HumorsComponent)LinkedEntity.GetComponent(typeof(HumorsComponent))).GetYellowBile() < costs[2]) { canCast = false; } if (((HumorsComponent)LinkedEntity.GetComponent(typeof(HumorsComponent))).GetBlackBile() < costs[3]) { canCast = false; } if (canCast) { ((HumorsComponent)LinkedEntity.GetComponent(typeof(HumorsComponent))).RemoveHumors(costs); CurrentSpell.ExecuteOnCanalise(); } else { ExecuteEnd(); Debugger.Log("Pas assez d'humeur par rapoort au coût de ce sort !"); } } }
void Cast(uint spellID, object target) { Spell s = SpellsManager.GetSpellByID(spellID); if (s != null) { bool canCast = true; float[] costs = s.OnCastCosts; if (LinkedEntity.GetComponent <HumorsComponent>() != null) { HumorsComponent humors = ((HumorsComponent)LinkedEntity.GetComponent(typeof(HumorsComponent))); if (humors.GetBlood() < costs[0]) { canCast = false; } else if (humors.GetPhlegm() < costs[1]) { canCast = false; } else if (humors.GetYellowBile() < costs[2]) { canCast = false; } else if (humors.GetBlackBile() < costs[3]) { canCast = false; } } if (canCast) { if (LinkedEntity.GetComponent <HumorsComponent>() != null) { LinkedEntity.GetComponent <HumorsComponent>().RemoveHumors(costs); } CurrentSpell = s.Cast(LinkedEntity, target); } else { Debugger.Log("Pas assez d'humeur par rapport au coût de ce sort !"); } } }
public override void Initialise(WorldState.WorldState worldState) { if (!CommandsInitialised) { InitialiseCommands(); } CurrentSpell = null; SpellKeyCodes = new Dictionary <uint, UnityEngine.KeyCode>(); if (SpellsManager.SpellsCount < 1) { SpellsManager.GetSpellByID(0); // Pour initialiser le tableau de Spells s'il ne l'était pas déjà } for (uint i = 0; i < SpellsManager.SpellsCount && i < 9; i++) { AddSpellKeyCode(i, UnityEngine.KeyCode.Alpha1 + (int)i); Debugger.Log("Sort d'ID " + i + " associé à la touche " + (UnityEngine.KeyCode.Alpha1 + (int)i).ToString(), UnityEngine.Color.magenta); } SelectedSpellId = 0; }
public Spell GetSpell() { return(SpellsManager.GetSpellByID(SpellID)); }