TO SQUASH: Yummy text on get.

This commit is contained in:
2026-08-27 21:51:28 -04:00
parent 67fc884bc4
commit ba1a7ba281
16 changed files with 496 additions and 71 deletions
+207
View File
@@ -0,0 +1,207 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!128 &12800000
Font:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 132
serializedVersion: 5
m_LineSpacing: 10
m_DefaultMaterial: {fileID: 2100000, guid: 5afa1c8a35a7fafb3927ead4bba3e3c2, type: 2}
m_FontSize: 10
m_Texture: {fileID: 0}
m_AsciiStartOffset: 0
m_Tracking: 1
m_CharacterSpacing: 0
m_CharacterPadding: 1
m_ConvertCase: 0
m_CharacterRects:
- serializedVersion: 2
index: 48
uv:
serializedVersion: 2
x: 0.010989011
y: 0.083333336
width: 0.08901099
height: 0.8333334
vert:
serializedVersion: 2
x: 0
y: 11
width: 8
height: -10
advance: 8
flipped: 0
- serializedVersion: 2
index: 49
uv:
serializedVersion: 2
x: 0.12197802
y: 0.083333336
width: 0.05604396
height: 0.8333334
vert:
serializedVersion: 2
x: 0
y: 11
width: 5
height: -10
advance: 5
flipped: 0
- serializedVersion: 2
index: 50
uv:
serializedVersion: 2
x: 0.21098901
y: 0.083333336
width: 0.089011
height: 0.8333334
vert:
serializedVersion: 2
x: 0
y: 11
width: 8
height: -10
advance: 8
flipped: 0
- serializedVersion: 2
index: 51
uv:
serializedVersion: 2
x: 0.31098902
y: 0.083333336
width: 0.08901098
height: 0.8333334
vert:
serializedVersion: 2
x: 0
y: 11
width: 8
height: -10
advance: 8
flipped: 0
- serializedVersion: 2
index: 52
uv:
serializedVersion: 2
x: 0.41098902
y: 0.083333336
width: 0.08901098
height: 0.8333334
vert:
serializedVersion: 2
x: 0
y: 11
width: 8
height: -10
advance: 8
flipped: 0
- serializedVersion: 2
index: 53
uv:
serializedVersion: 2
x: 0.510989
y: 0.083333336
width: 0.08901101
height: 0.8333334
vert:
serializedVersion: 2
x: 0
y: 11
width: 8
height: -10
advance: 8
flipped: 0
- serializedVersion: 2
index: 54
uv:
serializedVersion: 2
x: 0.61098903
y: 0.083333336
width: 0.089010954
height: 0.8333334
vert:
serializedVersion: 2
x: 0
y: 11
width: 8
height: -10
advance: 8
flipped: 0
- serializedVersion: 2
index: 55
uv:
serializedVersion: 2
x: 0.710989
y: 0.083333336
width: 0.08901101
height: 0.8333334
vert:
serializedVersion: 2
x: 0
y: 11
width: 8
height: -10
advance: 8
flipped: 0
- serializedVersion: 2
index: 56
uv:
serializedVersion: 2
x: 0.810989
y: 0.083333336
width: 0.08901101
height: 0.8333334
vert:
serializedVersion: 2
x: 0
y: 11
width: 8
height: -10
advance: 8
flipped: 0
- serializedVersion: 2
index: 57
uv:
serializedVersion: 2
x: 0.91098905
y: 0.083333336
width: 0.089010954
height: 0.8333334
vert:
serializedVersion: 2
x: 0
y: 11
width: 8
height: -10
advance: 8
flipped: 0
- serializedVersion: 2
index: 32
uv:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
vert:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
advance: 5
flipped: 0
m_KerningValues: []
m_PixelScale: 0.1
m_FontData:
m_Ascent: 0
m_Descent: 0
m_DefaultStyle: 0
m_FontNames: []
m_FallbackFonts: []
m_FontRenderingMode: 0
m_UseLegacyBoundsCalculation: 0
m_ShouldRoundAdvanceValue: 1
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a92fd4457dff532d1a975bc99acc0b2f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 12800000
userData:
assetBundleName:
assetBundleVariant:
+34
View File
@@ -0,0 +1,34 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: 132
m_Shader: {fileID: 10750, guid: 0000000000000000f000000000000000, type: 0}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _MainTex:
m_Texture: {fileID: 2800000, guid: 84c81451dd6b9779da8a8ea915f98a0e, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats: []
m_Colors: []
m_BuildTextureStacks: []
m_AllowLocking: 1
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5afa1c8a35a7fafb3927ead4bba3e3c2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
+81
View File
@@ -0,0 +1,81 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6394082776706812922
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4855514124719701429}
- component: {fileID: 6307932829238842412}
- component: {fileID: 1224870225590696388}
m_Layer: 5
m_Name: Notification
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4855514124719701429
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6394082776706812922}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 43.71, y: 15}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6307932829238842412
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6394082776706812922}
m_CullTransparentMesh: 1
--- !u!114 &1224870225590696388
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6394082776706812922}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Text
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: a92fd4457dff532d1a975bc99acc0b2f, type: 2}
m_FontSize: 10
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 1
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text:
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5cb297a990ab535aa8ef2b8054c9db1b
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+2
View File
@@ -134,6 +134,8 @@ MonoBehaviour:
bounceSound: {fileID: 8300000, guid: 7be58b030ab9bdaf2bd958c7429e124d, type: 3}
obtainedSound: {fileID: 8300000, guid: 1f85e962911ceb001b0a2805ccb013b8, type: 3}
missedSound: {fileID: 8300000, guid: 0c158e62f1f2d993a970cf904495d4f7, type: 3}
canvas: {fileID: 0}
notificationPrefab: {fileID: 6394082776706812922, guid: 5cb297a990ab535aa8ef2b8054c9db1b, type: 3}
--- !u!50 &7735783136257186560
Rigidbody2D:
serializedVersion: 5
+2
View File
@@ -112,6 +112,8 @@ MonoBehaviour:
bounceSound: {fileID: 8300000, guid: 7be58b030ab9bdaf2bd958c7429e124d, type: 3}
obtainedSound: {fileID: 8300000, guid: 1f85e962911ceb001b0a2805ccb013b8, type: 3}
missedSound: {fileID: 8300000, guid: 0c158e62f1f2d993a970cf904495d4f7, type: 3}
canvas: {fileID: 0}
notificationPrefab: {fileID: 6394082776706812922, guid: 5cb297a990ab535aa8ef2b8054c9db1b, type: 3}
--- !u!95 &3075665739119614440
Animator:
serializedVersion: 7
+1
View File
@@ -1148,6 +1148,7 @@ MonoBehaviour:
cakePrefab: {fileID: 2844589349164124371, guid: 5d4e6d6eee86e410bbf4d9c5ed9a6cdb, type: 3}
gameBoardSpriteRenderer: {fileID: 297740151}
worldFiller: {fileID: 2071167548}
canvas: {fileID: 2071745861}
--- !u!1 &240489635
GameObject:
m_ObjectHideFlags: 0
@@ -8,6 +8,8 @@ public class CakeSpawner : Spawner
public WorldFiller worldFiller;
public Canvas canvas;
private Bounds cakeBounds;
private Bounds gameBoardBounds;
@@ -48,6 +50,7 @@ public class CakeSpawner : Spawner
if (Random.value < spawnProbability)
{
GameObject cake = Instantiate(cakePrefab, spawnPosition, Quaternion.identity);
cake.GetComponent<YummyCake>().canvas = canvas;
}
spawned = true;
+55
View File
@@ -9,6 +9,12 @@ public abstract class YummyBase : MonoBehaviour
public AudioClip missedSound;
public Canvas canvas;
public GameObject notificationPrefab;
protected GameObject notificationInstance;
private AudioSource audioSource;
private Animator animator;
@@ -113,4 +119,53 @@ public abstract class YummyBase : MonoBehaviour
}
protected abstract void ObtainedCallback(Player player);
protected void ShowNotification(string text)
{
if (notificationPrefab == null || canvas == null)
{
return;
}
notificationInstance = Instantiate(notificationPrefab);
notificationInstance.transform.SetParent(canvas.transform, false);
notificationInstance.transform.localScale = Vector3.one;
var notificationRect = notificationInstance.GetComponent<RectTransform>();
var canvasRect = canvas.GetComponent<RectTransform>();
var label = notificationInstance.GetComponent<UnityEngine.UI.Text>();
if (label != null)
{
label.text = text;
}
if (notificationRect != null && canvasRect != null)
{
Camera worldCamera = canvas.worldCamera != null ? canvas.worldCamera : Camera.main;
Camera uiCamera = canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : worldCamera;
if (worldCamera != null)
{
Vector2 screenPoint = worldCamera.WorldToScreenPoint(transform.position);
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, screenPoint, uiCamera, out Vector2 localPoint))
{
notificationRect.anchoredPosition = localPoint;
}
}
}
StartCoroutine(HideNotification());
}
protected IEnumerator HideNotification()
{
yield return new WaitForSeconds(1.5f);
if (notificationInstance != null)
{
Destroy(notificationInstance);
}
}
}
+23 -14
View File
@@ -18,13 +18,15 @@ public class YummyCake : MonoBehaviour
public GameObject keyPrefab;
public Canvas canvas;
private AudioSource audioSource;
private Animator animator;
private WorldFiller worldFiller;
private static float laserProbability = 0.4f;
private static float laserProbability = 0.25f;
private static float magnetProbability = 0.2f;
@@ -70,21 +72,31 @@ public class YummyCake : MonoBehaviour
private void SpawnItem(float randomValue)
{
if (randomValue < laserProbability)
float laserThreshold = laserProbability;
float magnetThreshold = laserThreshold + magnetProbability;
float keyThreshold = magnetThreshold + keyProbability;
GameObject item = null;
if (randomValue < laserThreshold)
{
Instantiate(laserPrefab, transform.position, Quaternion.identity);
item = Instantiate(laserPrefab, transform.position, Quaternion.identity);
}
else if (randomValue < magnetProbability)
else if (randomValue < magnetThreshold)
{
Instantiate(magnetPrefab, transform.position, Quaternion.identity);
item = Instantiate(magnetPrefab, transform.position, Quaternion.identity);
}
else if (randomValue < keyProbability)
else if (randomValue < keyThreshold)
{
Instantiate(keyPrefab, transform.position, Quaternion.identity);
item = Instantiate(keyPrefab, transform.position, Quaternion.identity);
}
else
{
Instantiate(lightningPrefab, transform.position, Quaternion.identity);
item = Instantiate(lightningPrefab, transform.position, Quaternion.identity);
}
if (item != null)
{
item.GetComponent<YummyBase>().canvas = canvas;
}
}
@@ -106,14 +118,11 @@ public class YummyCake : MonoBehaviour
else
{
// The first yummy is guaranteed.
float randomValue = 0.0f;
SpawnItem(Random.value);
while (randomValue < manyProbability)
while (Random.value < manyProbability)
{
SpawnItem(randomValue);
// Update randomValue to determine if we should spawn another item.
randomValue = Random.value;
SpawnItem(Random.value);
}
}
}
+1 -1
View File
@@ -4,6 +4,6 @@ public class YummyKey : YummyBase
{
protected override void ObtainedCallback(Player player)
{
player.lives += 1;
player.lives += Random.Range(1, 5);
}
}
+4 -1
View File
@@ -4,6 +4,9 @@ public class YummyLaser : YummyBase
{
protected override void ObtainedCallback(Player player)
{
player.laserCount += 1;
int awarded = Random.Range(1, 15);
player.laserCount += awarded;
ShowNotification($"{awarded}");
}
}
+4 -1
View File
@@ -4,6 +4,9 @@ public class YummyMagnet : YummyBase
{
protected override void ObtainedCallback(Player player)
{
player.magnetCount += 1;
int awarded = Random.Range(1, 15);
player.magnetCount += awarded;
ShowNotification($"{awarded}");
}
}
+56 -54
View File
@@ -51,7 +51,7 @@ TextureImporter:
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
@@ -64,7 +64,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 1
@@ -143,12 +143,12 @@ TextureImporter:
name: 132_0
rect:
serializedVersion: 2
x: 0
y: 0
width: 10
height: 12
x: 1
y: 1
width: 8
height: 10
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
@@ -165,12 +165,12 @@ TextureImporter:
name: 132_1
rect:
serializedVersion: 2
x: 10
y: 0
width: 7
height: 12
x: 11
y: 1
width: 5
height: 10
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
@@ -187,12 +187,12 @@ TextureImporter:
name: 132_2
rect:
serializedVersion: 2
x: 18
y: 0
width: 10
height: 12
x: 19
y: 1
width: 8
height: 10
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
@@ -209,12 +209,12 @@ TextureImporter:
name: 132_3
rect:
serializedVersion: 2
x: 27
y: 0
width: 10
height: 12
x: 28
y: 1
width: 8
height: 10
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
@@ -231,12 +231,12 @@ TextureImporter:
name: 132_4
rect:
serializedVersion: 2
x: 36
y: 0
width: 10
height: 12
x: 37
y: 1
width: 8
height: 10
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
@@ -253,12 +253,12 @@ TextureImporter:
name: 132_5
rect:
serializedVersion: 2
x: 45
y: 0
width: 10
height: 12
x: 46
y: 1
width: 8
height: 10
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
@@ -275,12 +275,12 @@ TextureImporter:
name: 132_6
rect:
serializedVersion: 2
x: 54
y: 0
width: 10
height: 12
x: 55
y: 1
width: 8
height: 10
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
@@ -297,12 +297,12 @@ TextureImporter:
name: 132_7
rect:
serializedVersion: 2
x: 63
y: 0
width: 10
height: 12
x: 64
y: 1
width: 8
height: 10
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
@@ -319,12 +319,12 @@ TextureImporter:
name: 132_8
rect:
serializedVersion: 2
x: 72
y: 0
width: 10
height: 12
x: 73
y: 1
width: 8
height: 10
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
@@ -341,12 +341,12 @@ TextureImporter:
name: 132_9
rect:
serializedVersion: 2
x: 81
y: 0
width: 10
height: 12
x: 82
y: 1
width: 8
height: 10
alignment: 0
pivot: {x: 0, y: 0}
pivot: {x: 0.5, y: 0.5}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
@@ -363,7 +363,7 @@ TextureImporter:
customData:
physicsShape: []
bones: []
spriteID:
spriteID: bd39c4c4e1ca95db285d4018da8cd638
internalID: 0
vertices: []
indices:
@@ -371,7 +371,9 @@ TextureImporter:
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
entries:
- key: SpriteEditor.SliceSettings
value: '{"sliceOnImport":false,"gridCellCount":{"x":1.0,"y":1.0},"gridSpriteSize":{"x":64.0,"y":64.0},"gridSpriteOffset":{"x":0.0,"y":0.0},"gridSpritePadding":{"x":0.0,"y":0.0},"pivot":{"x":0.5,"y":0.5},"pivotPixels":{"x":0.0,"y":0.0},"autoSlicingMethod":0,"spriteAlignment":0,"pivotUnitMode":0,"slicingType":0,"keepEmptyRects":false,"isAlternate":false}'
nameFileIdTable:
132_0: 7236970418971138015
132_1: 6748673850382762363