/// <summary> /// Applies the effect to the target if the target is valid. /// </summary> /// /// <param name="target">The targeted tile.</param> /// <param name="audioSource">The audio source used to play ability sound effects.</param> public void Apply(Tile target, AudioSource audioSource) { // Check if the target is valid. if (!abilityEffectTarget.IsTarget(target)) { return; } // Get the HitRate and roll for hit. var hitRate = GetComponent <HitRate>(); Assert.IsNotNull(hitRate); if (hitRate.RollForHit(target)) { // TODO: Wait for the animation to finish before moving the camera // back to the caster. int damage = OnApply(target); var info = new HitInfo(target, damage, audioSource); this.PostNotification(HitNotification, info); } else { var info = new MissInfo(target, audioSource); this.PostNotification(MissNotification, info); } }
public bool IsTarget(Tile tile) { Transform obj = transform; for (int i = 0; i < obj.childCount; ++i) { AbilityEffectTarget targeter = obj.GetChild(i).GetComponent <AbilityEffectTarget>(); if (targeter.IsTarget(tile)) { return(true); } } return(false); }