Finalized work

This commit is contained in:
Michal Pikulski
2025-11-27 11:27:36 +01:00
parent 8bc4a88958
commit d083c2873e
6 changed files with 305 additions and 22 deletions

View File

@@ -49,6 +49,12 @@ namespace Minigames.StatueDressup.Controllers
{
Logging.Error("[DecorationMenuController] Failed to load StatueDressupSettings!");
}
// Ensure outline starts hidden (do this early so it's ready for saved decorations)
if (statueOutline != null)
{
statueOutline.gameObject.SetActive(false);
}
}
/// <summary>
@@ -64,12 +70,6 @@ namespace Minigames.StatueDressup.Controllers
return;
}
// Ensure outline starts hidden
if (statueOutline != null)
{
statueOutline.gameObject.SetActive(false);
}
var allDecorations = _settings.AllDecorations;
int itemsPerPage = _settings.ItemsPerPage;
@@ -185,14 +185,16 @@ namespace Minigames.StatueDressup.Controllers
// Get outline RectTransform for overlap detection
RectTransform outlineRect = statueOutline != null ? statueOutline.rectTransform : null;
// Initialize with references
// Initialize with references including outline callbacks
instance.Initialize(
data,
outlineRect,
statueController.StatueParent,
statueController,
_settings,
OnDraggableFinished
OnDraggableFinished,
ShowStatueOutline, // Show outline when picking up from statue
HideStatueOutline // Hide outline when drag ends
);
// Position at cursor (in local space)
@@ -220,19 +222,24 @@ namespace Minigames.StatueDressup.Controllers
/// <summary>
/// Show the statue outline to indicate valid drop area
/// </summary>
private void ShowStatueOutline()
public void ShowStatueOutline()
{
Logging.Debug($"[DecorationMenuController] ShowStatueOutline called - statueOutline is null: {statueOutline == null}");
if (statueOutline != null)
{
statueOutline.gameObject.SetActive(true);
Logging.Debug("[DecorationMenuController] Statue outline shown");
}
else
{
Logging.Warning("[DecorationMenuController] Cannot show outline - statueOutline is null!");
}
}
/// <summary>
/// Hide the statue outline after drag ends
/// </summary>
private void HideStatueOutline()
public void HideStatueOutline()
{
if (statueOutline != null)
{

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Core;
using Core.Lifecycle;
using Minigames.StatueDressup.Data;
@@ -420,11 +421,25 @@ namespace Minigames.StatueDressup.Controllers
// Spawn decoration instance
DecorationDraggableInstance instance = Instantiate(draggablePrefab, statueParent);
// Get canvas parent for drag context (used when picking up)
Transform canvasParent = statueParent.parent; // Typically the canvas or draggable container
// Create callbacks for outline show/hide
Logging.Debug($"[StatueDecorationController] MenuController is null: {menuController == null}");
System.Action showOutlineCallback = menuController != null ? (System.Action)menuController.ShowStatueOutline : null;
System.Action hideOutlineCallback = menuController != null ? (System.Action)menuController.HideStatueOutline : null;
Logging.Debug($"[StatueDecorationController] Show outline callback is null: {showOutlineCallback == null}");
// Initialize in "placed" state (skip drag logic)
instance.InitializeAsPlaced(
decorationData,
this,
_settings
_settings,
statueArea, // Pass statue outline for overlap detection
canvasParent, // Pass canvas parent for reparenting during pickup
showOutlineCallback, // Show outline when picking up
hideOutlineCallback, // Hide outline when drag ends
hideOutlineCallback // Also use hide callback for onFinished
);
// Apply saved transform
@@ -480,6 +495,13 @@ namespace Minigames.StatueDressup.Controllers
// openGalleryButton.onClick.RemoveListener(OnOpenGallery);
// }
}
public async void ExitToAppleHills()
{
// Replace with the actual scene name as set in Build Settings
var progress = new Progress<float>(p => Logging.Debug($"Loading progress: {p * 100:F0}%"));
await SceneManagerService.Instance.SwitchSceneAsync("AppleHillsOverworld", progress);
}
}
}