TO SQUASH: Fixed issue with yummy missed sound playing multiple times.
This commit is contained in:
@@ -13,6 +13,10 @@ public class Shark : MonoBehaviour
|
||||
|
||||
public Player player;
|
||||
|
||||
public SpriteRenderer gameBoardSpriteRenderer;
|
||||
|
||||
private Bounds gameBoardBounds;
|
||||
|
||||
private AudioSource audioSource;
|
||||
|
||||
private Animator animator;
|
||||
@@ -33,12 +37,14 @@ public class Shark : MonoBehaviour
|
||||
|
||||
private static int sharkKillPoints = 100;
|
||||
|
||||
private bool spawnFinished = false;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
animator = GetComponent<Animator>();
|
||||
|
||||
gameBoardBounds = gameBoardSpriteRenderer.bounds;
|
||||
bool spawnLeft = Random.Range(0, 2) == 0;
|
||||
angle = spawnLeft ? 90 : 270;
|
||||
|
||||
@@ -49,12 +55,18 @@ public class Shark : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
// Do stuff only if the spawn animation is finished
|
||||
// Check if the spawn animation has finished.
|
||||
if (
|
||||
(animator.GetCurrentAnimatorStateInfo(0).IsName("SharkSpawnRight") ||
|
||||
animator.GetCurrentAnimatorStateInfo(0).IsName("SharkSpawnLeft")) &&
|
||||
animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1.0f
|
||||
)
|
||||
{
|
||||
spawnFinished = true;
|
||||
}
|
||||
|
||||
// Do stuff only if the spawn animation has finished.
|
||||
if (spawnFinished)
|
||||
{
|
||||
// TODO: Check if the shark was killed.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user