TO SQUASH: Added yummy cake.
This commit is contained in:
@@ -63,7 +63,7 @@ AnimatorStateTransition:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_Conditions:
|
m_Conditions:
|
||||||
- m_ConditionMode: 1
|
- m_ConditionMode: 1
|
||||||
m_ConditionEvent: inClearSpace
|
m_ConditionEvent: break
|
||||||
m_EventTreshold: 0
|
m_EventTreshold: 0
|
||||||
m_DstStateMachine: {fileID: 0}
|
m_DstStateMachine: {fileID: 0}
|
||||||
m_DstState: {fileID: -8510499286316664716}
|
m_DstState: {fileID: -8510499286316664716}
|
||||||
@@ -87,8 +87,8 @@ AnimatorStateTransition:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_Conditions:
|
m_Conditions:
|
||||||
- m_ConditionMode: 2
|
- m_ConditionMode: 1
|
||||||
m_ConditionEvent: inClearSpace
|
m_ConditionEvent: miss
|
||||||
m_EventTreshold: 0
|
m_EventTreshold: 0
|
||||||
m_DstStateMachine: {fileID: 0}
|
m_DstStateMachine: {fileID: 0}
|
||||||
m_DstState: {fileID: 9054705311603876797}
|
m_DstState: {fileID: 9054705311603876797}
|
||||||
@@ -113,11 +113,17 @@ AnimatorController:
|
|||||||
m_Name: YummyCake
|
m_Name: YummyCake
|
||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_AnimatorParameters:
|
m_AnimatorParameters:
|
||||||
- m_Name: inClearSpace
|
- m_Name: break
|
||||||
m_Type: 4
|
m_Type: 9
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 1
|
m_DefaultBool: 0
|
||||||
|
m_Controller: {fileID: 9100000}
|
||||||
|
- m_Name: miss
|
||||||
|
m_Type: 9
|
||||||
|
m_DefaultFloat: 0
|
||||||
|
m_DefaultInt: 0
|
||||||
|
m_DefaultBool: 0
|
||||||
m_Controller: {fileID: 9100000}
|
m_Controller: {fileID: 9100000}
|
||||||
m_AnimatorLayers:
|
m_AnimatorLayers:
|
||||||
- serializedVersion: 5
|
- serializedVersion: 5
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ AnimationClip:
|
|||||||
value: {fileID: 5312722573255266818, guid: a8e7c25b11ef926f4abe6495691ab75c, type: 3}
|
value: {fileID: 5312722573255266818, guid: a8e7c25b11ef926f4abe6495691ab75c, type: 3}
|
||||||
- time: 0.13333334
|
- time: 0.13333334
|
||||||
value: {fileID: -6258906876495665141, guid: d9f45731492e51aa9b12664c27f590cd, type: 3}
|
value: {fileID: -6258906876495665141, guid: d9f45731492e51aa9b12664c27f590cd, type: 3}
|
||||||
- time: 0.2
|
- time: 0.21666667
|
||||||
value: {fileID: 4817393950854663739, guid: 9cae9b568a5adb06fad2525963201430, type: 3}
|
value: {fileID: 4817393950854663739, guid: 9cae9b568a5adb06fad2525963201430, type: 3}
|
||||||
- time: 0.25
|
- time: 0.26666668
|
||||||
value: {fileID: -3519590720368953014, guid: 53f4409a85f291421a239e89833c2b39, type: 3}
|
value: {fileID: -3519590720368953014, guid: 53f4409a85f291421a239e89833c2b39, type: 3}
|
||||||
- time: 0.31666666
|
- time: 0.33333334
|
||||||
value: {fileID: 6778420724524421813, guid: c9b44481324cac5f18c976426b039c12, type: 3}
|
value: {fileID: 6778420724524421813, guid: c9b44481324cac5f18c976426b039c12, type: 3}
|
||||||
- time: 0.38333333
|
- time: 0.4
|
||||||
value: {fileID: 3207459501502463124, guid: 8b78beb1a33b3a8bbb7bc30aa8f6818c, type: 3}
|
value: {fileID: 3207459501502463124, guid: 8b78beb1a33b3a8bbb7bc30aa8f6818c, type: 3}
|
||||||
attribute: m_Sprite
|
attribute: m_Sprite
|
||||||
path:
|
path:
|
||||||
@@ -69,7 +69,7 @@ AnimationClip:
|
|||||||
m_AdditiveReferencePoseClip: {fileID: 0}
|
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||||
m_AdditiveReferencePoseTime: 0
|
m_AdditiveReferencePoseTime: 0
|
||||||
m_StartTime: 0
|
m_StartTime: 0
|
||||||
m_StopTime: 0.4
|
m_StopTime: 0.4166667
|
||||||
m_OrientationOffsetY: 0
|
m_OrientationOffsetY: 0
|
||||||
m_Level: 0
|
m_Level: 0
|
||||||
m_CycleOffset: 0
|
m_CycleOffset: 0
|
||||||
@@ -88,4 +88,11 @@ AnimationClip:
|
|||||||
m_EulerEditorCurves: []
|
m_EulerEditorCurves: []
|
||||||
m_HasGenericRootTransform: 0
|
m_HasGenericRootTransform: 0
|
||||||
m_HasMotionFloatCurves: 0
|
m_HasMotionFloatCurves: 0
|
||||||
m_Events: []
|
m_Events:
|
||||||
|
- time: 0.4
|
||||||
|
functionName: OnAnimationComplete
|
||||||
|
data:
|
||||||
|
objectReferenceParameter: {fileID: 0}
|
||||||
|
floatParameter: 0
|
||||||
|
intParameter: 0
|
||||||
|
messageOptions: 0
|
||||||
|
|||||||
@@ -97,4 +97,11 @@ AnimationClip:
|
|||||||
m_EulerEditorCurves: []
|
m_EulerEditorCurves: []
|
||||||
m_HasGenericRootTransform: 0
|
m_HasGenericRootTransform: 0
|
||||||
m_HasMotionFloatCurves: 0
|
m_HasMotionFloatCurves: 0
|
||||||
m_Events: []
|
m_Events:
|
||||||
|
- time: 0.4
|
||||||
|
functionName: OnAnimationComplete
|
||||||
|
data:
|
||||||
|
objectReferenceParameter: {fileID: 0}
|
||||||
|
floatParameter: 0
|
||||||
|
intParameter: 0
|
||||||
|
messageOptions: 0
|
||||||
|
|||||||
@@ -115,4 +115,11 @@ AnimationClip:
|
|||||||
m_EulerEditorCurves: []
|
m_EulerEditorCurves: []
|
||||||
m_HasGenericRootTransform: 0
|
m_HasGenericRootTransform: 0
|
||||||
m_HasMotionFloatCurves: 0
|
m_HasMotionFloatCurves: 0
|
||||||
m_Events: []
|
m_Events:
|
||||||
|
- time: 0.8
|
||||||
|
functionName: BreakOrMiss
|
||||||
|
data:
|
||||||
|
objectReferenceParameter: {fileID: 0}
|
||||||
|
floatParameter: 0
|
||||||
|
intParameter: 0
|
||||||
|
messageOptions: 0
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ SpriteRenderer:
|
|||||||
m_GlobalIlluminationMeshLod: 0
|
m_GlobalIlluminationMeshLod: 0
|
||||||
m_SortingLayerID: 0
|
m_SortingLayerID: 0
|
||||||
m_SortingLayer: 0
|
m_SortingLayer: 0
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: 5
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_Sprite: {fileID: 4117774916817282162, guid: 46b32f517887e6d059266daadf89f6a6, type: 3}
|
m_Sprite: {fileID: 4117774916817282162, guid: 46b32f517887e6d059266daadf89f6a6, type: 3}
|
||||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
@@ -226,3 +226,11 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: e1946b527c8b37475beebe4e5bfc084a, type: 3}
|
m_Script: {fileID: 11500000, guid: e1946b527c8b37475beebe4e5bfc084a, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::YummyCake
|
m_EditorClassIdentifier: Assembly-CSharp::YummyCake
|
||||||
|
spawnSound: {fileID: 8300000, guid: 0c67dc4527cf24c19b6ca842257448f7, type: 3}
|
||||||
|
breakSound: {fileID: 8300000, guid: b839cbf5c672cf9aa899a3cea60865fe, type: 3}
|
||||||
|
missedSound: {fileID: 8300000, guid: 41540c042108a6b488e31a939b052446, type: 3}
|
||||||
|
stormSound: {fileID: 8300000, guid: c316f4b1d905a7bcfb855522802a7c73, type: 3}
|
||||||
|
lightningPrefab: {fileID: 2777603046878436080, guid: 475671cb1d96e3031a55f60143717ba1, type: 3}
|
||||||
|
laserPrefab: {fileID: 6002964310686798715, guid: 28823b745fceab0bba4430c17855252e, type: 3}
|
||||||
|
magnetPrefab: {fileID: 5157722627819042217, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
||||||
|
keyPrefab: {fileID: 725846353995077054, guid: 9d7c5ac60f0e549448022027ea4165e8, type: 3}
|
||||||
|
|||||||
@@ -572,7 +572,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 236182126}
|
m_GameObject: {fileID: 236182126}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: -0.24211, y: -0.24618, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
@@ -590,6 +590,8 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: fca49826eed1e6b2eb4be6ccac32574f, type: 3}
|
m_Script: {fileID: 11500000, guid: fca49826eed1e6b2eb4be6ccac32574f, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::CakeSpawner
|
m_EditorClassIdentifier: Assembly-CSharp::CakeSpawner
|
||||||
|
cakePrefab: {fileID: 2844589349164124371, guid: 5d4e6d6eee86e410bbf4d9c5ed9a6cdb, type: 3}
|
||||||
|
gameBoardSpriteRenderer: {fileID: 297740151}
|
||||||
--- !u!1 &240489635
|
--- !u!1 &240489635
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -961,63 +963,6 @@ Transform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 2111939185}
|
m_Father: {fileID: 2111939185}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1001 &737053983
|
|
||||||
PrefabInstance:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Modification:
|
|
||||||
serializedVersion: 3
|
|
||||||
m_TransformParent: {fileID: 0}
|
|
||||||
m_Modifications:
|
|
||||||
- target: {fileID: 1112612762832508471, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.x
|
|
||||||
value: -1.9606804
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1112612762832508471, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.y
|
|
||||||
value: -0.15573257
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1112612762832508471, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
|
||||||
propertyPath: m_LocalPosition.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1112612762832508471, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.w
|
|
||||||
value: 1
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1112612762832508471, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1112612762832508471, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1112612762832508471, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
|
||||||
propertyPath: m_LocalRotation.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1112612762832508471, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.x
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1112612762832508471, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.y
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 1112612762832508471, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
|
||||||
propertyPath: m_LocalEulerAnglesHint.z
|
|
||||||
value: 0
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 5157722627819042217, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
|
||||||
propertyPath: m_Name
|
|
||||||
value: Yummy Magnet
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
m_RemovedComponents: []
|
|
||||||
m_RemovedGameObjects: []
|
|
||||||
m_AddedGameObjects: []
|
|
||||||
m_AddedComponents: []
|
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 4f4c1cdc55e819e9e9f186af4b6e9da9, type: 3}
|
|
||||||
--- !u!1 &739145244
|
--- !u!1 &739145244
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -2851,4 +2796,3 @@ SceneRoots:
|
|||||||
- {fileID: 292763468}
|
- {fileID: 292763468}
|
||||||
- {fileID: 40868030}
|
- {fileID: 40868030}
|
||||||
- {fileID: 1162851830}
|
- {fileID: 1162851830}
|
||||||
- {fileID: 737053983}
|
|
||||||
|
|||||||
@@ -31,17 +31,17 @@ public class BallSpawner : MonoBehaviour
|
|||||||
|
|
||||||
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
// ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
// ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
// ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(oozeBallPrefab));
|
// ballQueue.Enqueue(() => SpawnBall(oozeBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(nuclearBallPrefab));
|
// ballQueue.Enqueue(() => SpawnBall(nuclearBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBall(eyeBallPrefab));
|
// ballQueue.Enqueue(() => SpawnBall(eyeBallPrefab));
|
||||||
|
|
||||||
StartCoroutine(SpawnBalls());
|
StartCoroutine(SpawnBalls());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,74 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class CakeSpawner : MonoBehaviour
|
public class CakeSpawner : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public GameObject cakePrefab;
|
||||||
|
|
||||||
|
public SpriteRenderer gameBoardSpriteRenderer;
|
||||||
|
|
||||||
|
private Bounds cakeBounds;
|
||||||
|
|
||||||
|
private Bounds gameBoardBounds;
|
||||||
|
|
||||||
|
private float spawnTimer = 0f;
|
||||||
|
|
||||||
|
private float spawnInterval = 10f;
|
||||||
|
|
||||||
|
private Vector2 spawnPosition;
|
||||||
|
|
||||||
|
private bool spawned = false;
|
||||||
|
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
|
gameBoardBounds = gameBoardSpriteRenderer.bounds;
|
||||||
|
cakeBounds = cakePrefab.GetComponent<SpriteRenderer>().bounds;
|
||||||
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void FixedUpdate()
|
||||||
{
|
{
|
||||||
|
if (!spawned)
|
||||||
|
{
|
||||||
|
spawnTimer += Time.fixedDeltaTime;
|
||||||
|
|
||||||
|
if (spawnTimer >= 1f)
|
||||||
|
{
|
||||||
|
spawnTimer = 0f;
|
||||||
|
if (Random.value < spawnProbability)
|
||||||
|
{
|
||||||
|
GameObject cake = Instantiate(cakePrefab, spawnPosition, Quaternion.identity);
|
||||||
|
}
|
||||||
|
|
||||||
|
spawned = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
spawnTimer += Time.fixedDeltaTime;
|
||||||
|
|
||||||
|
if (spawnTimer >= spawnInterval)
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
spawned = false;
|
||||||
|
spawnTimer = 0f;
|
||||||
|
spawnPosition = new Vector2(
|
||||||
|
Random.Range(
|
||||||
|
gameBoardBounds.min.x + cakeBounds.extents.x,
|
||||||
|
gameBoardBounds.max.x - cakeBounds.extents.x
|
||||||
|
),
|
||||||
|
Random.Range(
|
||||||
|
gameBoardBounds.min.y + cakeBounds.extents.y,
|
||||||
|
gameBoardBounds.max.y - cakeBounds.extents.y
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,115 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class YummyCake : MonoBehaviour
|
public class YummyCake : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public AudioClip spawnSound;
|
||||||
|
|
||||||
|
public AudioClip breakSound;
|
||||||
|
|
||||||
|
public AudioClip missedSound;
|
||||||
|
|
||||||
|
public AudioClip stormSound;
|
||||||
|
|
||||||
|
public GameObject lightningPrefab;
|
||||||
|
|
||||||
|
public GameObject laserPrefab;
|
||||||
|
|
||||||
|
public GameObject magnetPrefab;
|
||||||
|
|
||||||
|
public GameObject keyPrefab;
|
||||||
|
|
||||||
|
private AudioSource audioSource;
|
||||||
|
|
||||||
|
private Animator animator;
|
||||||
|
|
||||||
|
private static float laserProbability = 0.4f;
|
||||||
|
|
||||||
|
private static float magnetProbability = 0.2f;
|
||||||
|
|
||||||
|
private static float keyProbability = 0.1f;
|
||||||
|
|
||||||
|
private static float manyProbability = 0.2f;
|
||||||
|
|
||||||
|
private static float stormProbability = 0.01f;
|
||||||
|
|
||||||
// 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()
|
||||||
{
|
{
|
||||||
|
audioSource = GetComponent<AudioSource>();
|
||||||
|
animator = GetComponent<Animator>();
|
||||||
|
|
||||||
|
audioSource.PlayOneShot(spawnSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
public void BreakOrMiss()
|
||||||
void Update()
|
|
||||||
{
|
{
|
||||||
|
// TODO: Implement logic to check if the cake is in a clear area or not
|
||||||
|
bool inClearArea = true;
|
||||||
|
|
||||||
|
if (inClearArea)
|
||||||
|
{
|
||||||
|
animator.SetTrigger("break");
|
||||||
|
audioSource.PlayOneShot(breakSound);
|
||||||
|
Break();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
animator.SetTrigger("miss");
|
||||||
|
audioSource.PlayOneShot(missedSound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnAnimationComplete()
|
||||||
|
{
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SpawnItem(float randomValue)
|
||||||
|
{
|
||||||
|
if (randomValue < laserProbability)
|
||||||
|
{
|
||||||
|
Instantiate(laserPrefab, transform.position, Quaternion.identity);
|
||||||
|
}
|
||||||
|
else if (randomValue < magnetProbability)
|
||||||
|
{
|
||||||
|
Instantiate(magnetPrefab, transform.position, Quaternion.identity);
|
||||||
|
}
|
||||||
|
else if (randomValue < keyProbability)
|
||||||
|
{
|
||||||
|
Instantiate(keyPrefab, transform.position, Quaternion.identity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Instantiate(lightningPrefab, transform.position, Quaternion.identity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Break()
|
||||||
|
{
|
||||||
|
float isStorm = Random.value;
|
||||||
|
|
||||||
|
if (isStorm < stormProbability)
|
||||||
|
{
|
||||||
|
// Trigger a storm event, ie. spawn multiple items at once.
|
||||||
|
audioSource.PlayOneShot(stormSound);
|
||||||
|
|
||||||
|
for (int i = 0; i < Random.Range(8, 12); i++)
|
||||||
|
{
|
||||||
|
float randomValue = Random.value;
|
||||||
|
SpawnItem(randomValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The first yummy is guaranteed.
|
||||||
|
float randomValue = 0.0f;
|
||||||
|
|
||||||
|
while (randomValue < manyProbability)
|
||||||
|
{
|
||||||
|
SpawnItem(randomValue);
|
||||||
|
|
||||||
|
// Update randomValue to determine if we should spawn another item.
|
||||||
|
randomValue = Random.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user