TO SQUASH: Jesus!!

This commit is contained in:
2026-08-19 13:18:26 -04:00
parent 1cf68b32a1
commit 24d3297daa
16 changed files with 607 additions and 320 deletions
+18 -4
View File
@@ -73,6 +73,8 @@ public class Shark : MonoBehaviour
private float currentTargetTimer = 0f;
private bool killed = false;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
@@ -154,11 +156,9 @@ public class Shark : MonoBehaviour
// Do stuff only if the spawn animation has finished.
if (spawnFinished)
{
// TODO: Check if the shark was killed.
if (isDead)
if (killed && !isDead)
{
isDead = true;
animator.SetTrigger("killed");
audioSource.PlayOneShot(deathSound);
player.score += sharkKillPoints;
@@ -288,6 +288,15 @@ public class Shark : MonoBehaviour
);
Destroy(gameObject);
}
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Wall"))
{
Physics2D.IgnoreCollision(collision.collider, GetComponent<Collider2D>());
}
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.CompareTag("Bar"))
@@ -314,4 +323,9 @@ public class Shark : MonoBehaviour
}
}
}
public void KillShark()
{
killed = true;
}
}