void Update() { if (!isActivated) { float wyvernX, wyvernY; wyvernX = player.position.x - preFabTransform.position.x; wyvernY = player.position.y - preFabTransform.position.y; //Debug.Log(Mathf.Abs(wyvernX) + " ," + Mathf.Abs(wyvernY)); if (Mathf.Abs(wyvernX) <= 10 && Mathf.Abs(wyvernY) <= 10) { if (!isWaiting) { ActivateWyvern(); } } if (Mathf.Abs(wyvernX) >= 50 && Mathf.Abs(wyvernY) >= 50) { DeactivateWyvern(); } } if (deadBool) { deathTimer -= Time.deltaTime; if (deathTimer <= 0) { wyvernDestroy.ZombieDest(); } } if (!readyToAttack || !attacking) { AdjustSides(); } if (invincibleTimer > 0) { invincibleTimer = invincibleTimer - Time.deltaTime; } else { foreach (SkinnedMeshRenderer skin in wyvernRenderer) { skin.material.color = Color.white; } } }
// 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); }