Updates to testing scene
This commit is contained in:
@@ -30,6 +30,11 @@ MonoBehaviour:
|
|||||||
m_ReadOnly: 0
|
m_ReadOnly: 0
|
||||||
m_SerializedLabels: []
|
m_SerializedLabels: []
|
||||||
FlaggedDuringContentUpdateRestriction: 0
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 533a675687aa04146bfb69b8c9be7a6b
|
||||||
|
m_Address: Settings/CardSystemSettings
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
- m_GUID: 8f5195fb013895049a19488fd4d8f2a1
|
- m_GUID: 8f5195fb013895049a19488fd4d8f2a1
|
||||||
m_Address: Settings/InteractionSettings
|
m_Address: Settings/InteractionSettings
|
||||||
m_ReadOnly: 0
|
m_ReadOnly: 0
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,7 @@ namespace UI.CardSystem.StateMachine
|
|||||||
private Transform _transform;
|
private Transform _transform;
|
||||||
private RectTransform _rectTransform;
|
private RectTransform _rectTransform;
|
||||||
private ICardSystemSettings _settings;
|
private ICardSystemSettings _settings;
|
||||||
|
private TweenBase _activeIdleHoverTween;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
@@ -257,16 +258,31 @@ namespace UI.CardSystem.StateMachine
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Idle hover animation (gentle bobbing loop)
|
/// Idle hover animation (gentle bobbing loop)
|
||||||
/// Returns the TweenBase so caller can stop it later
|
/// Returns the TweenBase so caller can stop it later.
|
||||||
|
/// Only starts if not already running, or kills and restarts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TweenBase StartIdleHover(float hoverHeight = 10f, float duration = 1.5f)
|
public TweenBase StartIdleHover(float hoverHeight = 10f, float duration = 1.5f, bool restartIfActive = false)
|
||||||
{
|
{
|
||||||
|
// If already running, either skip or restart
|
||||||
|
if (_activeIdleHoverTween != null)
|
||||||
|
{
|
||||||
|
if (!restartIfActive)
|
||||||
|
{
|
||||||
|
// Already running, skip
|
||||||
|
return _activeIdleHoverTween;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kill existing and restart
|
||||||
|
_activeIdleHoverTween.Stop();
|
||||||
|
_activeIdleHoverTween = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (_rectTransform != null)
|
if (_rectTransform != null)
|
||||||
{
|
{
|
||||||
Vector2 originalPos = _rectTransform.anchoredPosition;
|
Vector2 originalPos = _rectTransform.anchoredPosition;
|
||||||
Vector2 targetPos = originalPos + Vector2.up * hoverHeight;
|
Vector2 targetPos = originalPos + Vector2.up * hoverHeight;
|
||||||
|
|
||||||
return Tween.Value(0f, 1f,
|
_activeIdleHoverTween = Tween.Value(0f, 1f,
|
||||||
(val) =>
|
(val) =>
|
||||||
{
|
{
|
||||||
if (_rectTransform != null)
|
if (_rectTransform != null)
|
||||||
@@ -276,11 +292,32 @@ namespace UI.CardSystem.StateMachine
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
duration, 0f, Tween.EaseInOut, Tween.LoopType.Loop);
|
duration, 0f, Tween.EaseInOut, Tween.LoopType.Loop);
|
||||||
|
|
||||||
|
return _activeIdleHoverTween;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stop idle hover animation and return to original position
|
||||||
|
/// </summary>
|
||||||
|
public void StopIdleHover(Vector2 originalPosition, float duration = 0.3f)
|
||||||
|
{
|
||||||
|
// Stop the tracked tween if it exists
|
||||||
|
if (_activeIdleHoverTween != null)
|
||||||
|
{
|
||||||
|
_activeIdleHoverTween.Stop();
|
||||||
|
_activeIdleHoverTween = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return to original position
|
||||||
|
if (_rectTransform != null)
|
||||||
|
{
|
||||||
|
Tween.AnchoredPosition(_rectTransform, originalPosition, duration, 0f, Tween.EaseInOut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Flip Animations (Two-Phase)
|
#region Flip Animations (Two-Phase)
|
||||||
|
|||||||
@@ -31,6 +31,13 @@ namespace UI.CardSystem.StateMachine.States
|
|||||||
|
|
||||||
public override void OnEnterState()
|
public override void OnEnterState()
|
||||||
{
|
{
|
||||||
|
// Ensure card front is visible and facing camera
|
||||||
|
if (_context.CardDisplay != null)
|
||||||
|
{
|
||||||
|
_context.CardDisplay.gameObject.SetActive(true);
|
||||||
|
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Store original transform for restoration
|
// Store original transform for restoration
|
||||||
_originalScale = _context.RootTransform.localScale;
|
_originalScale = _context.RootTransform.localScale;
|
||||||
_originalParent = _context.RootTransform.parent;
|
_originalParent = _context.RootTransform.parent;
|
||||||
|
|||||||
@@ -24,6 +24,13 @@ namespace UI.CardSystem.StateMachine.States
|
|||||||
|
|
||||||
public override void OnEnterState()
|
public override void OnEnterState()
|
||||||
{
|
{
|
||||||
|
// Ensure card front is visible and facing camera (in case we transitioned from an unexpected state)
|
||||||
|
if (_context.CardDisplay != null)
|
||||||
|
{
|
||||||
|
_context.CardDisplay.gameObject.SetActive(true);
|
||||||
|
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Store original scale
|
// Store original scale
|
||||||
_originalScale = _context.RootTransform.localScale;
|
_originalScale = _context.RootTransform.localScale;
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,13 @@ namespace UI.CardSystem.StateMachine.States
|
|||||||
|
|
||||||
public override void OnEnterState()
|
public override void OnEnterState()
|
||||||
{
|
{
|
||||||
|
// Ensure card front is visible and facing camera
|
||||||
|
if (_context.CardDisplay != null)
|
||||||
|
{
|
||||||
|
_context.CardDisplay.gameObject.SetActive(true);
|
||||||
|
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Store original scale
|
// Store original scale
|
||||||
_originalScale = _context.RootTransform.localScale;
|
_originalScale = _context.RootTransform.localScale;
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,13 @@ namespace UI.CardSystem.StateMachine.States
|
|||||||
|
|
||||||
public override void OnEnterState()
|
public override void OnEnterState()
|
||||||
{
|
{
|
||||||
|
// Ensure card front is visible and facing camera
|
||||||
|
if (_context.CardDisplay != null)
|
||||||
|
{
|
||||||
|
_context.CardDisplay.gameObject.SetActive(true);
|
||||||
|
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Store original scale
|
// Store original scale
|
||||||
_originalScale = _context.RootTransform.localScale;
|
_originalScale = _context.RootTransform.localScale;
|
||||||
_waitingForTap = false;
|
_waitingForTap = false;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Core;
|
using Core;
|
||||||
using Core.SaveLoad;
|
using Core.SaveLoad;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
namespace UI.CardSystem.StateMachine.States
|
namespace UI.CardSystem.StateMachine.States
|
||||||
@@ -20,6 +21,14 @@ namespace UI.CardSystem.StateMachine.States
|
|||||||
|
|
||||||
public override void OnEnterState()
|
public override void OnEnterState()
|
||||||
{
|
{
|
||||||
|
// Ensure card front is visible and facing camera
|
||||||
|
// This is important when spawning cards directly into album (skipping booster flow)
|
||||||
|
if (_context.CardDisplay != null)
|
||||||
|
{
|
||||||
|
_context.CardDisplay.gameObject.SetActive(true);
|
||||||
|
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
Logging.Debug($"[CardPlacedInSlotState] Card placed in slot: {_context.CardData?.Name}");
|
Logging.Debug($"[CardPlacedInSlotState] Card placed in slot: {_context.CardData?.Name}");
|
||||||
|
|
||||||
// Card is now part of the album, no special visuals needed
|
// Card is now part of the album, no special visuals needed
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ namespace UI.CardSystem.StateMachine.States
|
|||||||
|
|
||||||
public override void OnEnterState()
|
public override void OnEnterState()
|
||||||
{
|
{
|
||||||
|
// Ensure card front is visible and facing camera
|
||||||
|
if (_context.CardDisplay != null)
|
||||||
|
{
|
||||||
|
_context.CardDisplay.gameObject.SetActive(true);
|
||||||
|
_context.CardDisplay.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Card is at normal size, fully revealed
|
// Card is at normal size, fully revealed
|
||||||
|
|
||||||
// Show appropriate idle badge
|
// Show appropriate idle badge
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using AppleHills.Data.CardSystem;
|
using AppleHills.Data.CardSystem;
|
||||||
using Core;
|
using Core;
|
||||||
|
using Core.Lifecycle;
|
||||||
|
using Input;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@@ -13,7 +15,7 @@ namespace UI.CardSystem.Testing
|
|||||||
/// Test controller for card state machine testing.
|
/// Test controller for card state machine testing.
|
||||||
/// Provides UI controls to manually test state transitions, animations, and flows.
|
/// Provides UI controls to manually test state transitions, animations, and flows.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CardTestController : MonoBehaviour
|
public class CardTestController : ManagedBehaviour
|
||||||
{
|
{
|
||||||
[Header("Test Card")]
|
[Header("Test Card")]
|
||||||
[SerializeField] private Card testCard;
|
[SerializeField] private Card testCard;
|
||||||
@@ -31,6 +33,8 @@ namespace UI.CardSystem.Testing
|
|||||||
private List<string> _eventLog = new List<string>();
|
private List<string> _eventLog = new List<string>();
|
||||||
private CardContext _cardContext;
|
private CardContext _cardContext;
|
||||||
private Vector3 _originalCardPosition;
|
private Vector3 _originalCardPosition;
|
||||||
|
private Vector3 _originalCardScale;
|
||||||
|
private Vector2 _originalAnchoredPosition;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
@@ -38,6 +42,14 @@ namespace UI.CardSystem.Testing
|
|||||||
{
|
{
|
||||||
_cardContext = testCard.GetComponent<CardContext>();
|
_cardContext = testCard.GetComponent<CardContext>();
|
||||||
_originalCardPosition = testCard.transform.position;
|
_originalCardPosition = testCard.transform.position;
|
||||||
|
_originalCardScale = testCard.transform.localScale;
|
||||||
|
|
||||||
|
// Store original anchored position if it's a RectTransform
|
||||||
|
RectTransform rectTransform = testCard.GetComponent<RectTransform>();
|
||||||
|
if (rectTransform != null)
|
||||||
|
{
|
||||||
|
_originalAnchoredPosition = rectTransform.anchoredPosition;
|
||||||
|
}
|
||||||
|
|
||||||
// Subscribe to all card events
|
// Subscribe to all card events
|
||||||
if (_cardContext != null)
|
if (_cardContext != null)
|
||||||
@@ -64,7 +76,14 @@ namespace UI.CardSystem.Testing
|
|||||||
isClickableToggle.onValueChanged.AddListener(OnIsClickableToggled);
|
isClickableToggle.onValueChanged.AddListener(OnIsClickableToggled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal override void OnManagedAwake()
|
||||||
|
{
|
||||||
|
base.OnManagedAwake();
|
||||||
|
|
||||||
|
InputManager.Instance.SetInputMode(InputMode.UI);
|
||||||
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
// Initialize card with test data
|
// Initialize card with test data
|
||||||
@@ -88,38 +107,72 @@ namespace UI.CardSystem.Testing
|
|||||||
|
|
||||||
#region State Transition Buttons
|
#region State Transition Buttons
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reset card to default state (position, scale) before transitioning to a new state.
|
||||||
|
/// This prevents accumulation of tweens and ensures animations play correctly.
|
||||||
|
/// </summary>
|
||||||
|
private void ResetCardToDefault()
|
||||||
|
{
|
||||||
|
if (testCard == null || _cardContext == null) return;
|
||||||
|
|
||||||
|
// Stop all animations
|
||||||
|
if (_cardContext.Animator != null)
|
||||||
|
{
|
||||||
|
_cardContext.Animator.StopAllAnimations();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset transform immediately
|
||||||
|
testCard.transform.localScale = _originalCardScale;
|
||||||
|
testCard.transform.position = _originalCardPosition;
|
||||||
|
|
||||||
|
// Reset anchored position if it's a RectTransform
|
||||||
|
RectTransform rectTransform = testCard.GetComponent<RectTransform>();
|
||||||
|
if (rectTransform != null)
|
||||||
|
{
|
||||||
|
rectTransform.anchoredPosition = _originalAnchoredPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogEvent("Card reset to default state");
|
||||||
|
}
|
||||||
|
|
||||||
public void TransitionToIdleState()
|
public void TransitionToIdleState()
|
||||||
{
|
{
|
||||||
|
ResetCardToDefault();
|
||||||
_cardContext?.StateMachine.ChangeState("IdleState");
|
_cardContext?.StateMachine.ChangeState("IdleState");
|
||||||
LogEvent("Transitioned to IdleState");
|
LogEvent("Transitioned to IdleState");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TransitionToRevealedState()
|
public void TransitionToRevealedState()
|
||||||
{
|
{
|
||||||
|
ResetCardToDefault();
|
||||||
_cardContext?.StateMachine.ChangeState("RevealedState");
|
_cardContext?.StateMachine.ChangeState("RevealedState");
|
||||||
LogEvent("Transitioned to RevealedState");
|
LogEvent("Transitioned to RevealedState");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TransitionToEnlargedNewState()
|
public void TransitionToEnlargedNewState()
|
||||||
{
|
{
|
||||||
|
ResetCardToDefault();
|
||||||
_cardContext?.StateMachine.ChangeState("EnlargedNewState");
|
_cardContext?.StateMachine.ChangeState("EnlargedNewState");
|
||||||
LogEvent("Transitioned to EnlargedNewState");
|
LogEvent("Transitioned to EnlargedNewState");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TransitionToEnlargedRepeatState()
|
public void TransitionToEnlargedRepeatState()
|
||||||
{
|
{
|
||||||
|
ResetCardToDefault();
|
||||||
_cardContext?.StateMachine.ChangeState("EnlargedRepeatState");
|
_cardContext?.StateMachine.ChangeState("EnlargedRepeatState");
|
||||||
LogEvent("Transitioned to EnlargedRepeatState");
|
LogEvent("Transitioned to EnlargedRepeatState");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TransitionToDraggingState()
|
public void TransitionToDraggingState()
|
||||||
{
|
{
|
||||||
|
ResetCardToDefault();
|
||||||
_cardContext?.StateMachine.ChangeState("DraggingState");
|
_cardContext?.StateMachine.ChangeState("DraggingState");
|
||||||
LogEvent("Transitioned to DraggingState");
|
LogEvent("Transitioned to DraggingState");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TransitionToAlbumEnlargedState()
|
public void TransitionToAlbumEnlargedState()
|
||||||
{
|
{
|
||||||
|
ResetCardToDefault();
|
||||||
_cardContext?.StateMachine.ChangeState("AlbumEnlargedState");
|
_cardContext?.StateMachine.ChangeState("AlbumEnlargedState");
|
||||||
LogEvent("Transitioned to AlbumEnlargedState");
|
LogEvent("Transitioned to AlbumEnlargedState");
|
||||||
}
|
}
|
||||||
@@ -222,6 +275,9 @@ namespace UI.CardSystem.Testing
|
|||||||
|
|
||||||
public void PlayFlipAnimation()
|
public void PlayFlipAnimation()
|
||||||
{
|
{
|
||||||
|
// Reset card first to prevent accumulation
|
||||||
|
ResetCardToDefault();
|
||||||
|
|
||||||
// Transition to IdleState and programmatically trigger flip
|
// Transition to IdleState and programmatically trigger flip
|
||||||
TransitionToIdleState();
|
TransitionToIdleState();
|
||||||
|
|
||||||
@@ -238,7 +294,8 @@ namespace UI.CardSystem.Testing
|
|||||||
{
|
{
|
||||||
if (_cardContext?.Animator != null)
|
if (_cardContext?.Animator != null)
|
||||||
{
|
{
|
||||||
_cardContext.Animator.PlayEnlarge(2.5f);
|
ResetCardToDefault();
|
||||||
|
_cardContext.Animator.PlayEnlarge(1.5f);
|
||||||
LogEvent("Playing enlarge animation");
|
LogEvent("Playing enlarge animation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,6 +304,7 @@ namespace UI.CardSystem.Testing
|
|||||||
{
|
{
|
||||||
if (_cardContext?.Animator != null)
|
if (_cardContext?.Animator != null)
|
||||||
{
|
{
|
||||||
|
// Don't reset for shrink - we want to shrink from current state
|
||||||
_cardContext.Animator.PlayShrink(Vector3.one, null);
|
_cardContext.Animator.PlayShrink(Vector3.one, null);
|
||||||
LogEvent("Playing shrink animation");
|
LogEvent("Playing shrink animation");
|
||||||
}
|
}
|
||||||
@@ -256,15 +314,21 @@ namespace UI.CardSystem.Testing
|
|||||||
{
|
{
|
||||||
if (_cardContext?.Animator != null)
|
if (_cardContext?.Animator != null)
|
||||||
{
|
{
|
||||||
_cardContext.Animator.StartIdleHover(10f, 1.5f);
|
// Reset card position first to prevent accumulation
|
||||||
|
ResetCardToDefault();
|
||||||
|
|
||||||
|
_cardContext.Animator.StartIdleHover(10f, 1.5f, restartIfActive: true);
|
||||||
LogEvent("Started idle hover animation");
|
LogEvent("Started idle hover animation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopIdleHoverAnimation()
|
public void StopIdleHoverAnimation()
|
||||||
{
|
{
|
||||||
// Stopping hover is handled by IdleState's OnDisable
|
if (_cardContext?.Animator != null)
|
||||||
LogEvent("Idle hover stopped (change state to stop)");
|
{
|
||||||
|
_cardContext.Animator.StopIdleHover(_originalAnchoredPosition);
|
||||||
|
LogEvent("Stopped idle hover animation");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -276,7 +340,15 @@ namespace UI.CardSystem.Testing
|
|||||||
if (testCard != null)
|
if (testCard != null)
|
||||||
{
|
{
|
||||||
testCard.transform.position = _originalCardPosition;
|
testCard.transform.position = _originalCardPosition;
|
||||||
testCard.transform.localScale = Vector3.one;
|
testCard.transform.localScale = _originalCardScale;
|
||||||
|
|
||||||
|
// Reset anchored position if it's a RectTransform
|
||||||
|
RectTransform rectTransform = testCard.GetComponent<RectTransform>();
|
||||||
|
if (rectTransform != null)
|
||||||
|
{
|
||||||
|
rectTransform.anchoredPosition = _originalAnchoredPosition;
|
||||||
|
}
|
||||||
|
|
||||||
LogEvent("Card position reset");
|
LogEvent("Card position reset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ MonoBehaviour:
|
|||||||
flipDuration: 0.6
|
flipDuration: 0.6
|
||||||
flipScalePunch: 1.1
|
flipScalePunch: 1.1
|
||||||
newCardEnlargedScale: 1.5
|
newCardEnlargedScale: 1.5
|
||||||
albumCardEnlargedScale: 2.5
|
albumCardEnlargedScale: 1.5
|
||||||
scaleDuration: 0.3
|
scaleDuration: 0.3
|
||||||
dragScale: 1.1
|
dragScale: 1.1
|
||||||
cardsToUpgrade: 5
|
cardsToUpgrade: 5
|
||||||
|
|||||||
Reference in New Issue
Block a user