- Simulated "fake" physics and collisions - Object pooling for tiles, obstacles and monster spawns - Base monster scoring with proximity triggers and depth multiplier Co-authored-by: AlexanderT <alexander@foolhardyhorizons.com> Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Reviewed-on: #5
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
|
|
}
|
|
}
|
|
}
|