45 lines
1.7 KiB
C#
45 lines
1.7 KiB
C#
|
|
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 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>
|
|||
|
|
/// 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()
|
|||
|
|
{
|
|||
|
|
Debug.Log($"[ObstacleCollision] Damage immunity started for {damageImmunityDuration} seconds");
|
|||
|
|
|
|||
|
|
// Don't block input for obstacle damage - let player keep moving
|
|||
|
|
// The shared immunity system will handle the collision prevention
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Override to handle immunity end
|
|||
|
|
/// </summary>
|
|||
|
|
protected override void OnImmunityEnd()
|
|||
|
|
{
|
|||
|
|
Debug.Log($"[ObstacleCollision] Damage immunity ended");
|
|||
|
|
// No special handling needed - shared immunity system handles collider re-enabling
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|