示例#1
0
 void Awake()
 {
     SelectTarget();
     intTimer   = timer; // Store the initial value of timer
     anim       = GetComponent <Animator>();
     _birdGirth = playerBird.GetComponent <BirdGirth>();
 }
示例#2
0
    void Attack()
    {
        intTimer   = timer; // Reset Timer when Player enter Attack Range
        attackMode = true;  // To check if Enemy can still attack or not

        anim.SetBool("canWalk", false);
        anim.SetBool("canAttack", true);

        // Calculate Angle Between the collision point and the player
        var     collider     = triggerArea.GetComponent <Collider2D>();
        Vector3 closestPoint = collider.ClosestPoint(playerBird.position);
        Vector3 dir          = (playerBird.position - transform.position).normalized;

        _birdGirth = playerBird.GetComponent <BirdGirth>();
        // Only do Attack stuff if the bird is small and WEAK.
        if (_birdGirth.currentHealth < _consumable.RequiredGirthToConsume)
        {
            // Add force in direction of dir and multiply by force
            // Push back that boiiiii
            playerBird.GetComponent <Rigidbody2D>().AddForce(dir * force);


            // AFFECT PLAYER GIRTH
            playerBird.GetComponent <BirdGirth>().TakeDamage(5);
        }
    }