public void executeSkill(SkillBase skillBase, int skillbarIndex) { string skillName = skillBase.name; // check if skill is off cooldown if (skillCooldowns.ContainsKey(skillName) && skillCooldowns[skillName] > 0f) { Debug.Log(skillBase.name + " is not off cooldown yet."); return; } // check if we have the mana for this skill if (!ManaHelper.HasEnoughMana(skillBase.manaCost)) { Debug.Log("Not enough mana to cast " + skillBase.name); return; } if (skillName == SkillNames.CANNON) { // fetch the target position Vector3 target = GetComponent <TargetingModeController> ().GetGroundTargetPosition(); bool successfulShot = ShootCannonball(target); if (successfulShot) { StartSkillCooldown(skillName, skillBase.cooldown, skillbarIndex); } } else if (skillName == SkillNames.MYSTIC_BULWARK) { ManaHelper.SpendMana(skillBase.manaCost); StartSkillCooldown(skillName, skillBase.cooldown, skillbarIndex); ShieldHelper.SetShield(skillBase.shield); } }
// Use this for initialization void Start() { manaHelper = manaLayout.GetComponent<ManaHelper>(); left = down = up = false; right = true; animator = GetComponent<Animator>(); //Initialize xIndex = (int)transform.position.x; yIndex = (int)transform.position.y; LightArea(); }