private IEnumerator DoKill()
    {
        _platformerControl.DoStop();
        Vector3 targetPos       = (_cachedTransform.position + new Vector3(-10, -2, 0));
        Vector2 targetDirection = (targetPos - _cachedTransform.position).normalized;

        while ((_cachedTransform.position - targetPos).sqrMagnitude > 1)
        {
            _cachedTransform.Translate(targetDirection * _currentSpeed * Time.deltaTime);
            yield return(null);
        }

        _currentAnimationName = "attack_custom";

        //Enable particle system
        fireParticles.enableEmission = true;
        fireTrigger.isEnabled        = true;

        audioSource.Play();
        while (CharacterStats.CurrentLife > 0)
        {
            CharacterStats.ReduceLife(40 * Time.deltaTime);
            yield return(null);
        }

        audioSource.Stop();
        _platformerControl.Die();
        fireParticles.enableEmission = false;
        fireTrigger.isEnabled        = false;
        _currentAnimationName        = "flyidle_custom";

        _eventHandler.enabled = true;
        canMove = true;
    }
Ejemplo n.º 2
0
 // Use this for initialization
 void OnTriggerStay(Collider other)
 {
     if (isEnabled)
     {
         _platformerController = other.gameObject.GetComponent <platformerControl>();
         if (_platformerController != null)
         {
             CharacterStats.ReduceLife(reducedLifePerSecond * Time.deltaTime);
             if (CharacterStats.CurrentLife == 0)
             {
                 _platformerController.Die();
             }
         }
     }
 }