Compare commits
2 Commits
main
...
photo_inpu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20b3ce7136 | ||
|
|
05f63b28a0 |
@@ -139,6 +139,10 @@ namespace AppleHills.Core.Settings
|
|||||||
[Tooltip("Animation curve for the shrinking effect")]
|
[Tooltip("Animation curve for the shrinking effect")]
|
||||||
[SerializeField] private AnimationCurve viewfinderShrinkCurve = AnimationCurve.EaseInOut(0, 1, 1, 0);
|
[SerializeField] private AnimationCurve viewfinderShrinkCurve = AnimationCurve.EaseInOut(0, 1, 1, 0);
|
||||||
|
|
||||||
|
[Header("Photo Input")]
|
||||||
|
[Tooltip("Input mode for photo taking sequence")]
|
||||||
|
[SerializeField] private PhotoInputModes photoInputMode = PhotoInputModes.Tap;
|
||||||
|
|
||||||
[Tooltip("Padding factor to add space around the monster (1.0 = exact size, 1.2 = 20% extra)")]
|
[Tooltip("Padding factor to add space around the monster (1.0 = exact size, 1.2 = 20% extra)")]
|
||||||
[SerializeField] private float paddingFactor = 1.2f;
|
[SerializeField] private float paddingFactor = 1.2f;
|
||||||
|
|
||||||
@@ -220,6 +224,7 @@ namespace AppleHills.Core.Settings
|
|||||||
public float PaddingFactor => paddingFactor;
|
public float PaddingFactor => paddingFactor;
|
||||||
public float MaxSizePercent => maxSizePercent;
|
public float MaxSizePercent => maxSizePercent;
|
||||||
public float MinSizePercent => minSizePercent;
|
public float MinSizePercent => minSizePercent;
|
||||||
|
public PhotoInputModes PhotoInputMode => photoInputMode;
|
||||||
|
|
||||||
public override void OnValidate()
|
public override void OnValidate()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,15 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace AppleHills.Core.Settings
|
namespace AppleHills.Core.Settings
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Enum defining the different input modes for photo taking
|
||||||
|
/// </summary>
|
||||||
|
public enum PhotoInputModes
|
||||||
|
{
|
||||||
|
Tap, // Original tap-based input
|
||||||
|
Hold // New hold-based input
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface for player and follower settings
|
/// Interface for player and follower settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -114,11 +123,12 @@ namespace AppleHills.Core.Settings
|
|||||||
float ViewfinderShrinkDuration { get; }
|
float ViewfinderShrinkDuration { get; }
|
||||||
float ViewfinderMoveSpeed { get; }
|
float ViewfinderMoveSpeed { get; }
|
||||||
AnimationCurve ViewfinderShrinkCurve { get; }
|
AnimationCurve ViewfinderShrinkCurve { get; }
|
||||||
float ViewfinderStartScale { get; }
|
|
||||||
float ViewfinderEndScale { get; }
|
|
||||||
float[] ViewfinderProgressThresholds { get; }
|
float[] ViewfinderProgressThresholds { get; }
|
||||||
float PaddingFactor { get; }
|
float PaddingFactor { get; }
|
||||||
float MaxSizePercent { get; }
|
float MaxSizePercent { get; }
|
||||||
float MinSizePercent { get; }
|
float MinSizePercent { get; }
|
||||||
|
|
||||||
|
// Photo Input Settings
|
||||||
|
PhotoInputModes PhotoInputMode { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ namespace LevelS
|
|||||||
private void OnMenuCancel()
|
private void OnMenuCancel()
|
||||||
{
|
{
|
||||||
_isActive = true; // Allow interaction again if cancelled
|
_isActive = true; // Allow interaction again if cancelled
|
||||||
|
InputManager.Instance.SetInputMode(InputMode.GameAndUI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,6 +294,8 @@ namespace Minigames.DivingForPictures
|
|||||||
|
|
||||||
private void SpawnMonster(Transform spawnPoint)
|
private void SpawnMonster(Transform spawnPoint)
|
||||||
{
|
{
|
||||||
|
Debug.Log("Spawning monster: " + spawnPoint.name);
|
||||||
|
|
||||||
if (monsterPrefabs.Length == 0)
|
if (monsterPrefabs.Length == 0)
|
||||||
{
|
{
|
||||||
Debug.LogWarning("No monster prefabs assigned to DivingGameManager.");
|
Debug.LogWarning("No monster prefabs assigned to DivingGameManager.");
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ namespace Minigames.DivingForPictures
|
|||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
Debug.Log("Monster created: " + gameObject.name);
|
||||||
|
|
||||||
if (detectionCollider == null)
|
if (detectionCollider == null)
|
||||||
detectionCollider = GetComponent<CircleCollider2D>();
|
detectionCollider = GetComponent<CircleCollider2D>();
|
||||||
|
|
||||||
@@ -44,6 +46,11 @@ namespace Minigames.DivingForPictures
|
|||||||
photoSequenceInProgress = false;
|
photoSequenceInProgress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
Debug.Log("Monster destroyed: " + gameObject.name);
|
||||||
|
}
|
||||||
|
|
||||||
private IEnumerator CheckIfOffScreen()
|
private IEnumerator CheckIfOffScreen()
|
||||||
{
|
{
|
||||||
WaitForSeconds wait = new WaitForSeconds(0.5f);
|
WaitForSeconds wait = new WaitForSeconds(0.5f);
|
||||||
@@ -72,15 +79,24 @@ namespace Minigames.DivingForPictures
|
|||||||
Vector3 worldPosition = transform.position;
|
Vector3 worldPosition = transform.position;
|
||||||
Vector3 viewportPoint = mainCamera.WorldToViewportPoint(worldPosition);
|
Vector3 viewportPoint = mainCamera.WorldToViewportPoint(worldPosition);
|
||||||
|
|
||||||
// Adjust buffer to be larger below the screen to account for downward movement
|
// If z is negative, the object is behind the camera
|
||||||
float bufferSides = 0.2f;
|
if (viewportPoint.z < 0)
|
||||||
float bufferTop = 0.2f;
|
return false;
|
||||||
float bufferBottom = 0.5f; // Larger buffer below the screen
|
|
||||||
|
|
||||||
return viewportPoint.x > -bufferSides &&
|
// Simple logic:
|
||||||
viewportPoint.x < 1 + bufferSides &&
|
// 1. Allow monsters below the screen (new spawns)
|
||||||
viewportPoint.y > -bufferBottom &&
|
// 2. Despawn monsters only when completely above the top of screen
|
||||||
viewportPoint.y < 1 + bufferTop;
|
// 3. Keep monsters that are on screen
|
||||||
|
|
||||||
|
// Check if the monster is above the top of the screen
|
||||||
|
if (viewportPoint.y > 1)
|
||||||
|
return false; // Monster is completely above screen, destroy it
|
||||||
|
|
||||||
|
// Check horizontal bounds (keep moderate buffer so monsters don't disappear at screen edges)
|
||||||
|
float bufferSides = 0.2f;
|
||||||
|
bool withinHorizontalBounds = viewportPoint.x > -bufferSides && viewportPoint.x < 1 + bufferSides;
|
||||||
|
|
||||||
|
return withinHorizontalBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTriggerEnter2D(Collider2D other)
|
private void OnTriggerEnter2D(Collider2D other)
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ namespace Minigames.DivingForPictures.PictureCamera
|
|||||||
|
|
||||||
// Store settings
|
// Store settings
|
||||||
private IDivingMinigameSettings settings;
|
private IDivingMinigameSettings settings;
|
||||||
|
|
||||||
|
// New field to store the current input mode
|
||||||
|
private PhotoInputModes currentInputMode;
|
||||||
|
|
||||||
// Events for progress milestones
|
// Events for progress milestones
|
||||||
public event Action<float> OnProgressUpdated; // Continuous progress updates (0-1)
|
public event Action<float> OnProgressUpdated; // Continuous progress updates (0-1)
|
||||||
@@ -89,6 +92,9 @@ namespace Minigames.DivingForPictures.PictureCamera
|
|||||||
{
|
{
|
||||||
settings = GameManager.GetSettingsObject<IDivingMinigameSettings>();
|
settings = GameManager.GetSettingsObject<IDivingMinigameSettings>();
|
||||||
mainCamera = UnityEngine.Camera.main;
|
mainCamera = UnityEngine.Camera.main;
|
||||||
|
|
||||||
|
// Get the photo input mode from settings
|
||||||
|
currentInputMode = settings.PhotoInputMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -135,7 +141,7 @@ namespace Minigames.DivingForPictures.PictureCamera
|
|||||||
{
|
{
|
||||||
viewfinderComponent.Initialize(this);
|
viewfinderComponent.Initialize(this);
|
||||||
viewfinderComponent.SetupInputOverride();
|
viewfinderComponent.SetupInputOverride();
|
||||||
viewfinderComponent.OnViewfinderTapped += HandleViewfinderTapped;
|
InitializeViewfinder(viewfinderComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset state
|
// Reset state
|
||||||
@@ -450,10 +456,13 @@ namespace Minigames.DivingForPictures.PictureCamera
|
|||||||
{
|
{
|
||||||
if (viewfinderInstance != null)
|
if (viewfinderInstance != null)
|
||||||
{
|
{
|
||||||
// Unsubscribe from the viewfinder's tap event
|
// Unsubscribe from all viewfinder events
|
||||||
if (viewfinderComponent != null)
|
if (viewfinderComponent != null)
|
||||||
{
|
{
|
||||||
viewfinderComponent.OnViewfinderTapped -= HandleViewfinderTapped;
|
viewfinderComponent.OnViewfinderTapped -= HandleViewfinderTapped;
|
||||||
|
viewfinderComponent.OnViewfinderTapped -= HandleViewfinderTappedDuringAnimation;
|
||||||
|
viewfinderComponent.OnViewfinderHoldStarted -= HandleViewfinderHoldStarted;
|
||||||
|
viewfinderComponent.OnViewfinderHoldEnded -= HandleViewfinderHoldEnded;
|
||||||
}
|
}
|
||||||
|
|
||||||
Destroy(viewfinderInstance);
|
Destroy(viewfinderInstance);
|
||||||
@@ -507,8 +516,7 @@ namespace Minigames.DivingForPictures.PictureCamera
|
|||||||
{
|
{
|
||||||
viewfinderComponent.Initialize(this);
|
viewfinderComponent.Initialize(this);
|
||||||
viewfinderComponent.SetupInputOverride();
|
viewfinderComponent.SetupInputOverride();
|
||||||
viewfinderComponent.OnViewfinderTapped += HandleViewfinderTapped;
|
InitializeViewfinder(viewfinderComponent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine canvas width for full-screen sizing
|
// Determine canvas width for full-screen sizing
|
||||||
@@ -583,6 +591,20 @@ namespace Minigames.DivingForPictures.PictureCamera
|
|||||||
viewfinderComponent.OnViewfinderTapped += HandleViewfinderTappedDuringAnimation;
|
viewfinderComponent.OnViewfinderTapped += HandleViewfinderTappedDuringAnimation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize viewfinder with appropriate event handlers based on input mode
|
||||||
|
if (viewfinderComponent != null)
|
||||||
|
{
|
||||||
|
viewfinderComponent.Initialize(this);
|
||||||
|
viewfinderComponent.SetupInputOverride();
|
||||||
|
InitializeViewfinder(viewfinderComponent);
|
||||||
|
|
||||||
|
// For animation sequence, we need additional handling for tapping during animation
|
||||||
|
if (currentInputMode == PhotoInputModes.Tap)
|
||||||
|
{
|
||||||
|
viewfinderComponent.OnViewfinderTapped += HandleViewfinderTappedDuringAnimation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Reset state
|
// Reset state
|
||||||
animationProgress = 0f;
|
animationProgress = 0f;
|
||||||
isAnimating = true;
|
isAnimating = true;
|
||||||
@@ -772,5 +794,80 @@ namespace Minigames.DivingForPictures.PictureCamera
|
|||||||
HandleViewfinderTapped();
|
HandleViewfinderTapped();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the viewfinder with appropriate event handlers based on input mode
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="viewfinder">The viewfinder component to initialize</param>
|
||||||
|
public void InitializeViewfinder(Viewfinder viewfinder)
|
||||||
|
{
|
||||||
|
if (viewfinder != null)
|
||||||
|
{
|
||||||
|
// Clean up any existing event subscriptions
|
||||||
|
viewfinder.OnViewfinderTapped -= HandleViewfinderTapped;
|
||||||
|
viewfinder.OnViewfinderHoldStarted -= HandleViewfinderHoldStarted;
|
||||||
|
viewfinder.OnViewfinderHoldEnded -= HandleViewfinderHoldEnded;
|
||||||
|
|
||||||
|
// Set up handlers based on the current input mode
|
||||||
|
switch (currentInputMode)
|
||||||
|
{
|
||||||
|
case PhotoInputModes.Tap:
|
||||||
|
// For tap mode, only subscribe to tap events
|
||||||
|
viewfinder.OnViewfinderTapped += HandleViewfinderTapped;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PhotoInputModes.Hold:
|
||||||
|
// For hold mode, subscribe to hold start/end events
|
||||||
|
viewfinder.OnViewfinderHoldStarted += HandleViewfinderHoldStarted;
|
||||||
|
viewfinder.OnViewfinderHoldEnded += HandleViewfinderHoldEnded;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles hold start event from the viewfinder
|
||||||
|
/// </summary>
|
||||||
|
private void HandleViewfinderHoldStarted()
|
||||||
|
{
|
||||||
|
if (currentInputMode == PhotoInputModes.Hold)
|
||||||
|
{
|
||||||
|
// Start the photo sequence when hold begins (same behavior as first tap in tap mode)
|
||||||
|
OnViewfinderTapped?.Invoke();
|
||||||
|
Debug.Log("[CameraViewfinderManager] Hold started - initiating photo sequence");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles hold end event from the viewfinder
|
||||||
|
/// </summary>
|
||||||
|
private void HandleViewfinderHoldEnded()
|
||||||
|
{
|
||||||
|
if (currentInputMode == PhotoInputModes.Hold && isAnimating)
|
||||||
|
{
|
||||||
|
// Complete the sequence when hold ends (same behavior as second tap in tap mode)
|
||||||
|
OnViewfinderTappedDuringAnimation?.Invoke(currentProximity);
|
||||||
|
Debug.Log("[CameraViewfinderManager] Hold ended - completing photo sequence with proximity: " + currentProximity);
|
||||||
|
|
||||||
|
// Complete the animation immediately
|
||||||
|
if (animationCoroutine != null)
|
||||||
|
{
|
||||||
|
StopCoroutine(animationCoroutine);
|
||||||
|
animationCoroutine = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire completed event
|
||||||
|
OnAnimationCompleted?.Invoke();
|
||||||
|
isAnimating = false;
|
||||||
|
isReversePhase = false;
|
||||||
|
|
||||||
|
// Hide the viewfinder
|
||||||
|
if (viewfinderComponent != null)
|
||||||
|
{
|
||||||
|
viewfinderComponent.RemoveInputOverride();
|
||||||
|
}
|
||||||
|
HideViewfinder();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ namespace Minigames.DivingForPictures.PictureCamera
|
|||||||
|
|
||||||
// Events
|
// Events
|
||||||
public event System.Action OnViewfinderTapped;
|
public event System.Action OnViewfinderTapped;
|
||||||
|
public event System.Action OnViewfinderHoldStarted;
|
||||||
|
public event System.Action OnViewfinderHoldEnded;
|
||||||
|
|
||||||
// State
|
// State
|
||||||
private bool isActive = true;
|
private bool isActive = true;
|
||||||
@@ -101,10 +103,30 @@ namespace Minigames.DivingForPictures.PictureCamera
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required interface methods (no-op implementations)
|
public void OnHoldStart(Vector2 position)
|
||||||
public void OnHoldStart(Vector2 position) { }
|
{
|
||||||
public void OnHoldMove(Vector2 position) { }
|
if (isActive)
|
||||||
public void OnHoldEnd(Vector2 position) { }
|
{
|
||||||
|
// Fire the hold start event
|
||||||
|
OnViewfinderHoldStarted?.Invoke();
|
||||||
|
Debug.Log($"[MDPI] Viewfinder OnHoldStart: {position}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnHoldMove(Vector2 position)
|
||||||
|
{
|
||||||
|
// We can use this for any continuous effects during hold if needed in the future
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnHoldEnd(Vector2 position)
|
||||||
|
{
|
||||||
|
if (isActive)
|
||||||
|
{
|
||||||
|
// Fire the hold end event
|
||||||
|
OnViewfinderHoldEnded?.Invoke();
|
||||||
|
Debug.Log($"[MDPI] Viewfinder OnHoldEnd: {position}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ MonoBehaviour:
|
|||||||
tapMaxDistance: 0.2
|
tapMaxDistance: 0.2
|
||||||
tapDecelerationRate: 15
|
tapDecelerationRate: 15
|
||||||
baseSpawnProbability: 0.2
|
baseSpawnProbability: 0.2
|
||||||
maxSpawnProbability: 0.5
|
maxSpawnProbability: 0.8
|
||||||
probabilityIncreaseRate: 0.01
|
probabilityIncreaseRate: 0.01
|
||||||
guaranteedSpawnTime: 30
|
guaranteedSpawnTime: 30
|
||||||
spawnCooldown: 5
|
spawnCooldown: 5
|
||||||
@@ -76,6 +76,7 @@ MonoBehaviour:
|
|||||||
m_PreInfinity: 2
|
m_PreInfinity: 2
|
||||||
m_PostInfinity: 2
|
m_PostInfinity: 2
|
||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
|
photoInputMode: 1
|
||||||
paddingFactor: 2
|
paddingFactor: 2
|
||||||
minSizePercent: 0.15
|
minSizePercent: 0.15
|
||||||
maxSizePercent: 1
|
maxSizePercent: 1
|
||||||
@@ -85,4 +86,4 @@ MonoBehaviour:
|
|||||||
- 0.25
|
- 0.25
|
||||||
- 0.5
|
- 0.5
|
||||||
- 0.75
|
- 0.75
|
||||||
- 1
|
- 1
|
||||||
|
|||||||
Reference in New Issue
Block a user