TO SQUASH: Jesus!!
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user