Beispiel #1
0
    private void OnTriggerStay2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("sword"))
        {
            other.gameObject.SetActive(false);
            animator.SetTrigger("GotSword");
            animator.runtimeAnimatorController = (RuntimeAnimatorController)Resources.Load("player_sword");
            Weapon = new Sword();
        }

        if (other.gameObject.CompareTag("Enemy") && immunity.NotImmune)
        {
            Health.ChangeHealth(-.25f);
            animator.SetTrigger("Hurt");
            var direction = facingRight ? 1 : -1;
            velocity.x = direction * 8f;
            movement.Move(velocity * Time.deltaTime);
            immunity.Start(2);

            Weapon weapon = other.GetComponent <Weapon>();
            if (weapon != null)
            {
                weapon.TriggerWeaponHit();
            }
        }
    }
Beispiel #2
0
 internal virtual void YouGotHurt(GameObject playerObject)
 {
     if (Immunity.NotImmune)
     {
         Immunity.Start(immunityTime);
         Health.ChangeValue(-3);
         Animator.SetTrigger("Hurt");
     }
 }