示例#1
0
        public void DamageDealt(int currentLife, int maxLife)
        {
            OnPlayerDamage?.Invoke(currentLife, maxLife);

            if (_invincibilityCoroutine != null)
            {
                StopCoroutine(_invincibilityCoroutine);
            }

            StartCoroutine(InvincibilityTime(LifeSystem.InvincibilityTime));
        }
    private void GetDamage(GameObject other)
    {
        _rigidbody2D.velocity = Vector2.zero;
        _canMove      = false;
        _canGetDamage = false;
        if (other.CompareTag("DamageLeft"))
        {
            _rigidbody2D.AddForce(Vector2.left * velocity + Vector2.up * jumpForce, ForceMode2D.Impulse);
        }
        else if (other.CompareTag("DamageRight"))
        {
            _rigidbody2D.AddForce(Vector2.left * -velocity + Vector2.up * jumpForce, ForceMode2D.Impulse);
        }

        StopAllCoroutines();
        StartCoroutine(RestartNoImmune());
        OnPlayerDamage?.Invoke(immuneTime);
    }
示例#3
0
 /// <summary>
 /// Riases a player death event if there are any listeners
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 internal void RaisePlayerDamageEvent(object sender, PlayerDamageEventArgs args)
 {
     OnPlayerDamage?.Invoke(sender, args);
 }