// Update is called once per frame void Update() { distancetotarget = Vector3.Distance(target.position, transform.position); if (health.isdead()) { won.youwon(); source.volume = 0; this.enabled = false; navmeshagent.enabled = false; } else if (!health.isdead()) { if (isprovoke) { engagetarget(); } else if (distancetotarget <= chaserange) { source.volume = volume; isprovoke = true; source.Play(); chasetarget(); } } }
// Update is called once per frame public void youwon() { if (health.isdead()) { k++; if (k == 23) { StartCoroutine(finale()); } else { return; } IEnumerator finale() { source.Play(); canvas.enabled = true; yield return(new WaitForSeconds(1)); Time.timeScale = 0; Application.Quit(); } } }