Merge remote-tracking branch 'origin/savya' into work_branch
This commit is contained in:
@@ -5,4 +5,5 @@ namespace Darkmatter.Core.Contracts.Features.GameplayFlow;
|
||||
public interface IGameplaySceneRefs
|
||||
{
|
||||
RectTransform PaperRoot { get; }
|
||||
ParticleSystem Confetti { get; }
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ namespace Darkmatter.Core.Data.Static.Features.ShapeBuilder
|
||||
[SerializeField] private float snapDuration = 0.25f;
|
||||
[SerializeField] private float returnDuration = 0.25f;
|
||||
|
||||
[Header("Drag")]
|
||||
[SerializeField, Range(1f, 2f)] private float dragScale = 1.15f;
|
||||
|
||||
[Header("Preview easing")]
|
||||
[SerializeField] private AnimationCurve previewCurve = AnimationCurve.EaseInOut(0, 0, 1, 1);
|
||||
|
||||
@@ -21,6 +24,7 @@ namespace Darkmatter.Core.Data.Static.Features.ShapeBuilder
|
||||
public float PreviewRadius => previewRadius;
|
||||
public float SnapDuration => snapDuration;
|
||||
public float ReturnDuration => returnDuration;
|
||||
public float DragScale => dragScale;
|
||||
public AnimationCurve PreviewCurve => previewCurve;
|
||||
|
||||
public Vector2 DragSizeDelta(ShapeSO shape) =>
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace Darkmatter.Features.GameplayFlow.SceneRefs
|
||||
public class GameplaySceneRefs : MonoBehaviour, IGameplaySceneRefs
|
||||
{
|
||||
[SerializeField] private RectTransform paperRoot;
|
||||
|
||||
[SerializeField] private ParticleSystem confetti;
|
||||
public RectTransform PaperRoot => paperRoot;
|
||||
public ParticleSystem Confetti => confetti;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ namespace Darkmatter.Features.GameplayFlow.Systems
|
||||
private readonly ISceneService _scenes;
|
||||
private readonly ICaptureFeature _capture;
|
||||
private readonly ILoadingScreen _loadingScreen;
|
||||
private readonly IGameplaySceneRefs _refs;
|
||||
private readonly IEventBus _bus;
|
||||
|
||||
private IDrawingTemplate _template;
|
||||
@@ -53,6 +54,7 @@ namespace Darkmatter.Features.GameplayFlow.Systems
|
||||
ISceneService scenes,
|
||||
ICaptureFeature capture,
|
||||
ILoadingScreen loadingScreen,
|
||||
IGameplaySceneRefs refs,
|
||||
IEventBus bus)
|
||||
{
|
||||
_progression = progression;
|
||||
@@ -62,6 +64,7 @@ namespace Darkmatter.Features.GameplayFlow.Systems
|
||||
_scenes = scenes;
|
||||
_capture = capture;
|
||||
_loadingScreen = loadingScreen;
|
||||
_refs = refs;
|
||||
_bus = bus;
|
||||
}
|
||||
|
||||
@@ -123,6 +126,7 @@ namespace Darkmatter.Features.GameplayFlow.Systems
|
||||
public async UniTask NextAsync(CancellationToken ct)
|
||||
{
|
||||
await SaveCurrentAsync(ct);
|
||||
_refs.Confetti.Play();
|
||||
await _coloring.PlayCompletionAnimationAsync(ct);
|
||||
_progression.MarkCompleted(_templateId);
|
||||
|
||||
@@ -147,7 +151,6 @@ namespace Darkmatter.Features.GameplayFlow.Systems
|
||||
|
||||
public void OnApplicationPaused()
|
||||
{
|
||||
// Fire-and-forget — pause window is small; PlayerPrefs write is sync under the hood.
|
||||
SaveCurrentAsync(CancellationToken.None).Forget();
|
||||
}
|
||||
|
||||
|
||||
@@ -99,8 +99,6 @@ namespace Darkmatter.Features.ShapeBuilder.Systems
|
||||
ct.ThrowIfCancellationRequested();
|
||||
|
||||
int count = template.Pieces.Count;
|
||||
float trayW = _holder.SpawnWidth;
|
||||
float pitch = trayW / (count + 1);
|
||||
|
||||
_currentTemplateId = template.Id;
|
||||
_expected = count;
|
||||
@@ -113,7 +111,7 @@ namespace Darkmatter.Features.ShapeBuilder.Systems
|
||||
if (s != null && s.Shape != null && colorByShapeId.TryGetValue(s.Shape.Id, out var c))
|
||||
s.SetColor(c);
|
||||
|
||||
CreateShapePieceInstances(template, preSnappedIds, count, slots, pitch, trayW, colorByShapeId);
|
||||
CreateShapePieceInstances(template, preSnappedIds, count, slots, colorByShapeId);
|
||||
|
||||
CheckIfShapeAssembled();
|
||||
}
|
||||
@@ -132,7 +130,7 @@ namespace Darkmatter.Features.ShapeBuilder.Systems
|
||||
|
||||
private void CreateShapePieceInstances(IDrawingTemplate template, IReadOnlyCollection<string> preSnappedIds,
|
||||
int count,
|
||||
SlotMarker[] slots, float pitch, float trayW, Dictionary<string, Color> colorByShapeId)
|
||||
SlotMarker[] slots, Dictionary<string, Color> colorByShapeId)
|
||||
{
|
||||
var preSnapCounts = new Dictionary<string, int>();
|
||||
if (preSnappedIds != null)
|
||||
@@ -152,8 +150,7 @@ namespace Darkmatter.Features.ShapeBuilder.Systems
|
||||
continue;
|
||||
}
|
||||
|
||||
var trayPos = new Vector2(pitch * (i + 1) - trayW * 0.5f, 0f);
|
||||
var piece = _factory.Create(_piecePrefab, shape, candidates, trayPos);
|
||||
var piece = _factory.Create(_piecePrefab, shape, candidates, Vector2.zero);
|
||||
if (colorByShapeId != null && colorByShapeId.TryGetValue(shape.Id, out var c))
|
||||
piece.SetColor(c);
|
||||
_pieces.Add(piece);
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
private Vector2 _origAnchorMin;
|
||||
private Vector2 _origAnchorMax;
|
||||
private Vector2 _origPivot;
|
||||
private bool _origPreserveAspect;
|
||||
|
||||
// Per-drag state
|
||||
private RectTransform _rt;
|
||||
@@ -90,6 +91,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
_origAnchorMin = RectTransform.anchorMin;
|
||||
_origAnchorMax = RectTransform.anchorMax;
|
||||
_origPivot = RectTransform.pivot;
|
||||
_origPreserveAspect = image != null && image.preserveAspect;
|
||||
|
||||
image.sprite = shape.Sprite;
|
||||
ApplyTrayPose();
|
||||
@@ -112,6 +114,8 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
_dragLocalScale = RectTransform.localScale;
|
||||
_grabOffset = RectTransform.anchoredPosition - ScreenToLocal(e.position);
|
||||
_inPreview = false;
|
||||
|
||||
Tween.LocalScale(RectTransform, _dragLocalScale * _cfg.DragScale, _cfg.SnapDuration, Ease.OutQuad);
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData e)
|
||||
@@ -182,16 +186,18 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
if (toSlot && _activeSlot != null)
|
||||
{
|
||||
var slot = _activeSlot.RectTransform;
|
||||
if (image != null) image.preserveAspect = false;
|
||||
_previewSeq = Sequence.Create()
|
||||
.Group(Tween.UIAnchoredPosition(RectTransform, SlotPosInDragSpace(), _cfg.SnapDuration, Ease.OutQuad))
|
||||
.Group(Tween.LocalScale(RectTransform, SlotScaleInDragSpace(), _cfg.SnapDuration, Ease.OutQuad))
|
||||
.Group(Tween.LocalRotation(RectTransform, SlotRotInDragSpace(), _cfg.SnapDuration, Ease.OutQuad))
|
||||
.Group(Tween.UISizeDelta(RectTransform, slot.sizeDelta, _cfg.SnapDuration, Ease.OutQuad));
|
||||
.Group(Tween.UISizeDelta(RectTransform, slot.rect.size, _cfg.SnapDuration, Ease.OutQuad));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (image != null) image.preserveAspect = true;
|
||||
_previewSeq = Sequence.Create()
|
||||
.Group(Tween.LocalScale(RectTransform, _dragLocalScale, _cfg.SnapDuration, Ease.OutQuad))
|
||||
.Group(Tween.LocalScale(RectTransform, _dragLocalScale * _cfg.DragScale, _cfg.SnapDuration, Ease.OutQuad))
|
||||
.Group(Tween.LocalRotation(RectTransform, Quaternion.identity, _cfg.SnapDuration, Ease.OutQuad))
|
||||
.Group(Tween.UISizeDelta(RectTransform, _dragSizeDelta, _cfg.SnapDuration, Ease.OutQuad));
|
||||
}
|
||||
@@ -241,13 +247,15 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
private void FillSlot()
|
||||
{
|
||||
var rt = RectTransform;
|
||||
rt.anchorMin = Vector2.zero;
|
||||
rt.anchorMax = Vector2.one;
|
||||
var slot = _activeSlot.RectTransform;
|
||||
rt.anchorMin = new Vector2(0.5f, 0.5f);
|
||||
rt.anchorMax = new Vector2(0.5f, 0.5f);
|
||||
rt.pivot = new Vector2(0.5f, 0.5f);
|
||||
rt.anchoredPosition = Vector2.zero;
|
||||
rt.sizeDelta = Vector2.zero;
|
||||
rt.anchoredPosition = slot.rect.center;
|
||||
rt.sizeDelta = slot.rect.size;
|
||||
rt.localRotation = Quaternion.identity;
|
||||
rt.localScale = Vector3.one;
|
||||
if (image != null) image.preserveAspect = false;
|
||||
}
|
||||
|
||||
internal void UnsnapInternal(Transform parent, int siblingIndex, Vector2 pos, Vector2 size, Quaternion rot)
|
||||
@@ -270,6 +278,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
RectTransform.sizeDelta = size;
|
||||
RectTransform.localRotation = rot;
|
||||
RectTransform.localScale = Vector3.one;
|
||||
if (image != null) image.preserveAspect = _origPreserveAspect;
|
||||
|
||||
_sfx.Play(SfxId.ShapeReturn);
|
||||
_bus.Publish(new PieceUnsnappedSignal(_shape.Id));
|
||||
@@ -315,7 +324,6 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
|
||||
private void ApplyTrayPose()
|
||||
{
|
||||
RectTransform.anchoredPosition = _trayPos;
|
||||
RectTransform.sizeDelta = _traySize;
|
||||
RectTransform.localRotation = Quaternion.identity;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
public ShapeSO Shape => shape;
|
||||
public string SlotId => shape != null ? shape.Id : null;
|
||||
public RectTransform RectTransform => (RectTransform)transform;
|
||||
public RectTransform FitRect => outline != null ? outline.rectTransform : (RectTransform)transform;
|
||||
public bool IsOccupied { get; private set; }
|
||||
|
||||
public void SetOccupied(bool value) => IsOccupied = value;
|
||||
|
||||
@@ -68,7 +68,7 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: c3293fddd457324499e794c843736653, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_PreserveAspect: 1
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
|
||||
@@ -68,7 +68,7 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: cbc63d77c9f7c8448b6ff8900b09cc3f, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_PreserveAspect: 1
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -926,6 +926,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Features.GameplayFlow::Darkmatter.Features.GameplayFlow.SceneRefs.GameplaySceneRefs
|
||||
paperRoot: {fileID: 1143672390}
|
||||
confetti: {fileID: 1141121867}
|
||||
--- !u!1 &600922870
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1844,7 +1845,7 @@ MonoBehaviour:
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
m_ChildAlignment: 1
|
||||
m_Spacing: 0
|
||||
m_Spacing: 30
|
||||
m_ChildForceExpandWidth: 0
|
||||
m_ChildForceExpandHeight: 0
|
||||
m_ChildControlWidth: 0
|
||||
|
||||
Reference in New Issue
Block a user