TO SQUASH: Added shooting bars.

This commit is contained in:
2026-08-05 01:23:47 -04:00
parent 2c7e02887c
commit c91a405227
30 changed files with 7987 additions and 98 deletions
@@ -0,0 +1,283 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6045656660314469869
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5754140531426244356}
- component: {fileID: 8878076153969191535}
- component: {fileID: 5760720418200768735}
- component: {fileID: 3481259746481196927}
- component: {fileID: 2434502986484813791}
- component: {fileID: 8090287860417864703}
m_Layer: 0
m_Name: Horizontal Bar Component
m_TagString: Bar
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5754140531426244356
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6045656660314469869}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -5.0581875, y: 0.012736097, 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}
--- !u!212 &8878076153969191535
SpriteRenderer:
serializedVersion: 2
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6045656660314469869}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 5
m_MaskInteraction: 0
m_Sprite: {fileID: 532642863005658806, guid: 7d0a3c1274510d13a804de3f4be7e51f, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.08, y: 0.08}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_SpriteSortPoint: 0
--- !u!50 &5760720418200768735
Rigidbody2D:
serializedVersion: 5
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6045656660314469869}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDamping: 0
m_AngularDamping: 0.05
m_GravityScale: 0
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
--- !u!61 &3481259746481196927
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6045656660314469869}
m_Enabled: 1
serializedVersion: 3
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 1
m_UsedByEffector: 0
m_CompositeOperation: 0
m_CompositeOrder: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 0.08, y: 0.08}
newSize: {x: 0.08, y: 0.08}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_Size: {x: 0.08, y: 0.08}
m_EdgeRadius: 0
--- !u!114 &2434502986484813791
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6045656660314469869}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3f0f68050bf7251f7b0cac4505293fdc, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::HorizontalBar
firingSpeed: 0.03
horizontalBarrierPrefab: {fileID: 6045656660314469869}
canFireLeft: 1
canFireRight: 1
--- !u!82 &8090287860417864703
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6045656660314469869}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_Resource: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8fb281a5d3d9d99a0b13f951411400d9
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,283 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &948828080438803601
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1697634458930858322}
- component: {fileID: 1849045566778591861}
- component: {fileID: 1987224571519861697}
- component: {fileID: 4804822550127036516}
- component: {fileID: 5108727075007826851}
- component: {fileID: 1413000076055301866}
m_Layer: 0
m_Name: Vertical Bar Component
m_TagString: Bar
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1697634458930858322
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 948828080438803601}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -4.9333987, y: -1.1103609, 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}
--- !u!212 &1849045566778591861
SpriteRenderer:
serializedVersion: 2
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 948828080438803601}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 5
m_MaskInteraction: 0
m_Sprite: {fileID: 4808244930049875026, guid: 05db7adce83fc6c79950c15e05c65b7e, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.08, y: 0.08}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_SpriteSortPoint: 0
--- !u!61 &1987224571519861697
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 948828080438803601}
m_Enabled: 1
serializedVersion: 3
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 1
m_UsedByEffector: 0
m_CompositeOperation: 0
m_CompositeOrder: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 0.08, y: 0.08}
newSize: {x: 0.08, y: 0.08}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_Size: {x: 0.08, y: 0.08}
m_EdgeRadius: 0
--- !u!50 &4804822550127036516
Rigidbody2D:
serializedVersion: 5
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 948828080438803601}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDamping: 0
m_AngularDamping: 0.05
m_GravityScale: 0
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
--- !u!82 &5108727075007826851
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 948828080438803601}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_Resource: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &1413000076055301866
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 948828080438803601}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6dc29ecf320c579669972d171a926ff4, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::VerticalBar
firingSpeed: 0.03
verticalBarrierPrefab: {fileID: 948828080438803601}
canFireTop: 1
canFireBottom: 1
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8f1d5e2433b831ebabec25f47dcd071b
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+3 -1
View File
@@ -1263,7 +1263,7 @@ GameObject:
- component: {fileID: 1002905793}
m_Layer: 0
m_Name: Player
m_TagString: Untagged
m_TagString: Player
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -1407,6 +1407,8 @@ MonoBehaviour:
defeat: {fileID: 8300000, guid: ee144100b299499cab684e20021c6392, type: 3}
musicManager: {fileID: 933658174}
fader: {fileID: 40868033}
horizontalBarrierPrefab: {fileID: 6045656660314469869, guid: 8fb281a5d3d9d99a0b13f951411400d9, type: 3}
verticalBarrierPrefab: {fileID: 948828080438803601, guid: 8f1d5e2433b831ebabec25f47dcd071b, type: 3}
--- !u!58 &1002905793
CircleCollider2D:
m_ObjectHideFlags: 0
+40
View File
@@ -0,0 +1,40 @@
using UnityEngine;
public class BallBase : MonoBehaviour
{
public AudioClip spawnSound;
public AudioClip bounceSound;
public AudioClip hitSound;
protected Animator animator;
protected AudioSource audioSource;
protected Vector2 speed;
void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.CompareTag("Bar"))
{
audioSource.PlayOneShot(hitSound);
// Destroy all bar segments when the ball hits a bar.
var barSegments = GameObject.FindGameObjectsWithTag("Bar");
foreach (var barSegment in barSegments)
{
Destroy(barSegment);
}
// Notify the player that the bar has been hit.
var player = GameObject.FindGameObjectWithTag("Player");
if (player != null)
{
player.GetComponent<Player>().OnBarHit();
}
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d18fc23633602a1af955e537c3ec7f6f
+1 -13
View File
@@ -1,19 +1,7 @@
using UnityEngine;
public class BasicBall : MonoBehaviour
public class BasicBall : BallBase
{
private Animator animator;
public AudioClip spawnSound;
public AudioClip bounceSound;
public AudioClip hitSound;
private AudioSource audioSource;
private Vector2 speed;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
+3 -13
View File
@@ -1,19 +1,7 @@
using UnityEngine;
public class EyeBall : MonoBehaviour
public class EyeBall : BallBase
{
private Animator animator;
public AudioClip spawnSound;
public AudioClip bounceSound;
public AudioClip hitSound;
private AudioSource audioSource;
private Vector2 speed;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
@@ -29,6 +17,8 @@ public class EyeBall : MonoBehaviour
{
AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);
// TODO: Adjust eye ball direction based on the player's bar if active.
if (stateInfo.IsName("EyeBallMove")) {
transform.Translate(speed);
}
+1 -13
View File
@@ -1,19 +1,7 @@
using UnityEngine;
public class FruitBall : MonoBehaviour
public class FruitBall : BallBase
{
private Animator animator;
public AudioClip spawnSound;
public AudioClip bounceSound;
public AudioClip hitSound;
private AudioSource audioSource;
private Vector2 speed;
private float speedMultiplier = 1.0f;
private float speedIncreaseTimer = 0.0f;
+64 -17
View File
@@ -1,24 +1,18 @@
using UnityEngine;
using System.Collections;
public class GlassBall : MonoBehaviour
public class GlassBall : BallBase
{
private Animator animator;
public AudioClip spawnSound;
public AudioClip bounceSound;
public AudioClip hitSound;
public AudioClip breakSound;
private AudioSource audioSource;
private Vector2 speed;
private int health = 3;
private bool isBroken = false;
private float damageTimer = 0.0f;
private float damageCooldown = 0.5f;
private SpriteRenderer spriteRenderer;
// Start is called once before the first execution of Update after the MonoBehaviour is created
@@ -35,6 +29,11 @@ public class GlassBall : MonoBehaviour
// Update is called once per frame
void FixedUpdate()
{
if (damageTimer > 0.0f)
{
damageTimer -= Time.fixedDeltaTime;
}
AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);
if (stateInfo.IsName("GlassBallMove1") ||
@@ -54,10 +53,22 @@ public class GlassBall : MonoBehaviour
speed = Vector2.Reflect(speed, contact.normal);
// Glass balls take damage when colliding with other GlassBalls
// TODO: Check for collisions with a bar.
if (collision.gameObject.CompareTag("GlassBall"))
{
Damage();
}
}
}
private void Damage()
{
if (isBroken || damageTimer > 0.0f)
{
return;
}
health--;
damageTimer = damageCooldown;
if (health < 0)
{
@@ -69,17 +80,29 @@ public class GlassBall : MonoBehaviour
if (health > 0)
{
audioSource.PlayOneShot(hitSound);
} else
}
else
{
audioSource.PlayOneShot(breakSound);
}
}
}
}
public void Break()
{
if (isBroken)
{
return;
}
isBroken = true;
spriteRenderer.enabled = false;
var collider = GetComponent<Collider2D>();
if (collider != null)
{
collider.enabled = false;
}
StartCoroutine(BreakCoroutine());
}
@@ -89,4 +112,28 @@ public class GlassBall : MonoBehaviour
Destroy(gameObject);
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.CompareTag("Bar"))
{
Damage();
// Destroy all bar segments when the ball hits a bar.
var barSegments = GameObject.FindGameObjectsWithTag("Bar");
foreach (var barSegment in barSegments)
{
Destroy(barSegment);
}
// Notify the player that the bar has been hit.
var player = GameObject.FindGameObjectWithTag("Player");
if (player != null)
{
player.GetComponent<Player>().OnBarHit();
}
}
}
}
+17 -13
View File
@@ -1,29 +1,19 @@
using UnityEngine;
public class NukeBall : MonoBehaviour
public class NukeBall : BallBase
{
private Animator animator;
public AudioClip spawnSound;
public AudioClip bounceSound;
public AudioClip hitSound;
public AudioClip criticalSound;
public AudioClip explosionSound;
private AudioSource audioSource;
private Vector2 speed;
// Tracks escalating danger/critical phases for audio cues.
private int criticalState = 0;
private float criticalTime = 1.0f;
private float criticalTimer = 0.0f;
// Initial resting height the ball bounces back toward after a floor hit.
private float height;
private Collider2D selfCollider;
@@ -41,13 +31,17 @@ public class NukeBall : MonoBehaviour
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
// Cache frequently used components once.
audioSource = GetComponent<AudioSource>();
animator = GetComponent<Animator>();
selfCollider = GetComponent<Collider2D>();
// Start with a small random horizontal drift.
speed = new Vector2(Random.Range(-0.09f, 0.09f), 0.0f);
height = GetComponent<Transform>().position.y;
fallTargetY = height;
// Find the closest valid floor point under the current position.
UpdateFallTargetFromCurrentPosition();
audioSource.PlayOneShot(spawnSound);
@@ -68,12 +62,14 @@ public class NukeBall : MonoBehaviour
bounceTimer += Time.fixedDeltaTime;
float t = Mathf.Clamp01(bounceTimer / bounceDuration);
// Ease-out ascent: fast start, gentle finish near target height.
float easedT = 1.0f - Mathf.Pow(1.0f - t, 2.0f);
currentPosition.y = Mathf.Lerp(bounceStartY, height, easedT);
if (t >= 1.0f)
{
// Reached top of bounce arc; resume falling phase.
isBouncingToHeight = false;
bounceTimer = 0.0f;
currentPosition.y = height;
@@ -85,6 +81,7 @@ public class NukeBall : MonoBehaviour
bounceTimer += Time.fixedDeltaTime;
float t = Mathf.Clamp01(bounceTimer / bounceDuration);
// Ease-in descent: gentle start, faster approach to floor.
float easedT = t * t;
currentPosition.y = Mathf.Lerp(height, fallTargetY, easedT);
@@ -110,6 +107,7 @@ public class NukeBall : MonoBehaviour
audioSource.PlayOneShot(criticalSound);
}
// Restart timing window for the next critical beep.
criticalTimer = 0.0f;
}
}
@@ -120,6 +118,8 @@ public class NukeBall : MonoBehaviour
if (collision.gameObject.CompareTag("Wall"))
{
ContactPoint2D contact = collision.GetContact(0);
// Reflect horizontal movement from wall surfaces.
speed = Vector2.Reflect(speed, contact.normal);
speed.y = 0.0f;
@@ -130,6 +130,8 @@ public class NukeBall : MonoBehaviour
{
isBouncingToHeight = true;
bounceTimer = 0.0f;
// Use exact contact point as bounce origin so visual contact feels grounded.
bounceStartY = contact.point.y;
fallTargetY = bounceStartY;
@@ -142,8 +144,10 @@ public class NukeBall : MonoBehaviour
private void UpdateFallTargetFromCurrentPosition()
{
// Default to current y in case no valid floor is found.
fallTargetY = transform.position.y;
// Probe straight down and choose nearest upward-facing wall surface.
RaycastHit2D[] hits = Physics2D.RaycastAll(transform.position, Vector2.down, 100.0f);
float closestDistance = float.MaxValue;
+1 -13
View File
@@ -1,16 +1,8 @@
using UnityEngine;
using System.Collections;
public class OozeBall : MonoBehaviour
public class OozeBall : BallBase
{
private Animator animator;
public AudioClip spawnSound;
public AudioClip bounceSound;
public AudioClip hitSound;
public AudioClip timerSound;
public AudioClip splitSound;
@@ -19,12 +11,8 @@ public class OozeBall : MonoBehaviour
public BallSpawner spawner;
private AudioSource audioSource;
private SpriteRenderer spriteRenderer;
private Vector2 speed;
private float splitTimer = 10.0f;
private float tickTimer = 0.5f;
+92
View File
@@ -0,0 +1,92 @@
using UnityEngine;
public class HorizontalBar : MonoBehaviour
{
public float firingSpeed = 0.03f;
public GameObject horizontalBarrierPrefab;
public bool canFireLeft = true;
public bool canFireRight = true;
private float firingTimer = 0.0f;
private Bounds bounds;
private bool canFire = true;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
SpriteRenderer spriteRenderer = GetComponent<SpriteRenderer>();
bounds = spriteRenderer.bounds;
var walls = GameObject.FindGameObjectsWithTag("Wall");
if (walls.Length > 0)
{
foreach (var wall in walls)
{
if (wall.GetComponent<Collider2D>().bounds.Intersects(bounds))
{
canFire = false;
break;
}
}
}
}
// Update is called once per frame
void FixedUpdate()
{
if (canFire)
{
firingTimer += Time.fixedDeltaTime;
if (firingTimer >= firingSpeed)
{
if (canFireLeft)
{
Vector3 leftSide = new Vector3(
bounds.min.x - (bounds.size.x / 2.0f),
bounds.center.y,
bounds.center.z
);
var left = Instantiate(horizontalBarrierPrefab, leftSide, Quaternion.identity);
var leftBarScript = left.GetComponent<HorizontalBar>();
leftBarScript.firingSpeed = firingSpeed;
leftBarScript.canFireRight = false;
Physics2D.IgnoreCollision(
left.GetComponent<Collider2D>(),
GetComponent<Collider2D>(),
true
);
}
if (canFireRight)
{
Vector3 rightSide = new Vector3(
bounds.max.x + (bounds.size.x / 2.0f),
bounds.center.y,
bounds.center.z
);
var right = Instantiate(horizontalBarrierPrefab, rightSide, Quaternion.identity);
var rightBarScript = right.GetComponent<HorizontalBar>();
rightBarScript.firingSpeed = firingSpeed;
rightBarScript.canFireLeft = false;
Physics2D.IgnoreCollision(
right.GetComponent<Collider2D>(),
GetComponent<Collider2D>(),
true
);
}
canFire = false;
}
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3f0f68050bf7251f7b0cac4505293fdc
+34 -2
View File
@@ -30,12 +30,18 @@ public class Player : MonoBehaviour
public Fader fader;
public GameObject horizontalBarrierPrefab;
public GameObject verticalBarrierPrefab;
private bool flipped = false;
private bool gameOver = false;
private AudioSource audioSource;
private bool canFire = true;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
@@ -65,8 +71,8 @@ public class Player : MonoBehaviour
Vector3 mouseWorld = cam.ScreenToWorldPoint(new Vector3(mouseScreen.x, mouseScreen.y, screenZ));
Vector3 extents = playerBounds.extents;
float clampedX = Mathf.Clamp(mouseWorld.x, boardBounds.min.x + extents.x, boardBounds.max.x - extents.x);
float clampedY = Mathf.Clamp(mouseWorld.y, boardBounds.min.y + extents.y, boardBounds.max.y - extents.y);
float clampedX = Mathf.Clamp(mouseWorld.x, boardBounds.min.x + extents.x / 2.0f, boardBounds.max.x - extents.x / 2.0f);
float clampedY = Mathf.Clamp(mouseWorld.y, boardBounds.min.y + extents.y / 2.0f, boardBounds.max.y - extents.y / 2.0f);
transform.position = new Vector3(clampedX, clampedY, transform.position.z);
@@ -85,6 +91,21 @@ public class Player : MonoBehaviour
}
}
if (Mouse.current.leftButton.wasPressedThisFrame && canFire)
{
canFire = false;
audioSource.PlayOneShot(normalShoot);
if (flipped)
{
Instantiate(verticalBarrierPrefab, transform.position, Quaternion.identity);
}
else
{
Instantiate(horizontalBarrierPrefab, transform.position, Quaternion.identity);
}
}
if (gameOver)
{
StartCoroutine(EndGame());
@@ -126,4 +147,15 @@ public class Player : MonoBehaviour
yield return new WaitForSeconds(1.3f);
fader.ResetFader();
}
public void BarrierFinished()
{
canFire = true;
}
public void OnBarHit()
{
// TODO: Lose a life or end the game
canFire = true; // Allow firing again after bar hit
}
}
+92
View File
@@ -0,0 +1,92 @@
using UnityEngine;
public class VerticalBar : MonoBehaviour
{
public float firingSpeed = 0.03f;
public GameObject verticalBarrierPrefab;
public bool canFireTop = true;
public bool canFireBottom = true;
private float firingTimer = 0.0f;
private Bounds bounds;
private bool canFire = true;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
SpriteRenderer spriteRenderer = GetComponent<SpriteRenderer>();
bounds = spriteRenderer.bounds;
var walls = GameObject.FindGameObjectsWithTag("Wall");
if (walls.Length > 0)
{
foreach (var wall in walls)
{
if (wall.GetComponent<Collider2D>().bounds.Intersects(bounds))
{
canFire = false;
break;
}
}
}
}
// Update is called once per frame
void FixedUpdate()
{
if (canFire)
{
firingTimer += Time.fixedDeltaTime;
if (firingTimer >= firingSpeed)
{
if (canFireTop)
{
Vector3 topSide = new Vector3(
bounds.center.x,
bounds.max.y + (bounds.size.y / 2.0f),
bounds.center.z
);
var top = Instantiate(verticalBarrierPrefab, topSide, Quaternion.identity);
var topBarScript = top.GetComponent<VerticalBar>();
topBarScript.firingSpeed = firingSpeed;
topBarScript.canFireBottom = false;
Physics2D.IgnoreCollision(
top.GetComponent<Collider2D>(),
GetComponent<Collider2D>(),
true
);
}
if (canFireBottom)
{
Vector3 bottomSide = new Vector3(
bounds.center.x,
bounds.min.y - (bounds.size.y / 2.0f),
bounds.center.z
);
var bottom = Instantiate(verticalBarrierPrefab, bottomSide, Quaternion.identity);
var bottomBarScript = bottom.GetComponent<VerticalBar>();
bottomBarScript.firingSpeed = firingSpeed;
bottomBarScript.canFireTop = false;
Physics2D.IgnoreCollision(
bottom.GetComponent<Collider2D>(),
GetComponent<Collider2D>(),
true
);
}
canFire = false;
}
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6dc29ecf320c579669972d171a926ff4
Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

+169
View File
@@ -0,0 +1,169 @@
fileFormatVersion: 2
guid: 7d0a3c1274510d13a804de3f4be7e51f
TextureImporter:
internalIDToNameTable:
- first:
213: 532642863005658806
second: 200_0
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites:
- serializedVersion: 2
name: 200_0
rect:
serializedVersion: 2
x: 0
y: 0
width: 8
height: 8
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
physicsShape: []
tessellationDetail: -1
bones: []
spriteID: 6be6991acd3546700800000000000000
internalID: 532642863005658806
vertices: []
indices:
edges: []
weights: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable:
200_0: 532642863005658806
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

+169
View File
@@ -0,0 +1,169 @@
fileFormatVersion: 2
guid: 05db7adce83fc6c79950c15e05c65b7e
TextureImporter:
internalIDToNameTable:
- first:
213: 4808244930049875026
second: 202_0
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites:
- serializedVersion: 2
name: 202_0
rect:
serializedVersion: 2
x: 0
y: 0
width: 8
height: 8
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
physicsShape: []
tessellationDetail: -1
bones: []
spriteID: 25c12b8e9415ab240800000000000000
internalID: 4808244930049875026
vertices: []
indices:
edges: []
weights: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable:
202_0: 4808244930049875026
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b60e15ac5297128db91bd7464a5fbc6c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ae4332adf46faf14684b880670f0cc7e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f982ad294d90a2ffe9d4c5c5eaa1e3c0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ea70cd381aea7e05f8e3d99dd4692604
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+1
View File
@@ -12,6 +12,7 @@ TagManager:
- GlassBall
- NuclearBall
- EyeBall
- Bar
layers:
- Default
- TransparentFX