(probably) fixed bug where enemy doesn't reset if grappled

also moved the victory object lower in the brasslands
This commit is contained in:
Sam
2023-05-05 16:00:11 -07:00
parent 467f67bfd6
commit 82841da28e
3 changed files with 19 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ public class EnemyPatrol : MonoBehaviour {
[Header("General")]
public float moveSpeed;
Animator animator;
public bool isPlayingDefeatAnimation = false;
void Awake() {
animator = GetComponent<Animator>();
@@ -73,11 +74,13 @@ public class EnemyPatrol : MonoBehaviour {
}
IEnumerator Defeat() {
isPlayingDefeatAnimation = true;
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
animator.Play("Explosion");
this.gameObject.GetComponent<AudioSource>().Play();
yield return new WaitForSeconds(animator.GetCurrentAnimatorStateInfo(0).length);
this.gameObject.GetComponent<BoxCollider2D>().enabled = true;
isPlayingDefeatAnimation = false;
this.gameObject.SetActive(false);
}

View File

@@ -203,6 +203,9 @@ public class StateController : MonoBehaviour
{
foreach (GameObject enemy in enemiesInScene)
{
if (enemy.GetComponent<EnemyPatrol>().isPlayingDefeatAnimation) {
enemy.SetActive(false);
}
enemy.SetActive(true);
}
}