Update the Pause menu flow to be slightly less scoffed
This commit is contained in:
@@ -347,12 +347,12 @@ LineRenderer:
|
|||||||
- {x: -0.1572447, y: 3.8729858, z: 0}
|
- {x: -0.1572447, y: 3.8729858, z: 0}
|
||||||
- {x: -0.15785426, y: 3.7729874, z: 0}
|
- {x: -0.15785426, y: 3.7729874, z: 0}
|
||||||
- {x: -0.15846384, y: 3.6736438, z: 0}
|
- {x: -0.15846384, y: 3.6736438, z: 0}
|
||||||
- {x: -0.15907341, y: 3.5749545, z: 0}
|
- {x: -0.15907341, y: 3.5749543, z: 0}
|
||||||
- {x: -0.15968299, y: 3.4769197, z: 0}
|
- {x: -0.15968299, y: 3.4769194, z: 0}
|
||||||
- {x: -0.16029257, y: 3.379539, z: 0}
|
- {x: -0.16029257, y: 3.3795385, z: 0}
|
||||||
- {x: -0.16090216, y: 3.2828128, z: 0}
|
- {x: -0.16090216, y: 3.2828126, z: 0}
|
||||||
- {x: -0.16151173, y: 3.186741, z: 0}
|
- {x: -0.16151173, y: 3.1867406, z: 0}
|
||||||
- {x: -0.16212131, y: 3.0913236, z: 0}
|
- {x: -0.16212131, y: 3.0913231, z: 0}
|
||||||
m_Parameters:
|
m_Parameters:
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
widthMultiplier: 1
|
widthMultiplier: 1
|
||||||
@@ -1368,16 +1368,16 @@ LineRenderer:
|
|||||||
m_SortingOrder: 0
|
m_SortingOrder: 0
|
||||||
m_Positions:
|
m_Positions:
|
||||||
- {x: -0.15602553, y: 4.074945, z: 0}
|
- {x: -0.15602553, y: 4.074945, z: 0}
|
||||||
- {x: -0.11662118, y: 3.8796227, z: 0}
|
- {x: -0.11662118, y: 3.8796225, z: 0}
|
||||||
- {x: -0.07721684, y: 3.7057447, z: 0}
|
- {x: -0.07721684, y: 3.7057445, z: 0}
|
||||||
- {x: -0.03781248, y: 3.553311, z: 0}
|
- {x: -0.03781248, y: 3.5533106, z: 0}
|
||||||
- {x: 0.0015918687, y: 3.4223218, z: 0}
|
- {x: 0.0015918687, y: 3.4223216, z: 0}
|
||||||
- {x: 0.040996216, y: 3.3127768, z: 0}
|
- {x: 0.040996216, y: 3.3127766, z: 0}
|
||||||
- {x: 0.08040057, y: 3.2246761, z: 0}
|
- {x: 0.08040057, y: 3.2246757, z: 0}
|
||||||
- {x: 0.11980491, y: 3.15802, z: 0}
|
- {x: 0.11980491, y: 3.1580195, z: 0}
|
||||||
- {x: 0.15920927, y: 3.1128082, z: 0}
|
- {x: 0.15920927, y: 3.1128078, z: 0}
|
||||||
- {x: 0.1986136, y: 3.0890408, z: 0}
|
- {x: 0.1986136, y: 3.0890403, z: 0}
|
||||||
- {x: 0.23801796, y: 3.0867176, z: 0}
|
- {x: 0.23801796, y: 3.0867171, z: 0}
|
||||||
m_Parameters:
|
m_Parameters:
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
widthMultiplier: 1
|
widthMultiplier: 1
|
||||||
@@ -1912,15 +1912,15 @@ LineRenderer:
|
|||||||
m_Positions:
|
m_Positions:
|
||||||
- {x: -0.15602553, y: 4.074945, z: 0}
|
- {x: -0.15602553, y: 4.074945, z: 0}
|
||||||
- {x: -0.18956745, y: 3.8764977, z: 0}
|
- {x: -0.18956745, y: 3.8764977, z: 0}
|
||||||
- {x: -0.22310936, y: 3.7000237, z: 0}
|
- {x: -0.22310936, y: 3.7000232, z: 0}
|
||||||
- {x: -0.25665125, y: 3.5455213, z: 0}
|
- {x: -0.25665125, y: 3.5455205, z: 0}
|
||||||
- {x: -0.29019317, y: 3.412991, z: 0}
|
- {x: -0.29019317, y: 3.4129908, z: 0}
|
||||||
- {x: -0.32373506, y: 3.302434, z: 0}
|
- {x: -0.32373506, y: 3.3024333, z: 0}
|
||||||
- {x: -0.35727698, y: 3.2138486, z: 0}
|
- {x: -0.35727698, y: 3.213848, z: 0}
|
||||||
- {x: -0.39081886, y: 3.147236, z: 0}
|
- {x: -0.39081886, y: 3.1472356, z: 0}
|
||||||
- {x: -0.4243608, y: 3.1025963, z: 0}
|
- {x: -0.4243608, y: 3.1025953, z: 0}
|
||||||
- {x: -0.45790267, y: 3.0799284, z: 0}
|
- {x: -0.45790267, y: 3.0799277, z: 0}
|
||||||
- {x: -0.4914446, y: 3.079233, z: 0}
|
- {x: -0.4914446, y: 3.0792325, z: 0}
|
||||||
m_Parameters:
|
m_Parameters:
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
widthMultiplier: 1
|
widthMultiplier: 1
|
||||||
@@ -2469,7 +2469,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 2106431001}
|
m_GameObject: {fileID: 2106431001}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: -0.165, y: 2.6975174, z: 0}
|
m_LocalPosition: {x: -0.165, y: 2.697517, z: 0}
|
||||||
m_LocalScale: {x: 0.57574, y: 0.57574, z: 0.57574}
|
m_LocalScale: {x: 0.57574, y: 0.57574, z: 0.57574}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children:
|
m_Children:
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System.Collections;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using AppleHills.Core.Settings;
|
using AppleHills.Core.Settings;
|
||||||
using AppleHills.Core.Interfaces;
|
using AppleHills.Core.Interfaces;
|
||||||
using Core;
|
using Core;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
namespace Minigames.DivingForPictures
|
namespace Minigames.DivingForPictures
|
||||||
{
|
{
|
||||||
@@ -65,10 +67,13 @@ namespace Minigames.DivingForPictures
|
|||||||
SetNextSpawnInterval();
|
SetNextSpawnInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
DivingGameManager.Instance.RegisterPausableComponent(this);
|
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
// Start spawning if not paused
|
// Start spawning if not paused
|
||||||
StartSpawningCoroutine();
|
StartSpawningCoroutine();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,13 +83,16 @@ namespace Minigames.DivingForPictures
|
|||||||
onObstacleDestroyed = new UnityEvent<GameObject>();
|
onObstacleDestroyed = new UnityEvent<GameObject>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
// Register with the DivingGameManager for pause/resume events
|
||||||
|
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||||
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
DivingGameManager.Instance.OnGameInitialized += Initialize;
|
DivingGameManager.Instance.OnGameInitialized += Initialize;
|
||||||
|
|
||||||
// Register with the DivingGameManager for pause/resume events
|
|
||||||
DivingGameManager.Instance.RegisterPausableComponent(this);
|
|
||||||
|
|
||||||
// If game is already initialized, initialize immediately
|
// If game is already initialized, initialize immediately
|
||||||
if (DivingGameManager.Instance.GetType().GetField("_isGameInitialized",
|
if (DivingGameManager.Instance.GetType().GetField("_isGameInitialized",
|
||||||
System.Reflection.BindingFlags.NonPublic |
|
System.Reflection.BindingFlags.NonPublic |
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Collections;
|
|||||||
using AppleHills.Core.Settings;
|
using AppleHills.Core.Settings;
|
||||||
using AppleHills.Utilities;
|
using AppleHills.Utilities;
|
||||||
using Core;
|
using Core;
|
||||||
|
using Minigames.DivingForPictures.Player;
|
||||||
|
|
||||||
namespace Minigames.DivingForPictures
|
namespace Minigames.DivingForPictures
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,54 +1,59 @@
|
|||||||
using AppleHills.Core.Settings;
|
using AppleHills.Core.Interfaces;
|
||||||
|
using AppleHills.Core.Settings;
|
||||||
using AppleHillsCamera;
|
using AppleHillsCamera;
|
||||||
using Cinematics;
|
|
||||||
using Core;
|
using Core;
|
||||||
using Input;
|
using Input;
|
||||||
using UnityEditor.Search;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Minigames.DivingForPictures
|
namespace Minigames.DivingForPictures.Player
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles endless descender movement in response to tap and hold input events.
|
/// Handles endless descender movement in response to tap and hold input events.
|
||||||
/// Moves the character horizontally to follow the finger or tap position.
|
/// Moves the character horizontally to follow the finger or tap position.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PlayerController : MonoBehaviour, ITouchInputConsumer
|
public class PlayerController : MonoBehaviour, ITouchInputConsumer, IPausable
|
||||||
{
|
{
|
||||||
|
|
||||||
[Tooltip("Reference to the edge anchor that this player should follow for Y position")]
|
[Tooltip("Reference to the edge anchor that this player should follow for Y position")]
|
||||||
[SerializeField] private EdgeAnchor edgeAnchor;
|
[SerializeField] private EdgeAnchor edgeAnchor;
|
||||||
|
|
||||||
// Settings reference
|
// Settings reference
|
||||||
private IDivingMinigameSettings _settings;
|
private IDivingMinigameSettings settings;
|
||||||
|
|
||||||
private float _targetFingerX;
|
private float targetFingerX;
|
||||||
private bool _isTouchActive;
|
private bool isTouchActive;
|
||||||
private float _originY;
|
private float originY;
|
||||||
|
|
||||||
// Tap impulse system variables
|
// Tap impulse system variables
|
||||||
private float _tapImpulseStrength = 0f;
|
private float tapImpulseStrength = 0f;
|
||||||
private float _tapDirection = 0f;
|
private float tapDirection = 0f;
|
||||||
|
|
||||||
// Initialization flag
|
// Initialization flag
|
||||||
private bool _isInitialized = false;
|
private bool isInitialized = false;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
_originY = transform.position.y;
|
originY = transform.position.y;
|
||||||
|
|
||||||
// Get settings from GameManager
|
// Get settings from GameManager
|
||||||
_settings = GameManager.GetSettingsObject<IDivingMinigameSettings>();
|
settings = GameManager.GetSettingsObject<IDivingMinigameSettings>();
|
||||||
if (_settings == null)
|
if (settings == null)
|
||||||
{
|
{
|
||||||
Debug.LogError("[PlayerController] Failed to load diving minigame settings!");
|
Debug.LogError("[PlayerController] Failed to load diving minigame settings!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnEnable()
|
||||||
|
{
|
||||||
|
// Register as a pausable component with DivingGameManager
|
||||||
|
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||||
|
}
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
// Initialize target to current position
|
// Initialize target to current position
|
||||||
_targetFingerX = transform.position.x;
|
targetFingerX = transform.position.x;
|
||||||
_isTouchActive = false;
|
isTouchActive = false;
|
||||||
|
|
||||||
// Try to find edge anchor if not assigned
|
// Try to find edge anchor if not assigned
|
||||||
if (edgeAnchor == null)
|
if (edgeAnchor == null)
|
||||||
@@ -59,7 +64,7 @@ namespace Minigames.DivingForPictures
|
|||||||
// If not found, find any edge anchor in the scene
|
// If not found, find any edge anchor in the scene
|
||||||
if (edgeAnchor == null)
|
if (edgeAnchor == null)
|
||||||
{
|
{
|
||||||
edgeAnchor = FindObjectOfType<EdgeAnchor>();
|
edgeAnchor = FindFirstObjectByType<EdgeAnchor>();
|
||||||
if (edgeAnchor == null)
|
if (edgeAnchor == null)
|
||||||
{
|
{
|
||||||
Logging.Warning("[PlayerController] No EdgeAnchor found in scene. Origin Y position won't update with camera changes.");
|
Logging.Warning("[PlayerController] No EdgeAnchor found in scene. Origin Y position won't update with camera changes.");
|
||||||
@@ -98,12 +103,12 @@ namespace Minigames.DivingForPictures
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void Initialize()
|
private void Initialize()
|
||||||
{
|
{
|
||||||
if (_isInitialized) return;
|
if (isInitialized) return;
|
||||||
|
|
||||||
// Register as default consumer for input
|
// Register as default consumer for input
|
||||||
InputManager.Instance?.SetDefaultConsumer(this);
|
InputManager.Instance?.SetDefaultConsumer(this);
|
||||||
|
|
||||||
_isInitialized = true;
|
isInitialized = true;
|
||||||
Logging.Debug("[PlayerController] Initialized");
|
Logging.Debug("[PlayerController] Initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +116,9 @@ namespace Minigames.DivingForPictures
|
|||||||
{
|
{
|
||||||
DivingGameManager.Instance.OnGameInitialized -= Initialize;
|
DivingGameManager.Instance.OnGameInitialized -= Initialize;
|
||||||
|
|
||||||
|
// Unregister as a pausable component
|
||||||
|
DivingGameManager.Instance.UnregisterPausableComponent(this);
|
||||||
|
|
||||||
// Unsubscribe from edge anchor events
|
// Unsubscribe from edge anchor events
|
||||||
if (edgeAnchor != null)
|
if (edgeAnchor != null)
|
||||||
{
|
{
|
||||||
@@ -123,17 +131,20 @@ namespace Minigames.DivingForPictures
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void OnTap(Vector2 worldPosition)
|
public void OnTap(Vector2 worldPosition)
|
||||||
{
|
{
|
||||||
|
// Ignore input when paused
|
||||||
|
if (isPaused) return;
|
||||||
|
|
||||||
// Logging.Debug($"[EndlessDescenderController] OnTap at {worldPosition}");
|
// Logging.Debug($"[EndlessDescenderController] OnTap at {worldPosition}");
|
||||||
float targetX = Mathf.Clamp(worldPosition.x, _settings.ClampXMin, _settings.ClampXMax);
|
float targetX = Mathf.Clamp(worldPosition.x, settings.ClampXMin, settings.ClampXMax);
|
||||||
|
|
||||||
// Calculate tap direction (+1 for right, -1 for left)
|
// Calculate tap direction (+1 for right, -1 for left)
|
||||||
_tapDirection = Mathf.Sign(targetX - transform.position.x);
|
tapDirection = Mathf.Sign(targetX - transform.position.x);
|
||||||
|
|
||||||
// Set impulse strength to full
|
// Set impulse strength to full
|
||||||
_tapImpulseStrength = 1.0f;
|
tapImpulseStrength = 1.0f;
|
||||||
|
|
||||||
// Store target X for animation purposes
|
// Store target X for animation purposes
|
||||||
_targetFingerX = targetX;
|
targetFingerX = targetX;
|
||||||
|
|
||||||
// Do not set _isTouchActive for taps anymore
|
// Do not set _isTouchActive for taps anymore
|
||||||
// _isTouchActive = true; - Removed to prevent continuous movement
|
// _isTouchActive = true; - Removed to prevent continuous movement
|
||||||
@@ -144,9 +155,12 @@ namespace Minigames.DivingForPictures
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void OnHoldStart(Vector2 worldPosition)
|
public void OnHoldStart(Vector2 worldPosition)
|
||||||
{
|
{
|
||||||
|
// Ignore input when paused
|
||||||
|
if (isPaused) return;
|
||||||
|
|
||||||
// Logging.Debug($"[EndlessDescenderController] OnHoldStart at {worldPosition}");
|
// Logging.Debug($"[EndlessDescenderController] OnHoldStart at {worldPosition}");
|
||||||
_targetFingerX = Mathf.Clamp(worldPosition.x, _settings.ClampXMin, _settings.ClampXMax);
|
targetFingerX = Mathf.Clamp(worldPosition.x, settings.ClampXMin, settings.ClampXMax);
|
||||||
_isTouchActive = true;
|
isTouchActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -154,8 +168,11 @@ namespace Minigames.DivingForPictures
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void OnHoldMove(Vector2 worldPosition)
|
public void OnHoldMove(Vector2 worldPosition)
|
||||||
{
|
{
|
||||||
|
// Ignore input when paused
|
||||||
|
if (isPaused) return;
|
||||||
|
|
||||||
// Logging.Debug($"[EndlessDescenderController] OnHoldMove at {worldPosition}");
|
// Logging.Debug($"[EndlessDescenderController] OnHoldMove at {worldPosition}");
|
||||||
_targetFingerX = Mathf.Clamp(worldPosition.x, _settings.ClampXMin, _settings.ClampXMax);
|
targetFingerX = Mathf.Clamp(worldPosition.x, settings.ClampXMin, settings.ClampXMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -163,20 +180,26 @@ namespace Minigames.DivingForPictures
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void OnHoldEnd(Vector2 worldPosition)
|
public void OnHoldEnd(Vector2 worldPosition)
|
||||||
{
|
{
|
||||||
|
// Ignore input when paused
|
||||||
|
if (isPaused) return;
|
||||||
|
|
||||||
// Logging.Debug($"[EndlessDescenderController] OnHoldEnd at {worldPosition}");
|
// Logging.Debug($"[EndlessDescenderController] OnHoldEnd at {worldPosition}");
|
||||||
_isTouchActive = false;
|
isTouchActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
// Skip movement processing if paused
|
||||||
|
if (isPaused) return;
|
||||||
|
|
||||||
// Handle hold movement
|
// Handle hold movement
|
||||||
if (_isTouchActive)
|
if (isTouchActive)
|
||||||
{
|
{
|
||||||
float currentX = transform.position.x;
|
float currentX = transform.position.x;
|
||||||
float lerpSpeed = _settings.LerpSpeed;
|
float lerpSpeed = settings.LerpSpeed;
|
||||||
float maxOffset = _settings.MaxOffset;
|
float maxOffset = settings.MaxOffset;
|
||||||
float exponent = _settings.SpeedExponent;
|
float exponent = settings.SpeedExponent;
|
||||||
float targetX = _targetFingerX;
|
float targetX = targetFingerX;
|
||||||
float offset = targetX - currentX;
|
float offset = targetX - currentX;
|
||||||
offset = Mathf.Clamp(offset, -maxOffset, maxOffset);
|
offset = Mathf.Clamp(offset, -maxOffset, maxOffset);
|
||||||
float absOffset = Mathf.Abs(offset);
|
float absOffset = Mathf.Abs(offset);
|
||||||
@@ -185,32 +208,32 @@ namespace Minigames.DivingForPictures
|
|||||||
// Prevent overshooting
|
// Prevent overshooting
|
||||||
moveStep = Mathf.Clamp(moveStep, -absOffset, absOffset);
|
moveStep = Mathf.Clamp(moveStep, -absOffset, absOffset);
|
||||||
float newX = currentX + moveStep;
|
float newX = currentX + moveStep;
|
||||||
newX = Mathf.Clamp(newX, _settings.ClampXMin, _settings.ClampXMax);
|
newX = Mathf.Clamp(newX, settings.ClampXMin, settings.ClampXMax);
|
||||||
|
|
||||||
UpdatePosition(newX);
|
UpdatePosition(newX);
|
||||||
}
|
}
|
||||||
// Handle tap impulse movement
|
// Handle tap impulse movement
|
||||||
else if (_tapImpulseStrength > 0)
|
else if (tapImpulseStrength > 0)
|
||||||
{
|
{
|
||||||
float currentX = transform.position.x;
|
float currentX = transform.position.x;
|
||||||
float maxOffset = _settings.MaxOffset;
|
float maxOffset = settings.MaxOffset;
|
||||||
float lerpSpeed = _settings.LerpSpeed;
|
float lerpSpeed = settings.LerpSpeed;
|
||||||
|
|
||||||
// Calculate move distance based on impulse strength
|
// Calculate move distance based on impulse strength
|
||||||
float moveDistance = maxOffset * _tapImpulseStrength * Time.deltaTime * lerpSpeed;
|
float moveDistance = maxOffset * tapImpulseStrength * Time.deltaTime * lerpSpeed;
|
||||||
|
|
||||||
// Limit total movement from single tap
|
// Limit total movement from single tap
|
||||||
moveDistance = Mathf.Min(moveDistance, _settings.TapMaxDistance * _tapImpulseStrength);
|
moveDistance = Mathf.Min(moveDistance, settings.TapMaxDistance * tapImpulseStrength);
|
||||||
|
|
||||||
// Apply movement in tap direction
|
// Apply movement in tap direction
|
||||||
float newX = currentX + (moveDistance * _tapDirection);
|
float newX = currentX + (moveDistance * tapDirection);
|
||||||
newX = Mathf.Clamp(newX, _settings.ClampXMin, _settings.ClampXMax);
|
newX = Mathf.Clamp(newX, settings.ClampXMin, settings.ClampXMax);
|
||||||
|
|
||||||
// Reduce impulse strength over time
|
// Reduce impulse strength over time
|
||||||
_tapImpulseStrength -= Time.deltaTime * _settings.TapDecelerationRate;
|
tapImpulseStrength -= Time.deltaTime * settings.TapDecelerationRate;
|
||||||
if (_tapImpulseStrength < 0.01f)
|
if (tapImpulseStrength < 0.01f)
|
||||||
{
|
{
|
||||||
_tapImpulseStrength = 0f;
|
tapImpulseStrength = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatePosition(newX);
|
UpdatePosition(newX);
|
||||||
@@ -222,7 +245,7 @@ namespace Minigames.DivingForPictures
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void UpdatePosition(float newX)
|
private void UpdatePosition(float newX)
|
||||||
{
|
{
|
||||||
float newY = _originY;
|
float newY = originY;
|
||||||
// Add vertical offset from WobbleBehavior if present
|
// Add vertical offset from WobbleBehavior if present
|
||||||
WobbleBehavior wobble = GetComponent<WobbleBehavior>();
|
WobbleBehavior wobble = GetComponent<WobbleBehavior>();
|
||||||
if (wobble != null)
|
if (wobble != null)
|
||||||
@@ -237,7 +260,7 @@ namespace Minigames.DivingForPictures
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void UpdateOriginY(float newOriginY)
|
public void UpdateOriginY(float newOriginY)
|
||||||
{
|
{
|
||||||
_originY = newOriginY;
|
originY = newOriginY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -246,7 +269,7 @@ namespace Minigames.DivingForPictures
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void UpdateOriginYFromCurrentPosition()
|
private void UpdateOriginYFromCurrentPosition()
|
||||||
{
|
{
|
||||||
_originY = transform.position.y;
|
originY = transform.position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -255,8 +278,43 @@ namespace Minigames.DivingForPictures
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void UpdateOriginYFromAnchor()
|
private void UpdateOriginYFromAnchor()
|
||||||
{
|
{
|
||||||
_originY = edgeAnchor.transform.position.y;
|
originY = edgeAnchor.transform.position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region IPausable Implementation
|
||||||
|
private bool isPaused = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pauses the player controller, blocking all input processing
|
||||||
|
/// </summary>
|
||||||
|
public void Pause()
|
||||||
|
{
|
||||||
|
if (isPaused) return;
|
||||||
|
|
||||||
|
isPaused = true;
|
||||||
|
|
||||||
|
// If we're being paused, stop any active touch and tap impulse
|
||||||
|
isTouchActive = false;
|
||||||
|
tapImpulseStrength = 0f;
|
||||||
|
|
||||||
|
Logging.Debug("[PlayerController] Paused");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resumes the player controller, allowing input processing again
|
||||||
|
/// </summary>
|
||||||
|
public void DoResume()
|
||||||
|
{
|
||||||
|
if (!isPaused) return;
|
||||||
|
|
||||||
|
isPaused = false;
|
||||||
|
Logging.Debug("[PlayerController] Resumed");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns whether the player controller is currently paused
|
||||||
|
/// </summary>
|
||||||
|
public bool IsPaused => isPaused;
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
@@ -8,6 +9,7 @@ using AppleHills.Core.Settings;
|
|||||||
using Utils;
|
using Utils;
|
||||||
using AppleHills.Core.Interfaces;
|
using AppleHills.Core.Interfaces;
|
||||||
using Core;
|
using Core;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
namespace Minigames.DivingForPictures
|
namespace Minigames.DivingForPictures
|
||||||
{
|
{
|
||||||
@@ -166,13 +168,16 @@ namespace Minigames.DivingForPictures
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
// Register with the DivingGameManager for pause/resume events
|
||||||
|
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||||
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
DivingGameManager.Instance.OnGameInitialized += Initialize;
|
DivingGameManager.Instance.OnGameInitialized += Initialize;
|
||||||
|
|
||||||
// Register with the DivingGameManager for pause/resume events
|
|
||||||
DivingGameManager.Instance.RegisterPausableComponent(this);
|
|
||||||
|
|
||||||
// If game is already initialized, initialize immediately
|
// If game is already initialized, initialize immediately
|
||||||
if (DivingGameManager.Instance.GetType().GetField("_isGameInitialized",
|
if (DivingGameManager.Instance.GetType().GetField("_isGameInitialized",
|
||||||
System.Reflection.BindingFlags.NonPublic |
|
System.Reflection.BindingFlags.NonPublic |
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Minigames.DivingForPictures.Utilities
|
|||||||
|
|
||||||
private bool isPaused = false;
|
private bool isPaused = false;
|
||||||
|
|
||||||
private void Awake()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
DivingGameManager.Instance.RegisterPausableComponent(this);
|
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Minigames.DivingForPictures.Utilities
|
|||||||
|
|
||||||
private bool isPaused = false;
|
private bool isPaused = false;
|
||||||
|
|
||||||
private void Awake()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
DivingGameManager.Instance.RegisterPausableComponent(this);
|
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using Core;
|
using Core;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
@@ -10,9 +11,10 @@ public class DivingGameOverScreen : MonoBehaviour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayAgain()
|
public async void PlayAgain()
|
||||||
{
|
{
|
||||||
SceneManagerService.Instance.ReloadCurrentScene();
|
var progress = new Progress<float>(p => Logging.Debug($"Loading progress: {p * 100:F0}%"));
|
||||||
|
await SceneManagerService.Instance.ReloadCurrentScene(progress);;
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,6 +124,7 @@ namespace UI
|
|||||||
// Clear paused flag and broadcast event
|
// Clear paused flag and broadcast event
|
||||||
_isPaused = false;
|
_isPaused = false;
|
||||||
InputManager.Instance.SetInputMode(InputMode.GameAndUI);
|
InputManager.Instance.SetInputMode(InputMode.GameAndUI);
|
||||||
|
if(resetInput)
|
||||||
OnGameResumed?.Invoke();
|
OnGameResumed?.Invoke();
|
||||||
|
|
||||||
Logging.Debug("[PauseMenu] Game Resumed");
|
Logging.Debug("[PauseMenu] Game Resumed");
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ MonoBehaviour:
|
|||||||
clampXMin: -3.5
|
clampXMin: -3.5
|
||||||
clampXMax: 3.5
|
clampXMax: 3.5
|
||||||
speedExponent: 0.97
|
speedExponent: 0.97
|
||||||
tapMaxDistance: 0.2
|
tapMaxDistance: 0.03
|
||||||
tapDecelerationRate: 15
|
tapDecelerationRate: 15
|
||||||
baseSpawnProbability: 0.2
|
baseSpawnProbability: 0.2
|
||||||
maxSpawnProbability: 0.8
|
maxSpawnProbability: 0.8
|
||||||
|
|||||||
Reference in New Issue
Block a user