Merge remote-tracking branch 'origin/savya' into work_branch
This commit is contained in:
@@ -108,14 +108,31 @@ namespace Darkmatter.Features.ShapeBuilder.Systems
|
||||
|
||||
_bus.Publish(new ShapeBuilderStartedSignal(template.Id));
|
||||
|
||||
CreateShapePieceInstances(template, preSnappedIds, count, slots, pitch, trayW);
|
||||
var colorByShapeId = BuildColorMap(template, slots);
|
||||
foreach (var s in slots)
|
||||
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);
|
||||
|
||||
CheckIfShapeAssembled();
|
||||
}
|
||||
|
||||
private static Dictionary<string, Color> BuildColorMap(IDrawingTemplate template, SlotMarker[] slots)
|
||||
{
|
||||
var map = new Dictionary<string, Color>();
|
||||
foreach (var p in template.Pieces)
|
||||
if (p != null && !string.IsNullOrEmpty(p.Id) && !map.ContainsKey(p.Id))
|
||||
map[p.Id] = Color.HSVToRGB(UnityEngine.Random.value, 0.7f, 0.95f);
|
||||
foreach (var s in slots)
|
||||
if (s != null && s.Shape != null && !string.IsNullOrEmpty(s.Shape.Id) && !map.ContainsKey(s.Shape.Id))
|
||||
map[s.Shape.Id] = Color.HSVToRGB(UnityEngine.Random.value, 0.7f, 0.95f);
|
||||
return map;
|
||||
}
|
||||
|
||||
private void CreateShapePieceInstances(IDrawingTemplate template, IReadOnlyCollection<string> preSnappedIds,
|
||||
int count,
|
||||
SlotMarker[] slots, float pitch, float trayW)
|
||||
SlotMarker[] slots, float pitch, float trayW, Dictionary<string, Color> colorByShapeId)
|
||||
{
|
||||
var preSnapCounts = new Dictionary<string, int>();
|
||||
if (preSnappedIds != null)
|
||||
@@ -137,6 +154,8 @@ namespace Darkmatter.Features.ShapeBuilder.Systems
|
||||
|
||||
var trayPos = new Vector2(pitch * (i + 1) - trayW * 0.5f, 0f);
|
||||
var piece = _factory.Create(_piecePrefab, shape, candidates, trayPos);
|
||||
if (colorByShapeId != null && colorByShapeId.TryGetValue(shape.Id, out var c))
|
||||
piece.SetColor(c);
|
||||
_pieces.Add(piece);
|
||||
|
||||
if (preSnapCounts.TryGetValue(shape.Id, out var remaining) && remaining > 0)
|
||||
|
||||
@@ -59,6 +59,11 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
|
||||
public void ReassignActiveSlot(SlotMarker slot) => _activeSlot = slot;
|
||||
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
if (image != null) image.color = color;
|
||||
}
|
||||
|
||||
public void Setup(
|
||||
ShapeSO shape,
|
||||
SlotMarker[] candidateSlots,
|
||||
@@ -227,27 +232,18 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
{
|
||||
StopPreviewTweens();
|
||||
Lock();
|
||||
var slot = _activeSlot.RectTransform;
|
||||
|
||||
Sequence.Create()
|
||||
.Group(Tween.Position(RectTransform, slot.position, _cfg.SnapDuration, Ease.OutBack))
|
||||
.Group(Tween.Rotation(RectTransform, slot.rotation, _cfg.SnapDuration, Ease.OutBack))
|
||||
.Group(Tween.LocalScale(RectTransform, slot.localScale, _cfg.SnapDuration, Ease.OutBack))
|
||||
.Group(Tween.UISizeDelta(RectTransform, slot.sizeDelta, _cfg.SnapDuration, Ease.OutBack))
|
||||
.ChainCallback(AlignRectToSlot);
|
||||
FillSlot();
|
||||
|
||||
_sfx.Play(SfxId.ShapeSnap);
|
||||
_bus.Publish(new PieceSnappedSignal(_shape.Id));
|
||||
}
|
||||
|
||||
private void AlignRectToSlot()
|
||||
private void FillSlot()
|
||||
{
|
||||
if (this == null || _activeSlot == null) return;
|
||||
var rt = RectTransform;
|
||||
var slot = _activeSlot.RectTransform;
|
||||
rt.anchorMin = Vector2.zero;
|
||||
rt.anchorMax = Vector2.one;
|
||||
rt.pivot = slot.pivot;
|
||||
rt.pivot = new Vector2(0.5f, 0.5f);
|
||||
rt.anchoredPosition = Vector2.zero;
|
||||
rt.sizeDelta = Vector2.zero;
|
||||
rt.localRotation = Quaternion.identity;
|
||||
@@ -283,7 +279,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
{
|
||||
_activeSlot = slot;
|
||||
Lock();
|
||||
AlignRectToSlot();
|
||||
FillSlot();
|
||||
}
|
||||
|
||||
private void ReturnToTray()
|
||||
|
||||
@@ -20,5 +20,10 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
||||
{
|
||||
if (outline != null) outline.enabled = visible;
|
||||
}
|
||||
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
if (outline != null) outline.color = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1395,8 +1395,8 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Features.GameplayFlow::Darkmatter.Features.GameplayFlow.GameplayFlowFeatureModule
|
||||
sceneRefs: {fileID: 396806867}
|
||||
nextButtonView: {fileID: 0}
|
||||
backButtonView: {fileID: 0}
|
||||
nextButtonView: {fileID: 259035382}
|
||||
backButtonView: {fileID: 1130088203}
|
||||
--- !u!1 &1129540368
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2944,8 +2944,8 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: Artbook
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: f282e17aebd2cf547bdab7be22e5c474, type: 2}
|
||||
m_sharedMaterial: {fileID: 6332886355625335628, guid: f282e17aebd2cf547bdab7be22e5c474, type: 2}
|
||||
m_fontAsset: {fileID: 11400000, guid: dde468a43b0440f4a9d121fb1d8f290e, type: 2}
|
||||
m_sharedMaterial: {fileID: -1548830327015913602, guid: dde468a43b0440f4a9d121fb1d8f290e, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
|
||||
Reference in New Issue
Block a user