Some b ase obstacle and poop spawning
This commit is contained in:
@@ -17,6 +17,11 @@ namespace Minigames.BirdPooper
|
||||
[SerializeField] private BirdPlayerController player;
|
||||
[SerializeField] private ObstacleSpawner obstacleSpawner;
|
||||
[SerializeField] private GameOverScreen gameOverScreen;
|
||||
[SerializeField] private GameObject poopPrefab;
|
||||
|
||||
[Header("Game State")]
|
||||
private int targetsHit;
|
||||
private bool isGameOver;
|
||||
|
||||
internal override void OnManagedAwake()
|
||||
{
|
||||
@@ -51,12 +56,21 @@ namespace Minigames.BirdPooper
|
||||
// Hide game over screen on start
|
||||
gameOverScreen.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
if (poopPrefab == null)
|
||||
{
|
||||
Debug.LogWarning("[BirdPooperGameManager] Poop prefab not assigned!");
|
||||
}
|
||||
}
|
||||
|
||||
internal override void OnManagedStart()
|
||||
{
|
||||
base.OnManagedStart();
|
||||
|
||||
// Initialize game state
|
||||
isGameOver = false;
|
||||
targetsHit = 0;
|
||||
|
||||
// Subscribe to player events
|
||||
if (player != null)
|
||||
{
|
||||
@@ -95,7 +109,10 @@ namespace Minigames.BirdPooper
|
||||
/// </summary>
|
||||
private void HandlePlayerDamaged()
|
||||
{
|
||||
Debug.Log("[BirdPooperGameManager] Player damaged - showing game over screen");
|
||||
if (isGameOver) return;
|
||||
|
||||
isGameOver = true;
|
||||
Debug.Log($"[BirdPooperGameManager] Player damaged - Game Over! Targets Hit: {targetsHit}");
|
||||
|
||||
// Stop spawning obstacles
|
||||
if (obstacleSpawner != null)
|
||||
@@ -113,6 +130,39 @@ namespace Minigames.BirdPooper
|
||||
Debug.LogError("[BirdPooperGameManager] GameOverScreen reference missing!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawns a poop projectile at the player's current position.
|
||||
/// Called by UI button OnClick event.
|
||||
/// </summary>
|
||||
public void SpawnPoop()
|
||||
{
|
||||
if (isGameOver || player == null || poopPrefab == null)
|
||||
return;
|
||||
|
||||
Vector3 spawnPosition = player.transform.position;
|
||||
Instantiate(poopPrefab, spawnPosition, Quaternion.identity);
|
||||
|
||||
Debug.Log($"[BirdPooperGameManager] Spawned poop at {spawnPosition}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a target is successfully hit by poop (Phase 5).
|
||||
/// </summary>
|
||||
public void OnTargetHit()
|
||||
{
|
||||
if (isGameOver) return;
|
||||
|
||||
targetsHit++;
|
||||
Debug.Log($"[BirdPooperGameManager] Target Hit! Total: {targetsHit}");
|
||||
}
|
||||
|
||||
#region Public Accessors
|
||||
|
||||
public bool IsGameOver => isGameOver;
|
||||
public int TargetsHit => targetsHit;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user