TO SQUASH: Shark sparks.
This commit is contained in:
@@ -279,6 +279,7 @@ public class LevelEnder : MonoBehaviour
|
||||
cakeSpawner.StartSpawning();
|
||||
ballSpawner.StartSpawning();
|
||||
multiplierSpawner.Reset();
|
||||
sharkSpawner.Reset();
|
||||
|
||||
// Reset state.
|
||||
levelEnded = false;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a68da2f7dbe6b99dfb0fc455293e9bad
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -15,6 +15,8 @@ public class Shark : NotifierBase
|
||||
|
||||
public Player player;
|
||||
|
||||
public GameObject sparkPrefab;
|
||||
|
||||
public SpriteRenderer gameBoardSpriteRenderer;
|
||||
|
||||
private Bounds? gameBoardBounds = null;
|
||||
@@ -39,6 +41,8 @@ public class Shark : NotifierBase
|
||||
|
||||
private static int sharkKillPoints = 1000;
|
||||
|
||||
private static float sparkSpawnIntervalSeconds = 1.0f / 10.0f;
|
||||
|
||||
private bool spawnFinished = false;
|
||||
|
||||
[SerializeField]
|
||||
@@ -73,6 +77,8 @@ public class Shark : NotifierBase
|
||||
|
||||
private float currentTargetTimer = 0f;
|
||||
|
||||
private float sparkSpawnTimer = 0f;
|
||||
|
||||
private bool killed = false;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
@@ -268,10 +274,35 @@ public class Shark : NotifierBase
|
||||
Vector2 nextPosition = currentPosition + forward * (currentSpeed * Time.fixedDeltaTime);
|
||||
transform.position = new Vector3(nextPosition.x, nextPosition.y, transform.position.z);
|
||||
|
||||
float movedDistanceSqr = (nextPosition - currentPosition).sqrMagnitude;
|
||||
if (movedDistanceSqr > 0.000001f)
|
||||
{
|
||||
sparkSpawnTimer += Time.fixedDeltaTime;
|
||||
while (sparkSpawnTimer >= sparkSpawnIntervalSeconds)
|
||||
{
|
||||
SpawnSpark();
|
||||
sparkSpawnTimer -= sparkSpawnIntervalSeconds;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sparkSpawnTimer = 0f;
|
||||
}
|
||||
|
||||
angle = QuantizeAngleToTen(currentHeadingAngle);
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnSpark()
|
||||
{
|
||||
if (sparkPrefab == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Instantiate(sparkPrefab, transform.position, Quaternion.identity);
|
||||
}
|
||||
|
||||
private Vector2 ChooseRandomTarget()
|
||||
{
|
||||
Bounds bounds = movementBounds.Value;
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SharkSpark : MonoBehaviour
|
||||
{
|
||||
public void DestroySpark()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc6262e498fa2d2eba7d1e3d1b58f1cb
|
||||
Reference in New Issue
Block a user