2025-09-17 16:10:18 +02:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Minigames.DivingForPictures
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Collision behavior that handles damage from mobile obstacles.
|
2025-09-18 12:42:05 +02:00
|
|
|
|
/// Uses trigger-based collision detection with shared immunity state.
|
2025-09-17 16:10:18 +02:00
|
|
|
|
/// </summary>
|
2025-09-18 12:42:05 +02:00
|
|
|
|
public class ObstacleCollision : PlayerCollisionBehavior
|
2025-09-17 16:10:18 +02:00
|
|
|
|
{
|
|
|
|
|
|
protected override void HandleCollisionResponse(Collider2D obstacle)
|
|
|
|
|
|
{
|
2025-09-18 14:14:01 +02:00
|
|
|
|
// Mark the obstacle as having dealt damage to prevent multiple hits
|
|
|
|
|
|
FloatingObstacle obstacleComponent = obstacle.GetComponent<FloatingObstacle>();
|
|
|
|
|
|
if (obstacleComponent != null)
|
2025-09-17 16:10:18 +02:00
|
|
|
|
{
|
2025-09-18 14:14:01 +02:00
|
|
|
|
obstacleComponent.MarkDamageDealt();
|
2025-09-17 16:10:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-18 14:14:01 +02:00
|
|
|
|
Debug.Log($"[ObstacleCollision] Player hit by obstacle {obstacle.gameObject.name}");
|
2025-09-17 16:10:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Override to prevent input blocking during damage immunity
|
|
|
|
|
|
/// Since obstacles pass through the player, we don't want to block input
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected override void OnImmunityStart()
|
|
|
|
|
|
{
|
2025-09-18 12:42:05 +02:00
|
|
|
|
Debug.Log($"[ObstacleCollision] Damage immunity started for {damageImmunityDuration} seconds");
|
2025-09-17 16:10:18 +02:00
|
|
|
|
|
|
|
|
|
|
// Don't block input for obstacle damage - let player keep moving
|
2025-09-18 12:42:05 +02:00
|
|
|
|
// The shared immunity system will handle the collision prevention
|
2025-09-17 16:10:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-09-18 12:42:05 +02:00
|
|
|
|
/// Override to handle immunity end
|
2025-09-17 16:10:18 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected override void OnImmunityEnd()
|
|
|
|
|
|
{
|
2025-09-18 12:42:05 +02:00
|
|
|
|
Debug.Log($"[ObstacleCollision] Damage immunity ended");
|
|
|
|
|
|
// No special handling needed - shared immunity system handles collider re-enabling
|
2025-09-17 16:10:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|