// Update is called once per frame
    void Update()
    {
        if (invincibleTimer > 0)
        {
            invincibleTimer = invincibleTimer - Time.deltaTime;
        }

        else
        {
            foreach (SkinnedMeshRenderer skin in skeletonRenderer)
            {
                skin.material.color = Color.white;
            }
        }

        bool groundhit = Physics2D.OverlapBox(wallBounce.position, new Vector2(0.3f, 0.9f), 0, surface);

        bool collidedSurface = false;

        Collider2D[] collided = Physics2D.OverlapCircleAll(groundCheck.position, 0.1f, surface);

        for (int i = 0; i < collided.Length; i++)
        {
            if (collided[i].tag == "Surface")
            {
                collidedSurface = true;
            }
        }

        anim.SetBool("Grounded", collidedSurface);

        if (groundhit)
        {
            facingRight = !facingRight;
            AdjustSides();
        }

        if (anim.GetCurrentAnimatorStateInfo(0).IsName("Idle") && !anim.GetBool("Idle"))
        {
            Idle();
        }

        if (healthScript.GetPlayerHealth() != 0 && !anim.GetBool("Walking") &&
            anim.GetBool("Idle") &&
            !anim.GetBool("Attacking") &&
            !anim.GetBool("Hurt") &&
            !anim.GetAnimatorTransitionInfo(0).IsName("Hurt -> Idle"))
        {
            Move();
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (graveStone != null)
        {
            float zombieX, zombieY;

            zombieX = player.position.x - gameObject.transform.position.x;
            zombieY = player.position.y - gameObject.transform.position.y;

            //Debug.Log(Mathf.Abs(zombieX) + " ," + Mathf.Abs(zombieY));

            if (Mathf.Abs(zombieX) >= 40 || Mathf.Abs(zombieY) >= 40)
            {
                zombieDestroy.ZombieDest();
            }
        }

        if (invincibleTimer > 0)
        {
            invincibleTimer = invincibleTimer - Time.deltaTime;
        }

        else
        {
            foreach (SkinnedMeshRenderer skin in zombieRenderer)
            {
                skin.material.color = Color.white;
            }
        }

        bool groundhit = Physics2D.OverlapBox(wallBounce.position + new Vector3(0, 0.1f, 0), new Vector2(0.1f, 1.9f), 0, surface);

        bool collidedSurface = false;

        Collider2D[] collided = Physics2D.OverlapCircleAll(groundCheck.position, 0.1f, surface);

        for (int i = 0; i < collided.Length; i++)
        {
            if (collided[i].tag == "Surface")
            {
                collidedSurface = true;
            }
        }

        anim.SetBool("Grounded", collidedSurface);

        if (groundhit)
        {
            facingRight = !facingRight;
            AdjustSides();
        }

        if (anim.GetCurrentAnimatorStateInfo(0).IsName("Idle") && !anim.GetBool("Idle"))
        {
            Idle();
        }

        if (healthScript.GetPlayerHealth() != 0 && !anim.GetBool("Walking") &&
            anim.GetBool("Idle") &&
            !anim.GetBool("Attacking") &&
            !anim.GetBool("Hurting") &&
            !anim.GetAnimatorTransitionInfo(0).IsName("Hurting -> Idle"))
        {
            Move();
        }


        Debug.DrawRay(transAttack.transform.position, Vector3.right);
    }