Updates to testing scene

This commit is contained in:
Michal Pikulski
2025-11-12 20:26:51 +01:00
parent 42b67167eb
commit 4f5fba8b50
11 changed files with 8621 additions and 25 deletions

View File

@@ -30,6 +30,11 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 533a675687aa04146bfb69b8c9be7a6b
m_Address: Settings/CardSystemSettings
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 8f5195fb013895049a19488fd4d8f2a1
m_Address: Settings/InteractionSettings
m_ReadOnly: 0

File diff suppressed because it is too large Load Diff

View File

@@ -17,6 +17,7 @@ namespace UI.CardSystem.StateMachine
private Transform _transform;
private RectTransform _rectTransform;
private ICardSystemSettings _settings;
private TweenBase _activeIdleHoverTween;
private void Awake()
{
@@ -257,16 +258,31 @@ namespace UI.CardSystem.StateMachine
/// <summary>
/// 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>
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)
{
Vector2 originalPos = _rectTransform.anchoredPosition;
Vector2 targetPos = originalPos + Vector2.up * hoverHeight;
return Tween.Value(0f, 1f,
_activeIdleHoverTween = Tween.Value(0f, 1f,
(val) =>
{
if (_rectTransform != null)
@@ -276,11 +292,32 @@ namespace UI.CardSystem.StateMachine
}
},
duration, 0f, Tween.EaseInOut, Tween.LoopType.Loop);
return _activeIdleHoverTween;
}
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
#region Flip Animations (Two-Phase)

View File

@@ -31,6 +31,13 @@ namespace UI.CardSystem.StateMachine.States
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
_originalScale = _context.RootTransform.localScale;
_originalParent = _context.RootTransform.parent;

View File

@@ -24,6 +24,13 @@ namespace UI.CardSystem.StateMachine.States
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
_originalScale = _context.RootTransform.localScale;

View File

@@ -27,6 +27,13 @@ namespace UI.CardSystem.StateMachine.States
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
_originalScale = _context.RootTransform.localScale;

View File

@@ -30,6 +30,13 @@ namespace UI.CardSystem.StateMachine.States
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
_originalScale = _context.RootTransform.localScale;
_waitingForTap = false;

View File

@@ -1,5 +1,6 @@
using Core;
using Core.SaveLoad;
using UnityEngine;
using UnityEngine.EventSystems;
namespace UI.CardSystem.StateMachine.States
@@ -20,6 +21,14 @@ namespace UI.CardSystem.StateMachine.States
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}");
// Card is now part of the album, no special visuals needed

View File

@@ -25,6 +25,13 @@ namespace UI.CardSystem.StateMachine.States
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
// Show appropriate idle badge

View File

@@ -1,6 +1,8 @@
using System.Collections.Generic;
using AppleHills.Data.CardSystem;
using Core;
using Core.Lifecycle;
using Input;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
@@ -13,7 +15,7 @@ namespace UI.CardSystem.Testing
/// Test controller for card state machine testing.
/// Provides UI controls to manually test state transitions, animations, and flows.
/// </summary>
public class CardTestController : MonoBehaviour
public class CardTestController : ManagedBehaviour
{
[Header("Test Card")]
[SerializeField] private Card testCard;
@@ -31,6 +33,8 @@ namespace UI.CardSystem.Testing
private List<string> _eventLog = new List<string>();
private CardContext _cardContext;
private Vector3 _originalCardPosition;
private Vector3 _originalCardScale;
private Vector2 _originalAnchoredPosition;
private void Awake()
{
@@ -38,6 +42,14 @@ namespace UI.CardSystem.Testing
{
_cardContext = testCard.GetComponent<CardContext>();
_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
if (_cardContext != null)
@@ -64,7 +76,14 @@ namespace UI.CardSystem.Testing
isClickableToggle.onValueChanged.AddListener(OnIsClickableToggled);
}
}
internal override void OnManagedAwake()
{
base.OnManagedAwake();
InputManager.Instance.SetInputMode(InputMode.UI);
}
private void Start()
{
// Initialize card with test data
@@ -88,38 +107,72 @@ namespace UI.CardSystem.Testing
#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()
{
ResetCardToDefault();
_cardContext?.StateMachine.ChangeState("IdleState");
LogEvent("Transitioned to IdleState");
}
public void TransitionToRevealedState()
{
ResetCardToDefault();
_cardContext?.StateMachine.ChangeState("RevealedState");
LogEvent("Transitioned to RevealedState");
}
public void TransitionToEnlargedNewState()
{
ResetCardToDefault();
_cardContext?.StateMachine.ChangeState("EnlargedNewState");
LogEvent("Transitioned to EnlargedNewState");
}
public void TransitionToEnlargedRepeatState()
{
ResetCardToDefault();
_cardContext?.StateMachine.ChangeState("EnlargedRepeatState");
LogEvent("Transitioned to EnlargedRepeatState");
}
public void TransitionToDraggingState()
{
ResetCardToDefault();
_cardContext?.StateMachine.ChangeState("DraggingState");
LogEvent("Transitioned to DraggingState");
}
public void TransitionToAlbumEnlargedState()
{
ResetCardToDefault();
_cardContext?.StateMachine.ChangeState("AlbumEnlargedState");
LogEvent("Transitioned to AlbumEnlargedState");
}
@@ -222,6 +275,9 @@ namespace UI.CardSystem.Testing
public void PlayFlipAnimation()
{
// Reset card first to prevent accumulation
ResetCardToDefault();
// Transition to IdleState and programmatically trigger flip
TransitionToIdleState();
@@ -238,7 +294,8 @@ namespace UI.CardSystem.Testing
{
if (_cardContext?.Animator != null)
{
_cardContext.Animator.PlayEnlarge(2.5f);
ResetCardToDefault();
_cardContext.Animator.PlayEnlarge(1.5f);
LogEvent("Playing enlarge animation");
}
}
@@ -247,6 +304,7 @@ namespace UI.CardSystem.Testing
{
if (_cardContext?.Animator != null)
{
// Don't reset for shrink - we want to shrink from current state
_cardContext.Animator.PlayShrink(Vector3.one, null);
LogEvent("Playing shrink animation");
}
@@ -256,15 +314,21 @@ namespace UI.CardSystem.Testing
{
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");
}
}
public void StopIdleHoverAnimation()
{
// Stopping hover is handled by IdleState's OnDisable
LogEvent("Idle hover stopped (change state to stop)");
if (_cardContext?.Animator != null)
{
_cardContext.Animator.StopIdleHover(_originalAnchoredPosition);
LogEvent("Stopped idle hover animation");
}
}
#endregion
@@ -276,7 +340,15 @@ namespace UI.CardSystem.Testing
if (testCard != null)
{
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");
}
}

View File

@@ -18,7 +18,7 @@ MonoBehaviour:
flipDuration: 0.6
flipScalePunch: 1.1
newCardEnlargedScale: 1.5
albumCardEnlargedScale: 2.5
albumCardEnlargedScale: 1.5
scaleDuration: 0.3
dragScale: 1.1
cardsToUpgrade: 5