IEnumerator CheckRadius() { for (; dead == false;) { if (hasAttacked == false && attacking == false) { Collider2D[] c2d = Physics2D.OverlapCircleAll(transform.position, seekRadius); bool tempb = false; foreach (Collider2D cl2d in c2d) { if (cl2d.gameObject.GetComponent <Player>() != null) { tempb = true; } } if (tempb) { backMusic = Camera.main.GetComponentInChildren <BackMusicScript>(); backMusic.AddToList(gameObject); backMusic.PlayBattleMusic(battleMusic.enemyMusic); destinationSetter.target = player.transform; animator.Play("Move"); } else { backMusic = Camera.main.GetComponentInChildren <BackMusicScript>(); backMusic.RemoveFromList(gameObject); backMusic.PlayCalmMusic(); destinationSetter.target = temp.transform; animator.Play("Idle"); } } yield return(new WaitForSeconds(1f)); } }
public void ApplyDamage(float damage) { health -= damage; hpBar.fillAmount = health / maxHealth; hpBarText.text = $"{health}/{maxHealth}"; if (health <= 0) { backMusic.RemoveFromList(gameObject); backMusic.PlayCalmMusic(); Destroy(gameObject); } }
IEnumerator CheckRadius() { for (;;) { Collider2D[] c2d = Physics2D.OverlapCircleAll(transform.position, seekRadius); if (c2d[0].GetComponent <Player>() != null) { backMusic = Camera.main.GetComponentInChildren <BackMusicScript>(); backMusic.AddToList(gameObject); backMusic.PlayBattleMusic(battleMusic.enemyMusic); destinationSetter.target = player.transform; } else { backMusic = Camera.main.GetComponentInChildren <BackMusicScript>(); backMusic.RemoveFromList(gameObject); backMusic.PlayCalmMusic(); destinationSetter.target = temp.transform; } yield return(new WaitForSeconds(1f)); } }
public void ApplyDamage(float damage) { if (!dead) { health -= damage; } if (health > 0) { StartCoroutine(GetDamage()); } hpBar.fillAmount = health / maxHealth; hpBarText.text = $"{health}"; if (health <= 0) { backMusic.RemoveFromList(gameObject); backMusic.PlayCalmMusic(); animator.Play("Dead"); destinationSetter.target = transform; dead = true; SetPortalLevel(); entryPoint.SetActive(false); Destroy(hpBarText); } }