- A Settings Provider system to utilize addressables for loading settings at runtime - An editor UI for easy modifications of the settings objects - A split out developer settings functionality to keep gameplay and nitty-gritty details separately - Most settings migrated out of game objects and into the new system - An additional Editor utility for fetching the settings at editor runtime, for gizmos, visualization etc Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Co-authored-by: AlexanderT <alexander@foolhardyhorizons.com> Reviewed-on: #7
70 lines
2.6 KiB
C#
70 lines
2.6 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 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)
|
|
{
|
|
// Check if the obstacle is on the ObstacleLayer
|
|
if (obstacle.gameObject.layer != _devSettings.ObstacleLayer)
|
|
{
|
|
// If not on the obstacle layer, don't process the collision
|
|
Debug.Log($"[ObstacleCollision] Ignored collision with object on layer {obstacle.gameObject.layer} (expected {_devSettings.ObstacleLayer})");
|
|
return;
|
|
}
|
|
|
|
// 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.DamageImmunityDuration} 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
|
|
}
|
|
}
|
|
}
|