// Update is called once per frame void Update() { if (Skeleton.GetHealth() <= 0 && !drop) { animator.SetBool("Dead", true); Skeleton.GetTarget().gameObject.GetComponent <UnarmedCharacter>().Coins += 200; drop = true; return; } if (Skeleton.GetHealth() <= 0) { return; } pvBar.fillAmount = Skeleton.GetHealth() / MaxHp; if (Time.time > Skeleton.GetAllow_action()) { if (Skeleton.GetTarget() != null) { float Distance = Vector3.Distance(Skeleton.transform.position, Skeleton.GetTarget().transform.position); if (Distance > Skeleton.GetFightingRange()) { Skeleton.chase(); } else { if (Distance <= Skeleton.GetAttackRange()) { Skeleton.attack(); } else { if (Skeleton.GetFight() && Distance <= Skeleton.GetFightingRange()) { Skeleton.StartCoroutine("fighting"); } } } } } else { if (Skeleton.GetTarget() != null) { Vector3 Targetposition = new Vector3(Skeleton.GetTarget().transform.position.x, transform.position.y, Skeleton.GetTarget().transform.position.z); transform.LookAt(Targetposition); transform.position = Vector3.MoveTowards(transform.position, Skeleton.GetTarget().transform.position, 6 * Time.deltaTime); } } }
// Update is called once per frame void Update() { if (Time.time > Skeleton.GetAllow_action()) { if (Skeleton.GetTarget() != null) { float Distance = Vector3.Distance(Skeleton.transform.position, Skeleton.GetTarget().transform.position); if (Distance > Skeleton.GetFightingRange()) { Skeleton.chase(); } else { if (Distance <= Skeleton.GetAttackRange()) { Skeleton.attack(); } else { if (Skeleton.GetFight() && Distance <= Skeleton.GetFightingRange()) { Skeleton.StartCoroutine("fighting"); } } } } } else { if (Skeleton.GetTarget() != null) { Vector3 Targetposition = new Vector3(Skeleton.GetTarget().transform.position.x, transform.position.y, Skeleton.GetTarget().transform.position.z); transform.LookAt(Targetposition); transform.position = Vector3.MoveTowards(transform.position, Skeleton.GetTarget().transform.position, 6 * Time.deltaTime); } } }