First go at bird pooper controller

This commit is contained in:
Michal Pikulski
2025-11-20 01:29:30 +01:00
parent 97921c3727
commit 635b74db0a
18 changed files with 905 additions and 104 deletions

View File

@@ -20,11 +20,6 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 9d4a355954ae0a544a9c2a8281bc4bee
m_Address: Settings/CardSortingSettings
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: d28c589c05c122f449a8b34e696cda53
m_Address: Puzzles/Quarry
m_ReadOnly: 0

View File

@@ -25,6 +25,11 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 35d377f68c0a6704d838fe69a20b4bb8
m_Address: Settings/BirdPooperSettings
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 44f8b357e56ef9d4784ec1b1df1a13a8
m_Address: Settings/Developer/DebugSettings
m_ReadOnly: 0
@@ -40,6 +45,11 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 9d4a355954ae0a544a9c2a8281bc4bee
m_Address: Settings/CardSortingSettings
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: a9569848f604a6540827d4d4bb0a35c2
m_Address: Settings/DivingMinigameSettings
m_ReadOnly: 0

View File

@@ -19,5 +19,7 @@ MonoBehaviour:
requiredOrientation: 1
- sceneName: DivingForPictures
requiredOrientation: 0
- sceneName: BirdB
requiredOrientation: 1
- sceneName: CardQualityControl
requiredOrientation: 1

View File

@@ -11,7 +11,7 @@ namespace AppleHills.Core.Settings.Editor
{
private Vector2 scrollPosition;
private List<BaseSettings> allSettings = new List<BaseSettings>();
private string[] tabNames = new string[] { "Player & Follower", "Interaction & Items", "Diving Minigame", "Card System", "Card Sorting" };
private string[] tabNames = new string[] { "Player & Follower", "Interaction & Items", "Diving Minigame", "Card System", "Card Sorting", "Bird Pooper" };
private int selectedTab = 0;
private Dictionary<string, SerializedObject> serializedSettingsObjects = new Dictionary<string, SerializedObject>();
private GUIStyle headerStyle;
@@ -51,6 +51,7 @@ namespace AppleHills.Core.Settings.Editor
CreateSettingsIfMissing<DivingMinigameSettings>("DivingMinigameSettings");
CreateSettingsIfMissing<CardSystemSettings>("CardSystemSettings");
CreateSettingsIfMissing<CardSortingSettings>("CardSortingSettings");
CreateSettingsIfMissing<BirdPooperSettings>("BirdPooperSettings");
}
private void CreateSettingsIfMissing<T>(string fileName) where T : BaseSettings
@@ -123,6 +124,9 @@ namespace AppleHills.Core.Settings.Editor
case 4: // Card Sorting
DrawSettingsEditor<CardSortingSettings>();
break;
case 5: // Bird Pooper
DrawSettingsEditor<BirdPooperSettings>();
break;
}
EditorGUILayout.EndScrollView();

File diff suppressed because one or more lines are too long

View File

@@ -198,6 +198,216 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &941621855
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 941621856}
- component: {fileID: 941621858}
- component: {fileID: 941621857}
- component: {fileID: 941621859}
m_Layer: 0
m_Name: Bird
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &941621856
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 941621855}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -15, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1631945780}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &941621857
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 941621855}
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: 0
m_UsedByEffector: 0
m_CompositeOperation: 0
m_CompositeOrder: 0
m_Offset: {x: 0.10795927, y: 0.15422785}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_Size: {x: 3.1489096, y: 3.1797535}
m_EdgeRadius: 0
--- !u!50 &941621858
Rigidbody2D:
serializedVersion: 5
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 941621855}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 1
m_Mass: 10.012756
m_LinearDamping: 0
m_AngularDamping: 0
m_GravityScale: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Interpolate: 0
m_SleepingMode: 0
m_CollisionDetection: 1
m_Constraints: 0
--- !u!114 &941621859
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 941621855}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2d56e44aad9044f8808b892c7a5cfc50, type: 3}
m_Name:
m_EditorClassIdentifier: AppleHillsScripts::Minigames.BirdPooper.BirdPlayerController
--- !u!1 &1631945779
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1631945780}
- component: {fileID: 1631945781}
m_Layer: 0
m_Name: Visual
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1631945780
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1631945779}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.2, y: -0.83, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 941621856}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1631945781
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1631945779}
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: 2100000, guid: 9dfc825aed78fcd4ba02077103263b40, type: 2}
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: 0
m_Sprite: {fileID: -1746001368592556769, guid: b91b56c53bc01e042a092ece12f32f86, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 3.62, y: 3.7}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1810521056
GameObject:
m_ObjectHideFlags: 0
@@ -362,7 +572,7 @@ Transform:
m_GameObject: {fileID: 1810521056}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -34.3, y: -36.3, z: -10}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@@ -478,7 +688,7 @@ Transform:
m_GameObject: {fileID: 2103114174}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -34.3, y: -36.3, z: -10}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@@ -489,5 +699,6 @@ SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 1810521061}
- {fileID: 580848255}
- {fileID: 2103114178}
- {fileID: 580848255}
- {fileID: 941621856}

