Finalize nice animations
This commit is contained in:
@@ -87,18 +87,6 @@ MonoBehaviour:
|
|||||||
m_SerializedLabels:
|
m_SerializedLabels:
|
||||||
- BlokkemonCard
|
- BlokkemonCard
|
||||||
FlaggedDuringContentUpdateRestriction: 0
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
- m_GUID: 80e3766cc597fd94f895f5cd6aa2bcc6
|
|
||||||
m_Address: Assets/Data/Cards/Card_New Card.asset
|
|
||||||
m_ReadOnly: 0
|
|
||||||
m_SerializedLabels:
|
|
||||||
- BlokkemonCard
|
|
||||||
FlaggedDuringContentUpdateRestriction: 0
|
|
||||||
- m_GUID: 82008856df7c51f47b1582de464ba44b
|
|
||||||
m_Address: Assets/Data/Cards/Card_New Card.asset
|
|
||||||
m_ReadOnly: 0
|
|
||||||
m_SerializedLabels:
|
|
||||||
- BlokkemonCard
|
|
||||||
FlaggedDuringContentUpdateRestriction: 0
|
|
||||||
- m_GUID: 99d8e528a8f9ead438e4c88a08c6f6c0
|
- m_GUID: 99d8e528a8f9ead438e4c88a08c6f6c0
|
||||||
m_Address: Assets/Data/Cards/Card_New Card.asset
|
m_Address: Assets/Data/Cards/Card_New Card.asset
|
||||||
m_ReadOnly: 0
|
m_ReadOnly: 0
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ namespace AppleHills.Core.Settings
|
|||||||
[Tooltip("Scale for new cards when enlarged (1.5 = 150% of normal size)")]
|
[Tooltip("Scale for new cards when enlarged (1.5 = 150% of normal size)")]
|
||||||
[SerializeField] private float newCardEnlargedScale = 1.5f;
|
[SerializeField] private float newCardEnlargedScale = 1.5f;
|
||||||
|
|
||||||
[Tooltip("Scale for album cards when enlarged (2.5 = 250% of normal size)")]
|
[Tooltip("Scale for album cards when enlarged (4.0 = 400% of normal size - dramatic showcase)")]
|
||||||
[SerializeField] private float albumCardEnlargedScale = 2.5f;
|
[SerializeField] private float albumCardEnlargedScale = 4.0f;
|
||||||
|
|
||||||
[Tooltip("Duration of scale animations in seconds")]
|
[Tooltip("Duration of scale animations in seconds")]
|
||||||
[SerializeField] private float scaleDuration = 0.3f;
|
[SerializeField] private float scaleDuration = 0.3f;
|
||||||
|
|||||||
@@ -444,23 +444,12 @@ namespace UI.CardSystem
|
|||||||
private void OnCardShrinkRequested(StateMachine.States.CardAlbumEnlargedState state)
|
private void OnCardShrinkRequested(StateMachine.States.CardAlbumEnlargedState state)
|
||||||
{
|
{
|
||||||
if (state == null) return;
|
if (state == null) return;
|
||||||
// Hide backdrop
|
// Hide backdrop; state will animate back to slot and reparent on completion
|
||||||
if (cardEnlargedBackdrop != null)
|
if (cardEnlargedBackdrop != null)
|
||||||
{
|
{
|
||||||
cardEnlargedBackdrop.SetActive(false);
|
cardEnlargedBackdrop.SetActive(false);
|
||||||
}
|
}
|
||||||
// Reparent back to original parent and restore local transform
|
// Do not reparent here; reverse animation is orchestrated by the state
|
||||||
var ctx = state.GetComponentInParent<StateMachine.CardContext>();
|
|
||||||
if (ctx != null)
|
|
||||||
{
|
|
||||||
Transform originalParent = state.GetOriginalParent();
|
|
||||||
if (originalParent != null)
|
|
||||||
{
|
|
||||||
ctx.RootTransform.SetParent(originalParent, true);
|
|
||||||
ctx.RootTransform.localPosition = state.GetOriginalLocalPosition();
|
|
||||||
ctx.RootTransform.localRotation = state.GetOriginalLocalRotation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Core.SaveLoad;
|
using Core.SaveLoad;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using AppleHills.Core.Settings;
|
using AppleHills.Core.Settings;
|
||||||
|
using Pixelplacement;
|
||||||
|
|
||||||
namespace UI.CardSystem.StateMachine.States
|
namespace UI.CardSystem.StateMachine.States
|
||||||
{
|
{
|
||||||
@@ -17,6 +18,7 @@ namespace UI.CardSystem.StateMachine.States
|
|||||||
private Transform _originalParent;
|
private Transform _originalParent;
|
||||||
private Vector3 _originalLocalPosition;
|
private Vector3 _originalLocalPosition;
|
||||||
private Quaternion _originalLocalRotation;
|
private Quaternion _originalLocalRotation;
|
||||||
|
private Vector3 _originalWorldPosition;
|
||||||
|
|
||||||
// Events for page to manage backdrop and reparenting
|
// Events for page to manage backdrop and reparenting
|
||||||
public event System.Action<CardAlbumEnlargedState> OnEnlargeRequested;
|
public event System.Action<CardAlbumEnlargedState> OnEnlargeRequested;
|
||||||
@@ -42,14 +44,18 @@ namespace UI.CardSystem.StateMachine.States
|
|||||||
_originalParent = _context.RootTransform.parent;
|
_originalParent = _context.RootTransform.parent;
|
||||||
_originalLocalPosition = _context.RootTransform.localPosition;
|
_originalLocalPosition = _context.RootTransform.localPosition;
|
||||||
_originalLocalRotation = _context.RootTransform.localRotation;
|
_originalLocalRotation = _context.RootTransform.localRotation;
|
||||||
|
_originalWorldPosition = _context.RootTransform.position;
|
||||||
|
|
||||||
// Notify page to show backdrop and reparent card to top layer
|
// Notify page to show backdrop and reparent card to top layer (preserve world transform)
|
||||||
OnEnlargeRequested?.Invoke(this);
|
OnEnlargeRequested?.Invoke(this);
|
||||||
|
|
||||||
// Enlarge the card using album scale setting
|
// Animate into center and scale up significantly
|
||||||
if (_context.Animator != null)
|
if (_context.Animator != null)
|
||||||
{
|
{
|
||||||
_context.Animator.PlayEnlarge(_settings.AlbumCardEnlargedScale);
|
// Move to center of enlarged container (assumes zero is centered)
|
||||||
|
_context.Animator.AnimateLocalPosition(Vector3.zero, _settings.ScaleDuration);
|
||||||
|
// Enlarge using settings-controlled scale
|
||||||
|
_context.Animator.PlayEnlarge(_settings.AlbumCardEnlargedScale, _settings.ScaleDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logging.Debug($"[CardAlbumEnlargedState] Card enlarged from album: {_context.CardData?.Name}");
|
Logging.Debug($"[CardAlbumEnlargedState] Card enlarged from album: {_context.CardData?.Name}");
|
||||||
@@ -57,22 +63,38 @@ namespace UI.CardSystem.StateMachine.States
|
|||||||
|
|
||||||
public void OnCardClicked(CardContext context)
|
public void OnCardClicked(CardContext context)
|
||||||
{
|
{
|
||||||
// Click to shrink back
|
// Click to shrink back (play reverse of opening animation)
|
||||||
Logging.Debug($"[CardAlbumEnlargedState] Card clicked while enlarged, shrinking back");
|
Logging.Debug($"[CardAlbumEnlargedState] Card clicked while enlarged, shrinking back");
|
||||||
|
|
||||||
// Notify page to prepare for shrink
|
// Ask page to hide backdrop (state will handle moving back & reparenting)
|
||||||
OnShrinkRequested?.Invoke(this);
|
OnShrinkRequested?.Invoke(this);
|
||||||
|
|
||||||
// Shrink animation, then transition back
|
// Animate back to original world position + shrink to original scale
|
||||||
|
float duration = _settings.ScaleDuration;
|
||||||
|
|
||||||
|
// Move using world-space tween so we land exactly on the original position
|
||||||
|
Tween.Position(context.RootTransform, _originalWorldPosition, duration, 0f, Tween.EaseInOut);
|
||||||
|
|
||||||
if (context.Animator != null)
|
if (context.Animator != null)
|
||||||
{
|
{
|
||||||
context.Animator.PlayShrink(_originalScale, onComplete: () =>
|
context.Animator.PlayShrink(_originalScale, duration, onComplete: () =>
|
||||||
{
|
{
|
||||||
|
// Reparent back to original hierarchy and restore local transform
|
||||||
|
context.RootTransform.SetParent(_originalParent, true);
|
||||||
|
context.RootTransform.localPosition = _originalLocalPosition;
|
||||||
|
context.RootTransform.localRotation = _originalLocalRotation;
|
||||||
|
|
||||||
|
// Transition back to placed state
|
||||||
context.StateMachine.ChangeState("PlacedInSlotState");
|
context.StateMachine.ChangeState("PlacedInSlotState");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Fallback if no animator: snap back
|
||||||
|
context.RootTransform.position = _originalWorldPosition;
|
||||||
|
context.RootTransform.SetParent(_originalParent, true);
|
||||||
|
context.RootTransform.localPosition = _originalLocalPosition;
|
||||||
|
context.RootTransform.localRotation = _originalLocalRotation;
|
||||||
context.StateMachine.ChangeState("PlacedInSlotState");
|
context.StateMachine.ChangeState("PlacedInSlotState");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,4 +124,3 @@ namespace UI.CardSystem.StateMachine.States
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ MonoBehaviour:
|
|||||||
flipDuration: 0.6
|
flipDuration: 0.6
|
||||||
flipScalePunch: 1.1
|
flipScalePunch: 1.1
|
||||||
newCardEnlargedScale: 1.5
|
newCardEnlargedScale: 1.5
|
||||||
albumCardEnlargedScale: 1.5
|
albumCardEnlargedScale: 4
|
||||||
scaleDuration: 0.3
|
scaleDuration: 0.3
|
||||||
dragScale: 1.1
|
dragScale: 1.1
|
||||||
cardsToUpgrade: 5
|
cardsToUpgrade: 5
|
||||||
|
|||||||
Reference in New Issue
Block a user