예제 #1
0
    // Update is called once per frame
    void Update()
    {
        timeSinceLastAttack += Time.deltaTime;
        CalculateDistance();
        //Animations here

        if (hp.getHP() > 0)
        {
            PointTowardsPlayer();
            if (playerDistance < aggroDistance && notHit && playerDistance > attackRange)
            {
                FollowPlayer();
            }
            else if (notHit)
            {
                moveX = 0;
            }

            if (playerDistance < attackRange && attackSpeed <= timeSinceLastAttack)
            {
                Shoot();
            }
        }
        if (hp.getHit() == true)
        {
            Hit();
            hp.hitReceived();
        }
        if (hp.getHP() <= 0)
        {
            moveX = 0;
            ani.SetBool("Death", true);
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        //updating animation variables not including triggers
        animator.SetBool("IsGrounded", IsGrounded());
        animator.SetFloat("VelocityY", rb.velocity.y);

        //end of animaton variables
        if (IsGrounded() && !isAttacking && (Mathf.Abs(player.position.x - this.transform.position.x)) < aggroDistance && hp.getHP() > 0)
        {
            StartCoroutine(Attack());
            isAttacking = true;
        }
        if (hp.getHit() == true && hp.getHP() > 0)
        {
            animator.SetTrigger("Hit");
            hp.hitReceived();
        }
        if (hp.getHP() <= 0)
        {
            animator.SetBool("Death", true);
            //freeze position and dont interact with collisions
            if (IsGrounded())
            {
                rb.constraints = RigidbodyConstraints2D.FreezeAll;
                col.enabled    = false;
            }

            //GameObject.Destroy(this.gameObject);
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        //Timer for after the Guardians last attack, needed so the enemy cant just spam hit the Player.
        timeAfterLastAttack += Time.deltaTime;

        //Calculates the distance to teh Player to set up next move.
        CalculateDistance();


        if (hp.getHP() > 0)
        {
            if (playerDistanceFrom < engageRange && notHit && playerDistanceFrom > attackRange)
            {
                FollowPlayer();
            }
            else if (notHit)
            {
                moveXaxis = 0;
            }

            if (playerDistanceFrom < attackRange && attackSpeed <= timeAfterLastAttack)
            {
                Hit();
            }
        }
        if (hp.getHit() == true)
        {
            hp.hitRecived();
        }
    }
예제 #4
0
    // Update is called once per frame
    void Update()
    {
        timeSinceLastAttack += Time.deltaTime;
        CalculateDistance();
        Animations();
        if (playerDistance < agroDistance && notHit && hp.getHP() > 0 && playerDistance > dontMoveDistance)
        {
            FollowPlayer();
        }
        else if (notHit)
        {
            moveX = 0;
        }

        if (playerDistance < attackDistance && attackSpeed <= timeSinceLastAttack && hp.getHP() > 0)
        {
            Stab();
        }
        if (hp.getHit() == true)
        {
            Hit();
            hp.hitReceived();
        }
    }