View File

@@ -420,15 +420,15 @@ LineRenderer:
m_SortingOrder: 0
m_Positions:
- {x: -0.15602553, y: 4.074945, z: 0}
- {x: -0.1566351, y: 3.973638, z: 0}
- {x: -0.1572447, y: 3.8729856, z: 0}
- {x: -0.15785426, y: 3.7729874, z: 0}
- {x: -0.15846384, y: 3.6736436, z: 0}
- {x: -0.15907341, y: 3.574954, z: 0}
- {x: -0.15968299, y: 3.4769192, z: 0}
- {x: -0.16029257, y: 3.3795385, z: 0}
- {x: -0.16090216, y: 3.2828126, z: 0}
- {x: -0.16151173, y: 3.1867409, z: 0}
- {x: -0.1566351, y: 3.9736383, z: 0}
- {x: -0.1572447, y: 3.8729858, z: 0}
- {x: -0.15785426, y: 3.7729876, z: 0}
- {x: -0.15846384, y: 3.673644, z: 0}
- {x: -0.15907341, y: 3.5749545, z: 0}
- {x: -0.15968299, y: 3.4769197, z: 0}
- {x: -0.16029257, y: 3.379539, z: 0}
- {x: -0.16090216, y: 3.2828128, z: 0}
- {x: -0.16151173, y: 3.186741, z: 0}
- {x: -0.16212131, y: 3.0913236, z: 0}
m_Parameters:
serializedVersion: 3
@@ -1347,10 +1347,10 @@ RectTransform:
m_Children: []
m_Father: {fileID: 341271022}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 217.37007}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 52.88064, y: -106.98245}
m_SizeDelta: {x: 105.76128, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &495116985
MonoBehaviour:
@@ -2086,16 +2086,16 @@ LineRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_Positions:
- {x: -0.15602553, y: 4.0749445, z: 0}
- {x: -0.11662118, y: 3.879622, z: 0}
- {x: -0.07721684, y: 3.7057445, z: 0}
- {x: -0.03781248, y: 3.5533106, z: 0}
- {x: 0.0015918687, y: 3.4223216, z: 0}
- {x: 0.040996216, y: 3.3127766, z: 0}
- {x: -0.15602553, y: 4.074945, z: 0}
- {x: -0.11662118, y: 3.8796227, z: 0}
- {x: -0.07721684, y: 3.7057447, z: 0}
- {x: -0.03781248, y: 3.553311, z: 0}
- {x: 0.0015918687, y: 3.4223218, z: 0}
- {x: 0.040996216, y: 3.3127768, z: 0}
- {x: 0.08040057, y: 3.2246761, z: 0}
- {x: 0.11980491, y: 3.15802, z: 0}
- {x: 0.15920927, y: 3.1128082, z: 0}
- {x: 0.1986136, y: 3.0890405, z: 0}
- {x: 0.1986136, y: 3.0890408, z: 0}
- {x: 0.23801796, y: 3.0867176, z: 0}
m_Parameters:
serializedVersion: 3
@@ -2806,16 +2806,16 @@ LineRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_Positions:
- {x: -0.15602553, y: 4.0749445, z: 0}
- {x: -0.18956745, y: 3.8764973, z: 0}
- {x: -0.22310936, y: 3.7000232, z: 0}
- {x: -0.25665125, y: 3.5455203, z: 0}
- {x: -0.15602553, y: 4.074945, z: 0}
- {x: -0.18956745, y: 3.8764977, z: 0}
- {x: -0.22310936, y: 3.7000237, z: 0}
- {x: -0.25665125, y: 3.5455213, z: 0}
- {x: -0.29019317, y: 3.412991, z: 0}
- {x: -0.32373506, y: 3.3024335, z: 0}
- {x: -0.35727698, y: 3.2138484, z: 0}
- {x: -0.39081886, y: 3.1472359, z: 0}
- {x: -0.4243608, y: 3.1025958, z: 0}
- {x: -0.45790267, y: 3.0799282, z: 0}
- {x: -0.32373506, y: 3.302434, z: 0}
- {x: -0.35727698, y: 3.2138486, z: 0}
- {x: -0.39081886, y: 3.147236, z: 0}
- {x: -0.4243608, y: 3.1025963, z: 0}
- {x: -0.45790267, y: 3.0799284, z: 0}
- {x: -0.4914446, y: 3.079233, z: 0}
m_Parameters:
serializedVersion: 3

View File

@@ -171,6 +171,7 @@ namespace Core
var minigameSettings = SettingsProvider.Instance.LoadSettingsSynchronous<DivingMinigameSettings>();
var cardSystemSettings = SettingsProvider.Instance.LoadSettingsSynchronous<CardSystemSettings>();
var sortingGameSettings = SettingsProvider.Instance.LoadSettingsSynchronous<CardSortingSettings>();
var birdPooperSettings = SettingsProvider.Instance.LoadSettingsSynchronous<BirdPooperSettings>();
// Register settings with service locator
if (playerSettings != null)
@@ -222,9 +223,19 @@ namespace Core
{
Debug.LogError("Failed to load CardSystemSettings");
}
if (birdPooperSettings != null)
{
ServiceLocator.Register<IBirdPooperSettings>(birdPooperSettings);
Logging.Debug("BirdPooperSettings registered successfully");
}
else
{
Debug.LogError("Failed to load BirdPooperSettings");
}
// Log success
_settingsLoaded = playerSettings != null && interactionSettings != null && minigameSettings != null && cardSystemSettings != null;
_settingsLoaded = playerSettings != null && interactionSettings != null && minigameSettings != null && cardSystemSettings != null && birdPooperSettings != null;
if (_settingsLoaded)
{
Logging.Debug("All settings loaded and registered with ServiceLocator");

View File

@@ -0,0 +1,89 @@
using AppleHills.Core.Settings;
using UnityEngine;
namespace Core.Settings
{
[CreateAssetMenu(fileName = "BirdPooperSettings", menuName = "AppleHills/Settings/BirdPooper", order = 5)]
public class BirdPooperSettings : BaseSettings, IBirdPooperSettings
{
[Header("Player Controller")]
[Tooltip("Gravity acceleration in units/s²")]
[SerializeField] private float gravity = 20f;
[Tooltip("Upward velocity applied on flap in units/s")]
[SerializeField] private float flapForce = 8f;
[Tooltip("Maximum fall speed (terminal velocity) in units/s")]
[SerializeField] private float maxFallSpeed = 15f;
[Tooltip("Minimum Y boundary")]
[SerializeField] private float minY = -5f;
[Tooltip("Maximum Y boundary")]
[SerializeField] private float maxY = 5f;
[Header("Rotation")]
[Tooltip("Maximum rotation angle in degrees (positive = up, negative = down)")]
[SerializeField] private float maxRotationAngle = 30f;
[Tooltip("Speed of rotation interpolation (higher = snappier)")]
[SerializeField] private float rotationSpeed = 8f;
[Header("Obstacles")]
[Tooltip("Obstacle scroll speed in units/s")]
[SerializeField] private float obstacleMoveSpeed = 5f;
[Tooltip("Time between obstacle spawns in seconds")]
[SerializeField] private float obstacleSpawnInterval = 2f;
[Tooltip("X position where obstacles spawn (off-screen right)")]
[SerializeField] private float obstacleSpawnXPosition = 12f;
[Tooltip("X position where obstacles are destroyed (off-screen left)")]
[SerializeField] private float obstacleDestroyXPosition = -12f;
[Tooltip("Minimum Y position for obstacle spawns")]
[SerializeField] private float obstacleMinSpawnY = -3f;
[Tooltip("Maximum Y position for obstacle spawns")]
[SerializeField] private float obstacleMaxSpawnY = 3f;
[Header("Poop Projectile")]
[Tooltip("Poop fall speed in units/s")]
[SerializeField] private float poopFallSpeed = 10f;
[Tooltip("Y position where poop is destroyed (off-screen bottom)")]
[SerializeField] private float poopDestroyYPosition = -10f;
// Interface implementation
public float Gravity => gravity;
public float FlapForce => flapForce;
public float MaxFallSpeed => maxFallSpeed;
public float MinY => minY;
public float MaxY => maxY;
public float MaxRotationAngle => maxRotationAngle;
public float RotationSpeed => rotationSpeed;
public float ObstacleMoveSpeed => obstacleMoveSpeed;
public float ObstacleSpawnInterval => obstacleSpawnInterval;
public float ObstacleSpawnXPosition => obstacleSpawnXPosition;
public float ObstacleDestroyXPosition => obstacleDestroyXPosition;
public float ObstacleMinSpawnY => obstacleMinSpawnY;
public float ObstacleMaxSpawnY => obstacleMaxSpawnY;
public float PoopFallSpeed => poopFallSpeed;
public float PoopDestroyYPosition => poopDestroyYPosition;
public override void OnValidate()
{
base.OnValidate();
// Validation logic
gravity = Mathf.Max(0f, gravity);
flapForce = Mathf.Max(0f, flapForce);
maxFallSpeed = Mathf.Max(0f, maxFallSpeed);
maxRotationAngle = Mathf.Clamp(maxRotationAngle, 0f, 90f);
rotationSpeed = Mathf.Max(0.1f, rotationSpeed);
obstacleSpawnInterval = Mathf.Max(0.1f, obstacleSpawnInterval);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e7d3f5b948b3454681fa573071bee978
timeCreated: 1763596494

View File

@@ -0,0 +1,33 @@
namespace Core.Settings
{
/// <summary>
/// Settings interface for Bird Pooper minigame.
/// Accessed via GameManager.GetSettingsObject<IBirdPooperSettings>()
/// </summary>
public interface IBirdPooperSettings
{
// Player Controller
float Gravity { get; }
float FlapForce { get; }
float MaxFallSpeed { get; }
float MinY { get; }
float MaxY { get; }
// Rotation
float MaxRotationAngle { get; }
float RotationSpeed { get; }
// Obstacles
float ObstacleMoveSpeed { get; }
float ObstacleSpawnInterval { get; }
float ObstacleSpawnXPosition { get; }
float ObstacleDestroyXPosition { get; }
float ObstacleMinSpawnY { get; }
float ObstacleMaxSpawnY { get; }
// Poop Projectile
float PoopFallSpeed { get; }
float PoopDestroyYPosition { get; }
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 66509e37e0a549a79de6fe3fa710fd63
timeCreated: 1763596482

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: fa5389b421944c6e8f43d7fad84ef470
timeCreated: 1763596581

View File

@@ -0,0 +1,183 @@
using Core;
using Core.Lifecycle;
using Core.Settings;
using UnityEngine;
namespace Minigames.BirdPooper
{
/// <summary>
/// Bird player controller with Flappy Bird-style flight mechanics.
/// Responds to tap input to flap, with manual gravity simulation.
/// </summary>
public class BirdPlayerController : ManagedBehaviour, ITouchInputConsumer
{
private Rigidbody2D rb;
private IBirdPooperSettings settings;
private float verticalVelocity = 0f;
private bool isDead = false;
private float fixedXPosition; // Store the initial X position from the scene
internal override void OnManagedAwake()
{
base.OnManagedAwake();
// Load settings
settings = GameManager.GetSettingsObject<IBirdPooperSettings>();
if (settings == null)
{
Debug.LogError("[BirdPlayerController] BirdPooperSettings not found!");
return;
}
// Get Rigidbody2D component (Dynamic with gravityScale = 0)
rb = GetComponent<Rigidbody2D>();
if (rb != null)
{
rb.gravityScale = 0f; // Disable Unity physics gravity
rb.bodyType = RigidbodyType2D.Dynamic;
// Store the initial X position from the scene
fixedXPosition = rb.position.x;
Debug.Log($"[BirdPlayerController] Fixed X position set to: {fixedXPosition}");
}
else
{
Debug.LogError("[BirdPlayerController] Rigidbody2D component not found!");
return;
}
// Register as override consumer to capture ALL input (except UI button)
// Register as override consumer to capture ALL input (except UI button)
if (Input.InputManager.Instance != null)
{
Input.InputManager.Instance.RegisterOverrideConsumer(this);
Debug.Log("[BirdPlayerController] Registered as override input consumer");
}
else
{
Debug.LogError("[BirdPlayerController] InputManager instance not found!");
}
}
private void Update()
{
if (!isDead && settings != null && rb != null)
{
// Apply manual gravity
verticalVelocity -= settings.Gravity * Time.deltaTime;
// Cap fall speed (terminal velocity)
if (verticalVelocity < -settings.MaxFallSpeed)
verticalVelocity = -settings.MaxFallSpeed;
// Update position manually
Vector2 newPosition = rb.position;
newPosition.y += verticalVelocity * Time.deltaTime;
newPosition.x = fixedXPosition; // Keep X fixed at scene-configured position
// Clamp Y position to bounds
newPosition.y = Mathf.Clamp(newPosition.y, settings.MinY, settings.MaxY);
rb.MovePosition(newPosition);
// Update rotation based on velocity
UpdateRotation();
}
}
private void Destroy()
{
// Unregister when destroyed
if (Input.InputManager.Instance != null)
{
Input.InputManager.Instance.UnregisterOverrideConsumer(this);
Debug.Log("[BirdPlayerController] Unregistered override input consumer");
}
}
#region ITouchInputConsumer Implementation
public void OnTap(Vector2 tapPosition)
{
if (!isDead && settings != null)
{
verticalVelocity = settings.FlapForce;
Debug.Log($"[BirdPlayerController] Flap! velocity = {verticalVelocity}");
}
}
public void OnHoldStart(Vector2 position) { }
public void OnHoldMove(Vector2 position) { }
public void OnHoldEnd(Vector2 position) { }
#endregion
#region Rotation
/// <summary>
/// Updates the bird's rotation based on vertical velocity.
/// Bird tilts up when flapping, down when falling.
/// </summary>
private void UpdateRotation()
{
if (settings == null) return;
// Map velocity to rotation angle
// When falling at max speed (-MaxFallSpeed): -MaxRotationAngle (down)
// When at flap velocity (+FlapForce): +MaxRotationAngle (up)
float velocityPercent = Mathf.InverseLerp(
-settings.MaxFallSpeed,
settings.FlapForce,
verticalVelocity
);
float targetAngle = Mathf.Lerp(
-settings.MaxRotationAngle,
settings.MaxRotationAngle,
velocityPercent
);
// Get current angle (handle 0-360 wrapping to -180-180)
float currentAngle = transform.rotation.eulerAngles.z;
if (currentAngle > 180f)
currentAngle -= 360f;
// Smooth interpolation to target
float smoothedAngle = Mathf.Lerp(
currentAngle,
targetAngle,
settings.RotationSpeed * Time.deltaTime
);
// Apply rotation to Z axis only (2D rotation)
transform.rotation = Quaternion.Euler(0, 0, smoothedAngle);
}
#endregion
#region Collision Detection
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Obstacle"))
{
HandleDeath();
}
}
private void HandleDeath()
{
isDead = true;
verticalVelocity = 0f;
Debug.Log("[BirdPlayerController] Bird died!");
}
#endregion
#region Public Properties
public bool IsDead => isDead;
#endregion
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2d56e44aad9044f8808b892c7a5cfc50
timeCreated: 1763596581

View File

@@ -234,7 +234,7 @@ namespace UI
case "Quarry":
currentUIMode = UIMode.Puzzle;
break;
case "DivingForPictures" or "CardQualityControl":
case "DivingForPictures" or "CardQualityControl" or "BirdPoop":
currentUIMode = UIMode.Minigame;
break;
}

View File

@@ -0,0 +1,27 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e7d3f5b948b3454681fa573071bee978, type: 3}
m_Name: BirdPooperSettings
m_EditorClassIdentifier: AppleHillsScripts::Core.Settings.BirdPooperSettings
gravity: 100
flapForce: 50
maxFallSpeed: 150
minY: -15
maxY: 15
obstacleMoveSpeed: 5
obstacleSpawnInterval: 2
obstacleSpawnXPosition: 12
obstacleDestroyXPosition: -12
obstacleMinSpawnY: -3
obstacleMaxSpawnY: 3
poopFallSpeed: 10
poopDestroyYPosition: -10

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 35d377f68c0a6704d838fe69a20b4bb8
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant: