diff --git a/Assets/Prefabs/Managers/PlayerHUD.prefab b/Assets/Prefabs/Managers/PlayerHUD.prefab index 1c1b01fd..17e73cfc 100644 --- a/Assets/Prefabs/Managers/PlayerHUD.prefab +++ b/Assets/Prefabs/Managers/PlayerHUD.prefab @@ -1168,6 +1168,7 @@ MonoBehaviour: eagleEye: {fileID: 8093509920149135307} ramaSjangButton: {fileID: 4599222264323240281} scrabBookButton: {fileID: 2880351836456325619} + pauseButton: {fileID: 4413855344712201574} cinematicSprites: {fileID: 0} cinematicBackgroundSprites: {fileID: 0} currentCinematicPlayer: {fileID: 0} diff --git a/Assets/Scenes/MiniGames/StatueDecoration.unity b/Assets/Scenes/MiniGames/StatueDecoration.unity index f2659de5..402ecfdc 100644 --- a/Assets/Scenes/MiniGames/StatueDecoration.unity +++ b/Assets/Scenes/MiniGames/StatueDecoration.unity @@ -2173,6 +2173,7 @@ RectTransform: - {fileID: 1443594949} - {fileID: 61401516} - {fileID: 1678978} + - {fileID: 1758487248} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -2888,6 +2889,139 @@ MonoBehaviour: m_Spacing: {x: 50, y: 50} m_Constraint: 1 m_ConstraintCount: 3 +--- !u!1 &1758487247 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1758487248} + - component: {fileID: 1758487251} + - component: {fileID: 1758487250} + - component: {fileID: 1758487249} + m_Layer: 5 + m_Name: Button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1758487248 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1758487247} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1217454518} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -75, y: -75} + m_SizeDelta: {x: 150, y: 150} + m_Pivot: {x: 1, y: 1} +--- !u!114 &1758487249 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1758487247} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Button + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1758487250} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1647993458} + m_TargetAssemblyTypeName: Minigames.StatueDressup.Controllers.StatueDecorationController, + AppleHillsScripts + m_MethodName: ExitToAppleHills + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &1758487250 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1758487247} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 607773040016097035, guid: ee014bd71cac2bc4ab845f435726f383, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1758487251 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1758487247} + m_CullTransparentMesh: 1 --- !u!1 &1774956262 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Minigames/StatueDressup/Controllers/DecorationMenuController.cs b/Assets/Scripts/Minigames/StatueDressup/Controllers/DecorationMenuController.cs index df8285a5..130de96f 100644 --- a/Assets/Scripts/Minigames/StatueDressup/Controllers/DecorationMenuController.cs +++ b/Assets/Scripts/Minigames/StatueDressup/Controllers/DecorationMenuController.cs @@ -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); + } } /// @@ -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 /// /// Show the statue outline to indicate valid drop area /// - 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!"); + } } /// /// Hide the statue outline after drag ends /// - private void HideStatueOutline() + public void HideStatueOutline() { if (statueOutline != null) { diff --git a/Assets/Scripts/Minigames/StatueDressup/Controllers/StatueDecorationController.cs b/Assets/Scripts/Minigames/StatueDressup/Controllers/StatueDecorationController.cs index 1c6ab4ed..57d357d3 100644 --- a/Assets/Scripts/Minigames/StatueDressup/Controllers/StatueDecorationController.cs +++ b/Assets/Scripts/Minigames/StatueDressup/Controllers/StatueDecorationController.cs @@ -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(p => Logging.Debug($"Loading progress: {p * 100:F0}%")); + await SceneManagerService.Instance.SwitchSceneAsync("AppleHillsOverworld", progress); + } } } diff --git a/Assets/Scripts/Minigames/StatueDressup/DragDrop/DecorationDraggableInstance.cs b/Assets/Scripts/Minigames/StatueDressup/DragDrop/DecorationDraggableInstance.cs index d6446961..b6470357 100644 --- a/Assets/Scripts/Minigames/StatueDressup/DragDrop/DecorationDraggableInstance.cs +++ b/Assets/Scripts/Minigames/StatueDressup/DragDrop/DecorationDraggableInstance.cs @@ -12,8 +12,9 @@ namespace Minigames.StatueDressup.DragDrop /// Draggable instance of a decoration that can be placed on the statue. /// Created dynamically when dragging from menu or picking up from statue. /// Destroyed if dropped outside statue area. + /// Supports tapping and dragging when placed on statue. /// - public class DecorationDraggableInstance : MonoBehaviour + public class DecorationDraggableInstance : MonoBehaviour, IPointerClickHandler, IBeginDragHandler, IDragHandler, IEndDragHandler { [Header("References")] [SerializeField] private Image decorationImage; @@ -22,15 +23,19 @@ namespace Minigames.StatueDressup.DragDrop private DecorationData _decorationData; private RectTransform _rectTransform; private Canvas _canvas; + private Transform _canvasParent; // Parent transform for dragging (usually canvas or draggable container) private RectTransform _statueOutline; private Transform _statueParent; private StatueDecorationController _controller; private AppleHills.Core.Settings.IStatueDressupSettings _settings; private System.Action _onFinishedCallback; + private System.Action _onShowOutlineCallback; + private System.Action _onHideOutlineCallback; private bool _isDragging; private bool _isPlacedOnStatue; private Vector3 _dragOffset; + private bool _dragStarted; // Track if drag actually started (vs just a click) // Properties public DecorationData Data => _decorationData; @@ -41,10 +46,22 @@ namespace Minigames.StatueDressup.DragDrop _rectTransform = GetComponent(); _canvas = GetComponentInParent(); + // Store initial parent for dragging context + if (transform.parent != null) + { + _canvasParent = transform.parent; + } + if (canvasGroup == null) { canvasGroup = gameObject.AddComponent(); } + + // Ensure the decoration image can receive raycasts + if (decorationImage != null) + { + decorationImage.raycastTarget = true; + } } /// @@ -52,7 +69,7 @@ namespace Minigames.StatueDressup.DragDrop /// public void Initialize(DecorationData data, RectTransform statueOutline, Transform statueParent, StatueDecorationController controller, AppleHills.Core.Settings.IStatueDressupSettings settings, - System.Action onFinishedCallback) + System.Action onFinishedCallback, System.Action onShowOutline = null, System.Action onHideOutline = null) { _decorationData = data; _statueOutline = statueOutline; @@ -60,6 +77,8 @@ namespace Minigames.StatueDressup.DragDrop _controller = controller; _settings = settings; _onFinishedCallback = onFinishedCallback; + _onShowOutlineCallback = onShowOutline; + _onHideOutlineCallback = onHideOutline; // Set sprite if (decorationImage != null && data != null && data.DecorationSprite != null) @@ -81,7 +100,9 @@ namespace Minigames.StatueDressup.DragDrop /// Skips drag logic and sets up as if already placed on statue /// public void InitializeAsPlaced(DecorationData data, StatueDecorationController controller, - AppleHills.Core.Settings.IStatueDressupSettings settings) + AppleHills.Core.Settings.IStatueDressupSettings settings, RectTransform statueOutline = null, + Transform canvasParent = null, System.Action onShowOutline = null, System.Action onHideOutline = null, + System.Action onFinished = null) { _decorationData = data; _controller = controller; @@ -89,6 +110,23 @@ namespace Minigames.StatueDressup.DragDrop _isPlacedOnStatue = true; _isDragging = false; + // Store references needed for pickup + _statueOutline = statueOutline; + _statueParent = transform.parent; // Already parented to statue when this is called + if (canvasParent != null) + { + _canvasParent = canvasParent; + } + + // Store outline callbacks for when picking up from statue + _onShowOutlineCallback = onShowOutline; + _onHideOutlineCallback = onHideOutline; + _onFinishedCallback = onFinished; + + Logging.Debug($"[DecorationDraggableInstance] InitializeAsPlaced - Show outline callback is null: {_onShowOutlineCallback == null}"); + Logging.Debug($"[DecorationDraggableInstance] InitializeAsPlaced - Hide outline callback is null: {_onHideOutlineCallback == null}"); + Logging.Debug($"[DecorationDraggableInstance] InitializeAsPlaced - Finished callback is null: {_onFinishedCallback == null}"); + // Set sprite if (decorationImage != null && data != null && data.DecorationSprite != null) { @@ -101,7 +139,7 @@ namespace Minigames.StatueDressup.DragDrop _rectTransform.sizeDelta = data.AuthoredSize; } - // Make non-interactive for placed state (can be made interactive later if needed) + // Make interactive so it can be picked up if (canvasGroup != null) { canvasGroup.blocksRaycasts = true; @@ -250,8 +288,11 @@ namespace Minigames.StatueDressup.DragDrop /// /// Allow picking up from statue for repositioning /// - public void StartDragFromStatue(Vector3 pointerPosition) + public void StartDragFromStatue(PointerEventData eventData) { + Logging.Debug($"[DecorationDraggableInstance] StartDragFromStatue called for: {_decorationData?.DecorationName}"); + Logging.Debug($"[DecorationDraggableInstance] Show outline callback is null: {_onShowOutlineCallback == null}"); + if (_controller != null) { _controller.UnregisterDecoration(this); @@ -260,17 +301,87 @@ namespace Minigames.StatueDressup.DragDrop _isPlacedOnStatue = false; _isDragging = true; - // Calculate offset + // Show statue outline when picking up from statue + if (_onShowOutlineCallback != null) + { + Logging.Debug("[DecorationDraggableInstance] Invoking show outline callback"); + _onShowOutlineCallback.Invoke(); + } + else + { + Logging.Warning("[DecorationDraggableInstance] Show outline callback is null - cannot show outline!"); + } + + // Reparent to canvas for dragging (so coordinates work correctly) + if (_canvasParent != null && transform.parent != _canvasParent) + { + // Store world position before reparenting + Vector3 worldPos = transform.position; + transform.SetParent(_canvasParent, false); + transform.position = worldPos; // Restore world position + } + + // Calculate offset using proper camera RectTransformUtility.ScreenPointToLocalPointInRectangle( _canvas.transform as RectTransform, - pointerPosition, - null, + eventData.position, + eventData.pressEventCamera, out Vector2 localPoint); _dragOffset = _rectTransform.localPosition - (Vector3)localPoint; Logging.Debug($"[DecorationDraggableInstance] Started drag from statue: {_decorationData?.DecorationName}"); } + + #region Pointer Event Handlers + + /// + /// Handle pointer click - only when placed on statue + /// + public void OnPointerClick(PointerEventData eventData) + { + // Only handle clicks when placed on statue and not currently dragging + if (!_isPlacedOnStatue || _dragStarted) return; + + Logging.Debug($"[DecorationDraggableInstance] Decoration tapped: {_decorationData?.DecorationName}"); + + // Future: Open detail view, play sound effect, show info popup, etc. + } + + /// + /// Handle drag start - only when placed on statue + /// + public void OnBeginDrag(PointerEventData eventData) + { + // Only handle drag from statue if already placed + if (!_isPlacedOnStatue) return; + + _dragStarted = true; + StartDragFromStatue(eventData); + } + + /// + /// Handle drag continuation + /// + public void OnDrag(PointerEventData eventData) + { + if (!_isDragging) return; + + ContinueDrag(eventData); + } + + /// + /// Handle drag end + /// + public void OnEndDrag(PointerEventData eventData) + { + if (!_isDragging) return; + + _dragStarted = false; + EndDrag(eventData); + } + + #endregion } } diff --git a/Assets/Scripts/UI/PlayerHudManager.cs b/Assets/Scripts/UI/PlayerHudManager.cs index 00eba7a4..1d3edfae 100644 --- a/Assets/Scripts/UI/PlayerHudManager.cs +++ b/Assets/Scripts/UI/PlayerHudManager.cs @@ -103,7 +103,8 @@ namespace UI public GameObject eagleEye; public GameObject ramaSjangButton; public GameObject scrabBookButton; - + public GameObject pauseButton; + [HideInInspector] public Image cinematicSprites; [HideInInspector] public Image cinematicBackgroundSprites; [HideInInspector] public GameObject currentCinematicPlayer; @@ -235,9 +236,12 @@ namespace UI case "Quarry": currentUIMode = UIMode.Puzzle; break; - case "DivingForPictures" or "CardQualityControl" or "BirdPoop" or "StatueDecoration": + case "DivingForPictures" or "CardQualityControl" or "BirdPoop": currentUIMode = UIMode.Minigame; break; + case "StatueDecoration": + currentUIMode = UIMode.HideAll; + break; } ShowAllHud(); @@ -336,6 +340,10 @@ namespace UI } break; case UIMode.HideAll: + eagleEye.SetActive(false); + ramaSjangButton.SetActive(false); + scrabBookButton.SetActive(false); + pauseButton.SetActive(false); break; } }