TO SQUASH: Nuke ball fixes.
This commit is contained in:
@@ -101,7 +101,7 @@ AnimationClip:
|
|||||||
m_Level: 0
|
m_Level: 0
|
||||||
m_CycleOffset: 0
|
m_CycleOffset: 0
|
||||||
m_HasAdditiveReferencePose: 0
|
m_HasAdditiveReferencePose: 0
|
||||||
m_LoopTime: 0
|
m_LoopTime: 1
|
||||||
m_LoopBlend: 0
|
m_LoopBlend: 0
|
||||||
m_LoopBlendOrientation: 0
|
m_LoopBlendOrientation: 0
|
||||||
m_LoopBlendPositionY: 0
|
m_LoopBlendPositionY: 0
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ AnimationClip:
|
|||||||
m_Level: 0
|
m_Level: 0
|
||||||
m_CycleOffset: 0
|
m_CycleOffset: 0
|
||||||
m_HasAdditiveReferencePose: 0
|
m_HasAdditiveReferencePose: 0
|
||||||
m_LoopTime: 0
|
m_LoopTime: 1
|
||||||
m_LoopBlend: 0
|
m_LoopBlend: 0
|
||||||
m_LoopBlendOrientation: 0
|
m_LoopBlendOrientation: 0
|
||||||
m_LoopBlendPositionY: 0
|
m_LoopBlendPositionY: 0
|
||||||
|
|||||||
@@ -1187,6 +1187,7 @@ MonoBehaviour:
|
|||||||
fruitBallPrefab: {fileID: 3086586548818580311, guid: b67974a0c09fbe75aac299e30a0c665b, type: 3}
|
fruitBallPrefab: {fileID: 3086586548818580311, guid: b67974a0c09fbe75aac299e30a0c665b, type: 3}
|
||||||
gameBoard: {fileID: 297740150}
|
gameBoard: {fileID: 297740150}
|
||||||
player: {fileID: 1002905792}
|
player: {fileID: 1002905792}
|
||||||
|
worldFiller: {fileID: 2071167548}
|
||||||
--- !u!4 &240489637
|
--- !u!4 &240489637
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ public class NukeBall : BallBase
|
|||||||
|
|
||||||
public AudioClip explosionSound;
|
public AudioClip explosionSound;
|
||||||
|
|
||||||
|
public WorldFiller worldFiller;
|
||||||
|
|
||||||
// Tracks escalating danger/critical phases for audio cues.
|
// Tracks escalating danger/critical phases for audio cues.
|
||||||
private int criticalState = 0;
|
private int criticalState = 0;
|
||||||
|
|
||||||
private float criticalTime = 1.0f;
|
private float criticalTime = 0.5f;
|
||||||
|
|
||||||
private float criticalTimer = 0.0f;
|
private float criticalTimer = 0.0f;
|
||||||
|
|
||||||
@@ -92,12 +94,16 @@ public class NukeBall : BallBase
|
|||||||
|
|
||||||
transform.position = currentPosition;
|
transform.position = currentPosition;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// When in critical state 2, play the critical sound every half a second.
|
void Update()
|
||||||
if (criticalState == 2)
|
{
|
||||||
{
|
// Set critical state.
|
||||||
criticalTimer = 0.5f;
|
var area = worldFiller != null ? worldFiller.GetAreaPercentOfFreeRegion(transform.position) : -1.0f;
|
||||||
}
|
criticalState = (area < 0.2f) ? 2 : (area < 0.4f) ? 1 : 0;
|
||||||
|
|
||||||
|
// State 1 beeps every 0.5s, state 2 beeps every 0.25s.
|
||||||
|
criticalTime = (criticalState == 2) ? 0.5f : 1.0f;
|
||||||
|
|
||||||
// If in a critical state, increment the critical timer and play the
|
// If in a critical state, increment the critical timer and play the
|
||||||
// critical sound if the timer exceeds the critical time.
|
// critical sound if the timer exceeds the critical time.
|
||||||
@@ -108,9 +114,13 @@ public class NukeBall : BallBase
|
|||||||
if (criticalTimer >= criticalTime)
|
if (criticalTimer >= criticalTime)
|
||||||
{
|
{
|
||||||
audioSource.PlayOneShot(criticalSound);
|
audioSource.PlayOneShot(criticalSound);
|
||||||
}
|
|
||||||
|
|
||||||
// Restart timing window for the next critical beep.
|
// Keep fractional overflow so cadence stays stable across frame rates.
|
||||||
|
criticalTimer -= criticalTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
criticalTimer = 0.0f;
|
criticalTimer = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,6 +152,12 @@ public class NukeBall : BallBase
|
|||||||
currentPosition.y = bounceStartY;
|
currentPosition.y = bounceStartY;
|
||||||
transform.position = currentPosition;
|
transform.position = currentPosition;
|
||||||
}
|
}
|
||||||
|
else if (contact.normal.y <= -0.5f)
|
||||||
|
{
|
||||||
|
isBouncingToHeight = false;
|
||||||
|
bounceTimer = 0.0f;
|
||||||
|
height = contact.point.y - 0.01f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ public class Player : MonoBehaviour
|
|||||||
// Mouse input handling for firing lasers, magnets, or normal barriers.
|
// Mouse input handling for firing lasers, magnets, or normal barriers.
|
||||||
if (
|
if (
|
||||||
Mouse.current.leftButton.wasPressedThisFrame &&
|
Mouse.current.leftButton.wasPressedThisFrame &&
|
||||||
worldFiller.IsPositionInFreeArea(transform.position) &&
|
worldFiller.IsPositionInFreeRegion(transform.position) &&
|
||||||
canFire &&
|
canFire &&
|
||||||
!exploding
|
!exploding
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ public class BallSpawner : Spawner
|
|||||||
|
|
||||||
public Player player;
|
public Player player;
|
||||||
|
|
||||||
|
public WorldFiller worldFiller;
|
||||||
|
|
||||||
private static WaitForSeconds _waitForSeconds0_5 = new WaitForSeconds(0.5f);
|
private static WaitForSeconds _waitForSeconds0_5 = new WaitForSeconds(0.5f);
|
||||||
|
|
||||||
private Queue<System.Action> ballQueue = new Queue<System.Action>();
|
private Queue<System.Action> ballQueue = new Queue<System.Action>();
|
||||||
@@ -35,6 +37,7 @@ public class BallSpawner : Spawner
|
|||||||
|
|
||||||
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||||
|
ballQueue.Enqueue(() => SpawnBall(nuclearBallPrefab));
|
||||||
basicBallCount = 2;
|
basicBallCount = 2;
|
||||||
|
|
||||||
StartCoroutine(SpawnBalls());
|
StartCoroutine(SpawnBalls());
|
||||||
@@ -195,6 +198,14 @@ public class BallSpawner : Spawner
|
|||||||
oozeBallScript.spawner = this;
|
oozeBallScript.spawner = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (ballPrefab == nuclearBallPrefab)
|
||||||
|
{
|
||||||
|
var nuclearBallScript = newBall.GetComponent<NukeBall>();
|
||||||
|
if (nuclearBallScript != null)
|
||||||
|
{
|
||||||
|
nuclearBallScript.worldFiller = worldFiller;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
balls.Enqueue(newBall);
|
balls.Enqueue(newBall);
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class SharkSpawner : Spawner
|
|||||||
{
|
{
|
||||||
spawnTimer += Time.fixedDeltaTime;
|
spawnTimer += Time.fixedDeltaTime;
|
||||||
|
|
||||||
if (spawnTimer >= 1f && isActive && isSpawning && player.level >= 1)
|
if (spawnTimer >= 1f && isActive && isSpawning && player.level >= 10)
|
||||||
{
|
{
|
||||||
spawnTimer = 0f;
|
spawnTimer = 0f;
|
||||||
if (Random.value < spawnProbability)
|
if (Random.value < spawnProbability)
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ public class WorldFiller : MonoBehaviour
|
|||||||
boardArea = boardRect.width * boardRect.height;
|
boardArea = boardRect.width * boardRect.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPositionInFreeArea(Vector2 position)
|
public bool IsPositionInFreeRegion(Vector2 position)
|
||||||
{
|
{
|
||||||
if (freeAreas.Count == 0 && gameBoardSpriteRenderer != null)
|
if (freeAreas.Count == 0 && gameBoardSpriteRenderer != null)
|
||||||
{
|
{
|
||||||
@@ -299,6 +299,24 @@ public class WorldFiller : MonoBehaviour
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetAreaPercentOfFreeRegion(Vector2 position)
|
||||||
|
{
|
||||||
|
if (freeAreas.Count == 0 && gameBoardSpriteRenderer != null)
|
||||||
|
{
|
||||||
|
InitializeFreeAreas();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < freeAreas.Count; i++)
|
||||||
|
{
|
||||||
|
if (RectContainsWithTolerance(freeAreas[i], position))
|
||||||
|
{
|
||||||
|
return (freeAreas[i].width * freeAreas[i].height) / boardArea;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
public Vector2 GetRandomPositionInFreeAreas(Bounds? clearingArea = null)
|
public Vector2 GetRandomPositionInFreeAreas(Bounds? clearingArea = null)
|
||||||
{
|
{
|
||||||
if (freeAreas.Count == 0 && gameBoardSpriteRenderer != null)
|
if (freeAreas.Count == 0 && gameBoardSpriteRenderer != null)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class YummyCake : MonoBehaviour
|
|||||||
public void BreakOrMiss()
|
public void BreakOrMiss()
|
||||||
{
|
{
|
||||||
// TODO: Implement logic to check if the cake is in a clear area or not
|
// TODO: Implement logic to check if the cake is in a clear area or not
|
||||||
bool inClearArea = worldFiller.IsPositionInFreeArea(transform.position);
|
bool inClearArea = worldFiller.IsPositionInFreeRegion(transform.position);
|
||||||
|
|
||||||
if (inClearArea)
|
if (inClearArea)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -306,7 +306,99 @@ PlayerSettings:
|
|||||||
m_Width: 128
|
m_Width: 128
|
||||||
m_Height: 128
|
m_Height: 128
|
||||||
m_Kind: 0
|
m_Kind: 0
|
||||||
m_BuildTargetPlatformIcons: []
|
m_BuildTargetPlatformIcons:
|
||||||
|
- m_BuildTarget: Android
|
||||||
|
m_Icons:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 432
|
||||||
|
m_Height: 432
|
||||||
|
m_Kind: 2
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 324
|
||||||
|
m_Height: 324
|
||||||
|
m_Kind: 2
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 216
|
||||||
|
m_Height: 216
|
||||||
|
m_Kind: 2
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 162
|
||||||
|
m_Height: 162
|
||||||
|
m_Kind: 2
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 108
|
||||||
|
m_Height: 108
|
||||||
|
m_Kind: 2
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 81
|
||||||
|
m_Height: 81
|
||||||
|
m_Kind: 2
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 192
|
||||||
|
m_Height: 192
|
||||||
|
m_Kind: 1
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 144
|
||||||
|
m_Height: 144
|
||||||
|
m_Kind: 1
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 96
|
||||||
|
m_Height: 96
|
||||||
|
m_Kind: 1
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 72
|
||||||
|
m_Height: 72
|
||||||
|
m_Kind: 1
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 48
|
||||||
|
m_Height: 48
|
||||||
|
m_Kind: 1
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 36
|
||||||
|
m_Height: 36
|
||||||
|
m_Kind: 1
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 192
|
||||||
|
m_Height: 192
|
||||||
|
m_Kind: 0
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 144
|
||||||
|
m_Height: 144
|
||||||
|
m_Kind: 0
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 96
|
||||||
|
m_Height: 96
|
||||||
|
m_Kind: 0
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 72
|
||||||
|
m_Height: 72
|
||||||
|
m_Kind: 0
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 48
|
||||||
|
m_Height: 48
|
||||||
|
m_Kind: 0
|
||||||
|
m_SubKind:
|
||||||
|
- m_Textures: []
|
||||||
|
m_Width: 36
|
||||||
|
m_Height: 36
|
||||||
|
m_Kind: 0
|
||||||
|
m_SubKind:
|
||||||
m_BuildTargetBatching:
|
m_BuildTargetBatching:
|
||||||
- m_BuildTarget: Standalone
|
- m_BuildTarget: Standalone
|
||||||
m_StaticBatching: 1
|
m_StaticBatching: 1
|
||||||
|
|||||||
Reference in New Issue
Block a user