The feel is fine

This commit is contained in:
2025-09-24 15:16:31 +02:00
parent 783541a776
commit aeaa977294
19 changed files with 494 additions and 344 deletions

View File

@@ -1,61 +0,0 @@
using UnityEngine;
namespace Minigames.DivingForPictures
{
/// <summary>
/// Collision behavior that handles damage from mobile obstacles.
/// Uses trigger-based collision detection with shared immunity state.
/// </summary>
public class ObstacleCollision : PlayerCollisionBehavior
{
protected override void OnEnable()
{
base.OnEnable();
// Subscribe to immunity events
OnImmunityStarted += HandleImmunityStarted;
OnImmunityEnded += HandleImmunityEnded;
}
protected override void OnDisable()
{
// Unsubscribe from immunity events
OnImmunityStarted -= HandleImmunityStarted;
OnImmunityEnded -= HandleImmunityEnded;
base.OnDisable();
}
protected override void HandleCollisionResponse(Collider2D obstacle)
{
// Mark the obstacle as having dealt damage to prevent multiple hits
FloatingObstacle obstacleComponent = obstacle.GetComponent<FloatingObstacle>();
if (obstacleComponent != null)
{
obstacleComponent.MarkDamageDealt();
}
Debug.Log($"[ObstacleCollision] Player hit by obstacle {obstacle.gameObject.name}");
}
/// <summary>
/// Handler for immunity started event - replaces OnImmunityStart method
/// </summary>
private void HandleImmunityStarted()
{
Debug.Log($"[ObstacleCollision] Damage immunity started for {_gameSettings.EndlessDescenderDamageImmunityDuration} seconds");
// Don't block input for obstacle damage - let player keep moving
// The shared immunity system will handle the collision prevention
}
/// <summary>
/// Handler for immunity ended event - replaces OnImmunityEnd method
/// </summary>
private void HandleImmunityEnded()
{
Debug.Log($"[ObstacleCollision] Damage immunity ended");
// No special handling needed - shared immunity system handles collider re-enabling
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: c9c18dbd013d42ae8c221e6205e4d49c
timeCreated: 1758116850

View File

@@ -221,9 +221,9 @@ namespace Minigames.DivingForPictures
while (true)
{
// Calculate next spawn time with variation
float nextSpawnTime = _settings.EndlessDescenderObstacleSpawnInterval +
Random.Range(-_settings.EndlessDescenderObstacleSpawnIntervalVariation,
_settings.EndlessDescenderObstacleSpawnIntervalVariation);
float nextSpawnTime = _settings.ObstacleSpawnInterval +
Random.Range(-_settings.ObstacleSpawnIntervalVariation,
_settings.ObstacleSpawnIntervalVariation);
nextSpawnTime = Mathf.Max(0.1f, nextSpawnTime); // Ensure minimum interval
yield return new WaitForSeconds(nextSpawnTime);
@@ -257,7 +257,7 @@ namespace Minigames.DivingForPictures
bool foundValidPosition = false;
// Try to find a valid spawn position
for (int attempts = 0; attempts < _settings.EndlessDescenderObstacleMaxSpawnAttempts; attempts++)
for (int attempts = 0; attempts < _settings.ObstacleMaxSpawnAttempts; attempts++)
{
spawnPosition = GetRandomSpawnPosition();
@@ -270,13 +270,13 @@ namespace Minigames.DivingForPictures
}
else
{
Debug.Log($"[ObstacleSpawner] Position {spawnPosition} invalid (attempt {attempts + 1}/{_settings.EndlessDescenderObstacleMaxSpawnAttempts})");
Debug.Log($"[ObstacleSpawner] Position {spawnPosition} invalid (attempt {attempts + 1}/{_settings.ObstacleMaxSpawnAttempts})");
}
}
if (!foundValidPosition)
{
Debug.LogWarning($"[ObstacleSpawner] SPAWN MISSED: Could not find valid spawn position after {_settings.EndlessDescenderObstacleMaxSpawnAttempts} attempts at {Time.time:F2}");
Debug.LogWarning($"[ObstacleSpawner] SPAWN MISSED: Could not find valid spawn position after {_settings.ObstacleMaxSpawnAttempts} attempts at {Time.time:F2}");
}
}
@@ -300,7 +300,7 @@ namespace Minigames.DivingForPictures
{
// Use OverlapCircle to check for collisions with tiles using just the layer
// Convert the single layer to a layer mask inline (1 << layerNumber)
Collider2D collision = Physics2D.OverlapCircle(position, _settings.EndlessDescenderObstacleSpawnCollisionRadius, 1 << _devSettings.TrenchTileLayer);
Collider2D collision = Physics2D.OverlapCircle(position, _settings.ObstacleSpawnCollisionRadius, 1 << _devSettings.TrenchTileLayer);
return collision == null;
}
@@ -412,8 +412,8 @@ namespace Minigames.DivingForPictures
// Randomize properties using settings
obstacleComponent.MoveSpeed = Random.Range(
_settings.EndlessDescenderObstacleMinMoveSpeed,
_settings.EndlessDescenderObstacleMaxMoveSpeed);
_settings.ObstacleMinMoveSpeed,
_settings.ObstacleMaxMoveSpeed);
// Set spawner reference (since FloatingObstacle has this built-in now)
obstacleComponent.SetSpawner(this);
@@ -544,7 +544,7 @@ namespace Minigames.DivingForPictures
// Draw collision radius at spawn point
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(center, _settings.EndlessDescenderObstacleSpawnCollisionRadius);
Gizmos.DrawWireSphere(center, _settings.ObstacleSpawnCollisionRadius);
}
}
#endif