TO SQUASH: More shark.
This commit is contained in:
@@ -15,7 +15,7 @@ public class Shark : MonoBehaviour
|
|||||||
|
|
||||||
public SpriteRenderer gameBoardSpriteRenderer;
|
public SpriteRenderer gameBoardSpriteRenderer;
|
||||||
|
|
||||||
private Bounds gameBoardBounds;
|
private Bounds? gameBoardBounds = null;
|
||||||
|
|
||||||
private AudioSource audioSource;
|
private AudioSource audioSource;
|
||||||
|
|
||||||
@@ -44,7 +44,6 @@ public class Shark : MonoBehaviour
|
|||||||
{
|
{
|
||||||
audioSource = GetComponent<AudioSource>();
|
audioSource = GetComponent<AudioSource>();
|
||||||
animator = GetComponent<Animator>();
|
animator = GetComponent<Animator>();
|
||||||
gameBoardBounds = gameBoardSpriteRenderer.bounds;
|
|
||||||
bool spawnLeft = Random.Range(0, 2) == 0;
|
bool spawnLeft = Random.Range(0, 2) == 0;
|
||||||
angle = spawnLeft ? 90 : 270;
|
angle = spawnLeft ? 90 : 270;
|
||||||
|
|
||||||
@@ -55,6 +54,11 @@ public class Shark : MonoBehaviour
|
|||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void FixedUpdate()
|
void FixedUpdate()
|
||||||
{
|
{
|
||||||
|
if (gameBoardSpriteRenderer != null && gameBoardBounds == null)
|
||||||
|
{
|
||||||
|
gameBoardBounds = gameBoardSpriteRenderer.bounds;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the spawn animation has finished.
|
// Check if the spawn animation has finished.
|
||||||
if (
|
if (
|
||||||
(animator.GetCurrentAnimatorStateInfo(0).IsName("SharkSpawnRight") ||
|
(animator.GetCurrentAnimatorStateInfo(0).IsName("SharkSpawnRight") ||
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class SharkSpawner : MonoBehaviour
|
|||||||
|
|
||||||
private bool isActive = true;
|
private bool isActive = true;
|
||||||
|
|
||||||
private static float spawnProbability = 0.1f;
|
private static float spawnProbability = 0.9f;
|
||||||
|
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
void Start()
|
void Start()
|
||||||
|
|||||||
Reference in New Issue
Block a user