Compare commits
2 Commits
michal_dum
...
f0abc4760b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0abc4760b | ||
|
|
ff28bd23cb |
@@ -63,18 +63,6 @@ MonoBehaviour:
|
||||
m_SerializedLabels:
|
||||
- BlokkemonCard
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 4f4ec75013bc276429c2f4fa52d165e0
|
||||
m_Address: Assets/Data/Cards/Card_KalkUlation 3.asset
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels:
|
||||
- BlokkemonCard
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 53996921ed2094948aa317efe4ca6630
|
||||
m_Address: Assets/Data/Cards/Card_MormorMarmor 3.asset
|
||||
m_ReadOnly: 0
|
||||
m_SerializedLabels:
|
||||
- BlokkemonCard
|
||||
FlaggedDuringContentUpdateRestriction: 0
|
||||
- m_GUID: 73d54071304571647b3238a799d9781f
|
||||
m_Address: Assets/Data/Cards/Card_New Card.asset
|
||||
m_ReadOnly: 0
|
||||
|
||||
95
Assets/Editor/Tools/AutoClearSavesOnPlay.cs
Normal file
95
Assets/Editor/Tools/AutoClearSavesOnPlay.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using AppleHills.Core.Settings;
|
||||
|
||||
namespace Editor.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// Editor script that automatically clears saves before entering play mode
|
||||
/// if the autoClearSaves setting is enabled in DebugSettings
|
||||
/// </summary>
|
||||
[InitializeOnLoad]
|
||||
public static class AutoClearSavesOnPlay
|
||||
{
|
||||
static AutoClearSavesOnPlay()
|
||||
{
|
||||
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||
}
|
||||
|
||||
private static void OnPlayModeStateChanged(PlayModeStateChange state)
|
||||
{
|
||||
// Only act when entering play mode (before the scene starts playing)
|
||||
if (state != PlayModeStateChange.ExitingEditMode)
|
||||
return;
|
||||
|
||||
// Try to load the debug settings
|
||||
DebugSettings debugSettings = LoadDebugSettings();
|
||||
|
||||
if (debugSettings == null)
|
||||
{
|
||||
Debug.LogWarning("[AutoClearSaves] Could not find DebugSettings asset. Auto-clear saves disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if auto-clear is enabled
|
||||
if (!debugSettings.AutoClearSaves)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute the clear saves logic
|
||||
ClearSavesFolder();
|
||||
}
|
||||
|
||||
private static DebugSettings LoadDebugSettings()
|
||||
{
|
||||
// Try to find the DebugSettings asset in the project
|
||||
string[] guids = AssetDatabase.FindAssets("t:DebugSettings");
|
||||
|
||||
if (guids.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Load the first found DebugSettings asset
|
||||
string path = AssetDatabase.GUIDToAssetPath(guids[0]);
|
||||
return AssetDatabase.LoadAssetAtPath<DebugSettings>(path);
|
||||
}
|
||||
|
||||
private static void ClearSavesFolder()
|
||||
{
|
||||
// Construct the save folder path (matches SaveLoadManager.DefaultSaveFolder)
|
||||
string saveFolder = Path.Combine(Application.persistentDataPath, "GameSaves");
|
||||
|
||||
if (!Directory.Exists(saveFolder))
|
||||
{
|
||||
Debug.Log("[AutoClearSaves] Save folder does not exist, nothing to clear.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Delete all files in the save folder
|
||||
string[] files = Directory.GetFiles(saveFolder);
|
||||
int deletedCount = 0;
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
File.Delete(file);
|
||||
deletedCount++;
|
||||
}
|
||||
|
||||
if (deletedCount > 0)
|
||||
{
|
||||
Debug.Log($"[AutoClearSaves] Automatically deleted {deletedCount} save file(s) before entering play mode");
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogError($"[AutoClearSaves] Failed to auto-clear saves: {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3
Assets/Editor/Tools/AutoClearSavesOnPlay.cs.meta
Normal file
3
Assets/Editor/Tools/AutoClearSavesOnPlay.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3ba01f7bb704c17bc4f22fd726f7fee
|
||||
timeCreated: 1763974355
|
||||
@@ -802,7 +802,7 @@ MonoBehaviour:
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 0}
|
||||
m_TargetGraphic: {fileID: 4189849640380816173}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
@@ -1459,6 +1459,10 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 2474710976069581060}
|
||||
m_Modifications:
|
||||
- target: {fileID: 823686888810001266, guid: 428a0feafda9d6d4e87ecf43ad41dc20, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5445689290567702089, guid: 428a0feafda9d6d4e87ecf43ad41dc20, type: 3}
|
||||
propertyPath: m_Pivot.x
|
||||
value: 1
|
||||
|
||||
@@ -226,7 +226,7 @@ GameObject:
|
||||
- component: {fileID: 2741639361616064442}
|
||||
- component: {fileID: 4903273501345439385}
|
||||
- component: {fileID: 1054459649399154791}
|
||||
- component: {fileID: 7319925080429004531}
|
||||
- component: {fileID: 61210891595976786}
|
||||
m_Layer: 10
|
||||
m_Name: Hidden
|
||||
m_TagString: Untagged
|
||||
@@ -451,7 +451,7 @@ MonoBehaviour:
|
||||
audioSource: {fileID: 0}
|
||||
clipPriority: 0
|
||||
sourcePriority: 1
|
||||
--- !u!114 &7319925080429004531
|
||||
--- !u!114 &61210891595976786
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@@ -460,9 +460,9 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 1011363502278351410}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 95e46aacea5b42888ee7881894193c11, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 1fa347bfb45f473f8639842928f8cfa1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: AppleHillsScripts::Core.SaveLoad.AppleState
|
||||
m_EditorClassIdentifier: AppleHillsScripts::StateMachines.Quarry.AnneLise.HiddenState
|
||||
--- !u!1 &1674229500073894281
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -830,6 +830,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 603ecc4a6ab6bb84c8cb9773fa310b69, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: '::'
|
||||
dialogueCanvas: {fileID: 7042752134100908030}
|
||||
--- !u!114 &1193493154550576580
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1740,3 +1741,8 @@ RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 3484825090253933040, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3}
|
||||
m_PrefabInstance: {fileID: 4289827099693551234}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &7042752134100908030 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 6499933157207406972, guid: a8b0a1c6cf21352439dc24d3b03182db, type: 3}
|
||||
m_PrefabInstance: {fileID: 4289827099693551234}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -450296,7 +450296,7 @@ GameObject:
|
||||
- component: {fileID: 1137411215}
|
||||
m_Layer: 0
|
||||
m_Name: CinemachineCamera
|
||||
m_TagString: Untagged
|
||||
m_TagString: MainCinemachineCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace AppleHills.Core.Settings
|
||||
[Header("Save Load Options")]
|
||||
[Tooltip("Should use save laod system?")]
|
||||
[SerializeField] public bool useSaveLoadSystem = true;
|
||||
[Tooltip("Automatically clear all saves before entering play mode in editor")]
|
||||
[SerializeField] public bool autoClearSaves = false;
|
||||
|
||||
[Header("Logging Options")]
|
||||
[Tooltip("Logging level for bootstrap services")]
|
||||
@@ -49,6 +51,7 @@ namespace AppleHills.Core.Settings
|
||||
// Property getters
|
||||
public bool ShowDebugUiMessages => showDebugUiMessages;
|
||||
public bool PauseTimeOnPauseGame => pauseTimeOnPauseGame;
|
||||
public bool AutoClearSaves => autoClearSaves;
|
||||
|
||||
public override void OnValidate()
|
||||
{
|
||||
|
||||
@@ -1,84 +1,131 @@
|
||||
using System.Collections;
|
||||
using Unity.Cinemachine;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class EagleEyeBehaviour : MonoBehaviour
|
||||
namespace DamianExperiments
|
||||
{
|
||||
[SerializeField] private CinemachineCamera virtualCamera;
|
||||
[SerializeField] private CinemachineConfiner2D confiner2D;
|
||||
[SerializeField] private float zoomOutOrthoSize = 30f;
|
||||
[SerializeField] private float normalOrthoSize = 15f;
|
||||
private float currentOrthoSize;
|
||||
[SerializeField] private float transitionDuration = 0.5f; // Duration of the transition
|
||||
[SerializeField] private float eagleEyeDuration = 3f; // Duration to stay zoomed out
|
||||
[SerializeField] private bool disablePlayerInputDuringEagleEye = true; // Gate input disable
|
||||
[SerializeField] private UnityEngine.UI.Button eagleEyeButton; // Reference to the UI button
|
||||
|
||||
private Coroutine zoomCoroutine;
|
||||
|
||||
public void ActivateEagleEye()
|
||||
public class EagleEyeBehaviour : MonoBehaviour
|
||||
{
|
||||
//Assigns the Virtual Camera and Confiner if not already assigned
|
||||
if (virtualCamera == null)
|
||||
{
|
||||
virtualCamera = FindAnyObjectByType<CinemachineCamera>();
|
||||
}
|
||||
if (confiner2D == null)
|
||||
{
|
||||
confiner2D = virtualCamera.GetComponent<CinemachineConfiner2D>();
|
||||
}
|
||||
// Serialized backing fields allow manual assignment in the inspector
|
||||
private GameObject _cinecameraObject;
|
||||
private CinemachineCamera _virtualCamera;
|
||||
private CinemachineConfiner2D _confiner2D;
|
||||
|
||||
// Implementation for activating eagle eye behaviour
|
||||
if (disablePlayerInputDuringEagleEye)
|
||||
// Lazy-fetched properties: if null, try to find the GameObject tagged "MainCinemachineCamera"
|
||||
private CinemachineCamera VirtualCamera
|
||||
{
|
||||
currentOrthoSize = virtualCamera.Lens.OrthographicSize;
|
||||
}
|
||||
if (eagleEyeButton != null)
|
||||
{
|
||||
eagleEyeButton.interactable = false;
|
||||
}
|
||||
if (zoomCoroutine != null) StopCoroutine(zoomCoroutine);
|
||||
zoomCoroutine = StartCoroutine(EagleEyeSequence());
|
||||
}
|
||||
|
||||
private IEnumerator EagleEyeSequence()
|
||||
{
|
||||
if (disablePlayerInputDuringEagleEye)
|
||||
{
|
||||
Core.GameManager.Instance.RequestPause(this); // Disable player input
|
||||
}
|
||||
yield return StartCoroutine(SmoothOrthoSize(virtualCamera, zoomOutOrthoSize, transitionDuration));
|
||||
yield return new WaitForSeconds(eagleEyeDuration);
|
||||
float zoomInTarget = disablePlayerInputDuringEagleEye ? currentOrthoSize : normalOrthoSize;
|
||||
yield return StartCoroutine(SmoothOrthoSize(virtualCamera, zoomInTarget, transitionDuration));
|
||||
if (disablePlayerInputDuringEagleEye)
|
||||
{
|
||||
Core.GameManager.Instance.ReleasePause(this); // Re-enable player input
|
||||
}
|
||||
if (eagleEyeButton != null)
|
||||
{
|
||||
eagleEyeButton.interactable = true;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator SmoothOrthoSize(CinemachineCamera cam, float targetSize, float duration)
|
||||
{
|
||||
float startSize = cam.Lens.OrthographicSize;
|
||||
float elapsed = 0f;
|
||||
while (elapsed < duration)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
cam.Lens.OrthographicSize = Mathf.Lerp(startSize, targetSize, elapsed / duration);
|
||||
if (confiner2D != null)
|
||||
get
|
||||
{
|
||||
confiner2D.InvalidateBoundingShapeCache();
|
||||
if (_virtualCamera == null)
|
||||
{
|
||||
if (_cinecameraObject == null)
|
||||
_cinecameraObject = GameObject.FindWithTag("MainCinemachineCamera");
|
||||
if (_cinecameraObject != null)
|
||||
{
|
||||
_virtualCamera = _cinecameraObject.GetComponent<CinemachineCamera>();
|
||||
|
||||
if (_virtualCamera == null)
|
||||
Debug.LogWarning("EagleEyeBehaviour: Found object with tag 'MainCinemachineCamera' " +
|
||||
"but couldn't find a CinemachineCamera component.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("EagleEyeBehaviour: No GameObject found with tag 'MainCinemachineCamera'.");
|
||||
}
|
||||
}
|
||||
|
||||
return _virtualCamera;
|
||||
}
|
||||
yield return null;
|
||||
set => _virtualCamera = value;
|
||||
}
|
||||
cam.Lens.OrthographicSize = targetSize;
|
||||
if (confiner2D != null)
|
||||
|
||||
private CinemachineConfiner2D Confiner2D
|
||||
{
|
||||
confiner2D.InvalidateBoundingShapeCache();
|
||||
get
|
||||
{
|
||||
if (_confiner2D == null)
|
||||
{
|
||||
// If a virtual camera exists, try to pull the confiner from it
|
||||
if (VirtualCamera != null)
|
||||
{
|
||||
_confiner2D = VirtualCamera.GetComponent<CinemachineConfiner2D>();
|
||||
}
|
||||
|
||||
if (_confiner2D == null)
|
||||
{
|
||||
Debug.LogWarning("EagleEyeBehaviour: CinemachineConfiner2D not found on the MainCinemachineCamera object.");
|
||||
}
|
||||
}
|
||||
|
||||
return _confiner2D;
|
||||
}
|
||||
set => _confiner2D = value;
|
||||
}
|
||||
|
||||
[SerializeField] private float zoomOutOrthoSize = 30f;
|
||||
[SerializeField] private float normalOrthoSize = 15f;
|
||||
[SerializeField] private float transitionDuration = 0.5f; // Duration of the transition
|
||||
[SerializeField] private float eagleEyeDuration = 3f; // Duration to stay zoomed out
|
||||
[SerializeField] private UnityEngine.UI.Button eagleEyeButton; // Reference to the UI button
|
||||
|
||||
private Coroutine _zoomCoroutine;
|
||||
private Coroutine _smoothOrthoCoroutine;
|
||||
private float _currentOrthoSize;
|
||||
|
||||
public void ResetEagleEye()
|
||||
{
|
||||
if (_zoomCoroutine != null)
|
||||
StopCoroutine(_zoomCoroutine);
|
||||
if (_smoothOrthoCoroutine != null)
|
||||
StopCoroutine(_smoothOrthoCoroutine);
|
||||
if (eagleEyeButton != null)
|
||||
eagleEyeButton.interactable = true;
|
||||
}
|
||||
|
||||
|
||||
public void ActivateEagleEye()
|
||||
{
|
||||
if (eagleEyeButton != null)
|
||||
{
|
||||
eagleEyeButton.interactable = false;
|
||||
}
|
||||
if (_zoomCoroutine != null) StopCoroutine(_zoomCoroutine);
|
||||
_zoomCoroutine = StartCoroutine(EagleEyeSequence());
|
||||
}
|
||||
|
||||
private IEnumerator EagleEyeSequence()
|
||||
{
|
||||
_smoothOrthoCoroutine = StartCoroutine(SmoothOrthoSize(VirtualCamera, zoomOutOrthoSize, transitionDuration));
|
||||
yield return _smoothOrthoCoroutine;
|
||||
yield return new WaitForSeconds(eagleEyeDuration);
|
||||
float zoomInTarget = normalOrthoSize;
|
||||
_smoothOrthoCoroutine = StartCoroutine(SmoothOrthoSize(VirtualCamera, zoomInTarget, transitionDuration));;
|
||||
yield return _smoothOrthoCoroutine;
|
||||
if (eagleEyeButton != null)
|
||||
{
|
||||
eagleEyeButton.interactable = true;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator SmoothOrthoSize(CinemachineCamera cam, float targetSize, float duration)
|
||||
{
|
||||
float startSize = cam.Lens.OrthographicSize;
|
||||
float elapsed = 0f;
|
||||
while (elapsed < duration)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
cam.Lens.OrthographicSize = Mathf.Lerp(startSize, targetSize, elapsed / duration);
|
||||
if (Confiner2D != null)
|
||||
{
|
||||
Confiner2D.InvalidateBoundingShapeCache();
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
cam.Lens.OrthographicSize = targetSize;
|
||||
if (Confiner2D != null)
|
||||
{
|
||||
Confiner2D.InvalidateBoundingShapeCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class cameraSwitcherNailBird : MonoBehaviour
|
||||
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
if (other.CompareTag("Player") && gameObject.activeInHierarchy)
|
||||
{
|
||||
playerInsideCount--;
|
||||
if (playerInsideCount == 0 && virtualCamera != null)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5596931aef9448a3b369f7917af07797
|
||||
timeCreated: 1763745490
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34525368248b48e0b271537891123818
|
||||
timeCreated: 1763745579
|
||||
@@ -1,247 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Core;
|
||||
using Minigames.StatueDressup.Data;
|
||||
using Minigames.StatueDressup.DragDrop;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Minigames.StatueDressup.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages the side menu with decoration items and pagination
|
||||
/// </summary>
|
||||
public class DecorationMenuController : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private DecorationItem itemPrefab;
|
||||
[SerializeField] private Transform itemsContainer;
|
||||
[SerializeField] private Button nextPageButton;
|
||||
[SerializeField] private Button previousPageButton;
|
||||
|
||||
[Header("Configuration")]
|
||||
[SerializeField] private List<DecorationData> allDecorations = new List<DecorationData>();
|
||||
[SerializeField] private int itemsPerPage = 10; // 2 columns x 5 rows
|
||||
|
||||
[Header("Layout")]
|
||||
[SerializeField] private GridLayoutGroup gridLayout;
|
||||
|
||||
private int _currentPage = 0;
|
||||
private int _totalPages = 0;
|
||||
private List<DecorationItem> _spawnedItems = new List<DecorationItem>();
|
||||
private Dictionary<DecorationItem, DecorationData> _itemDataMapping = new Dictionary<DecorationItem, DecorationData>();
|
||||
|
||||
// Properties
|
||||
public int CurrentPage => _currentPage;
|
||||
public int TotalPages => _totalPages;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
Logging.Debug($"[DecorationMenuController] Initializing with {allDecorations.Count} decorations");
|
||||
|
||||
// Calculate total pages
|
||||
_totalPages = Mathf.CeilToInt((float)allDecorations.Count / itemsPerPage);
|
||||
Logging.Debug($"[DecorationMenuController] Total pages: {_totalPages}");
|
||||
|
||||
// Setup buttons
|
||||
if (nextPageButton != null)
|
||||
{
|
||||
nextPageButton.onClick.AddListener(OnNextPage);
|
||||
}
|
||||
|
||||
if (previousPageButton != null)
|
||||
{
|
||||
previousPageButton.onClick.AddListener(OnPreviousPage);
|
||||
}
|
||||
|
||||
// Subscribe to drag events for all items
|
||||
// (will be handled per-item when spawned)
|
||||
|
||||
// Populate first page
|
||||
PopulateCurrentPage();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populate the current page with decoration items
|
||||
/// </summary>
|
||||
private void PopulateCurrentPage()
|
||||
{
|
||||
Logging.Debug($"[DecorationMenuController] Populating page {_currentPage + 1}/{_totalPages}");
|
||||
|
||||
// Clear existing items
|
||||
ClearItems();
|
||||
|
||||
// Calculate range for current page
|
||||
int startIndex = _currentPage * itemsPerPage;
|
||||
int endIndex = Mathf.Min(startIndex + itemsPerPage, allDecorations.Count);
|
||||
|
||||
Logging.Debug($"[DecorationMenuController] Spawning items {startIndex} to {endIndex - 1}");
|
||||
|
||||
// Spawn items for this page
|
||||
for (int i = startIndex; i < endIndex; i++)
|
||||
{
|
||||
SpawnDecorationItem(allDecorations[i]);
|
||||
}
|
||||
|
||||
// Update button states
|
||||
UpdateNavigationButtons();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawn a decoration item in the menu
|
||||
/// </summary>
|
||||
private void SpawnDecorationItem(DecorationData data)
|
||||
{
|
||||
if (itemPrefab == null || itemsContainer == null)
|
||||
{
|
||||
Logging.Warning("[DecorationMenuController] Missing prefab or container");
|
||||
return;
|
||||
}
|
||||
|
||||
DecorationItem item = Instantiate(itemPrefab, itemsContainer);
|
||||
item.SetDecorationData(data);
|
||||
|
||||
// Store original position for return animation
|
||||
if (item.RectTransform != null)
|
||||
{
|
||||
// Force layout update to get correct position
|
||||
Canvas.ForceUpdateCanvases();
|
||||
item.SetOriginalMenuPosition(item.RectTransform.anchoredPosition);
|
||||
}
|
||||
|
||||
// Subscribe to drag events
|
||||
item.OnDragStarted += HandleItemPickedUp;
|
||||
item.OnDragEnded += HandleItemDropped;
|
||||
|
||||
_spawnedItems.Add(item);
|
||||
_itemDataMapping[item] = data;
|
||||
|
||||
Logging.Debug($"[DecorationMenuController] Spawned: {data.DecorationName} at position {item.RectTransform?.anchoredPosition}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle item picked up from menu
|
||||
/// </summary>
|
||||
private void HandleItemPickedUp(DraggableObject draggable)
|
||||
{
|
||||
if (draggable is DecorationItem item && _itemDataMapping.ContainsKey(item))
|
||||
{
|
||||
Logging.Debug($"[DecorationMenuController] Item picked up: {item.Data?.DecorationName}");
|
||||
|
||||
// Spawn replacement in menu slot
|
||||
// This ensures menu always shows available items
|
||||
DecorationData data = _itemDataMapping[item];
|
||||
// We'll spawn replacement only if item is actually placed, not on pickup
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle item dropped (either placed on statue or returned to menu)
|
||||
/// </summary>
|
||||
private void HandleItemDropped(DraggableObject draggable)
|
||||
{
|
||||
if (draggable is DecorationItem item && _itemDataMapping.ContainsKey(item))
|
||||
{
|
||||
Logging.Debug($"[DecorationMenuController] Item dropped: {item.Data?.DecorationName}, slot={item.CurrentSlot?.name}");
|
||||
|
||||
// If item was placed on statue, spawn replacement in menu
|
||||
if (item.CurrentSlot != null && !item.IsInMenu)
|
||||
{
|
||||
DecorationData data = _itemDataMapping[item];
|
||||
|
||||
// Remove original from tracking
|
||||
_spawnedItems.Remove(item);
|
||||
_itemDataMapping.Remove(item);
|
||||
|
||||
// Spawn replacement
|
||||
SpawnDecorationItem(data);
|
||||
|
||||
Logging.Debug($"[DecorationMenuController] Spawned replacement for: {data.DecorationName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear all spawned items
|
||||
/// </summary>
|
||||
private void ClearItems()
|
||||
{
|
||||
foreach (var item in _spawnedItems)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
item.OnDragStarted -= HandleItemPickedUp;
|
||||
item.OnDragEnded -= HandleItemDropped;
|
||||
Destroy(item.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
_spawnedItems.Clear();
|
||||
_itemDataMapping.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Navigate to next page
|
||||
/// </summary>
|
||||
private void OnNextPage()
|
||||
{
|
||||
if (_currentPage < _totalPages - 1)
|
||||
{
|
||||
_currentPage++;
|
||||
PopulateCurrentPage();
|
||||
Logging.Debug($"[DecorationMenuController] Next page: {_currentPage + 1}/{_totalPages}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Navigate to previous page
|
||||
/// </summary>
|
||||
private void OnPreviousPage()
|
||||
{
|
||||
if (_currentPage > 0)
|
||||
{
|
||||
_currentPage--;
|
||||
PopulateCurrentPage();
|
||||
Logging.Debug($"[DecorationMenuController] Previous page: {_currentPage + 1}/{_totalPages}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update navigation button interactability
|
||||
/// </summary>
|
||||
private void UpdateNavigationButtons()
|
||||
{
|
||||
if (previousPageButton != null)
|
||||
{
|
||||
previousPageButton.interactable = _currentPage > 0;
|
||||
}
|
||||
|
||||
if (nextPageButton != null)
|
||||
{
|
||||
nextPageButton.interactable = _currentPage < _totalPages - 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
// Cleanup button listeners
|
||||
if (nextPageButton != null)
|
||||
{
|
||||
nextPageButton.onClick.RemoveListener(OnNextPage);
|
||||
}
|
||||
|
||||
if (previousPageButton != null)
|
||||
{
|
||||
previousPageButton.onClick.RemoveListener(OnPreviousPage);
|
||||
}
|
||||
|
||||
// Cleanup item listeners
|
||||
ClearItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acbd542762b44e719326dff6c3a69e6e
|
||||
timeCreated: 1763745579
|
||||
@@ -1,267 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Core;
|
||||
using Minigames.StatueDressup.DragDrop;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Minigames.StatueDressup.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Main controller for the Mr. Cement statue decoration minigame
|
||||
/// </summary>
|
||||
public class StatueDecorationController : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private StatueDecorationSlot[] statueSlots;
|
||||
[SerializeField] private DecorationMenuController menuController;
|
||||
[SerializeField] private Button takePhotoButton;
|
||||
[SerializeField] private GameObject statue;
|
||||
|
||||
[Header("UI Elements to Hide for Photo")]
|
||||
[SerializeField] private GameObject[] uiElementsToHideForPhoto;
|
||||
|
||||
[Header("Photo Settings")]
|
||||
[SerializeField] private RectTransform photoArea; // Area to capture
|
||||
[SerializeField] private string photoSaveKey = "MrCementStatuePhoto";
|
||||
|
||||
private Dictionary<StatueDecorationSlot, DecorationItem> _placedDecorations = new Dictionary<StatueDecorationSlot, DecorationItem>();
|
||||
private bool _minigameCompleted = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
Logging.Debug("[StatueDecorationController] Initializing minigame");
|
||||
|
||||
// Setup photo button
|
||||
if (takePhotoButton != null)
|
||||
{
|
||||
takePhotoButton.onClick.AddListener(OnTakePhoto);
|
||||
}
|
||||
|
||||
// Subscribe to slot occupation events
|
||||
foreach (var slot in statueSlots)
|
||||
{
|
||||
if (slot != null)
|
||||
{
|
||||
slot.OnOccupied += HandleDecorationPlaced;
|
||||
}
|
||||
}
|
||||
|
||||
// Load saved state if exists
|
||||
LoadStatueState();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle decoration placed in slot
|
||||
/// </summary>
|
||||
private void HandleDecorationPlaced(DraggableObject draggable)
|
||||
{
|
||||
if (draggable is DecorationItem decoration)
|
||||
{
|
||||
var slot = decoration.CurrentSlot as StatueDecorationSlot;
|
||||
if (slot != null)
|
||||
{
|
||||
_placedDecorations[slot] = decoration;
|
||||
Logging.Debug($"[StatueDecorationController] Decoration placed: {decoration.Data?.DecorationName} in slot {slot.name}");
|
||||
|
||||
// Auto-save state
|
||||
SaveStatueState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Take photo of decorated statue
|
||||
/// </summary>
|
||||
private void OnTakePhoto()
|
||||
{
|
||||
if (_minigameCompleted)
|
||||
{
|
||||
Logging.Debug("[StatueDecorationController] Minigame already completed");
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.Debug("[StatueDecorationController] Taking photo of statue");
|
||||
|
||||
// Hide UI elements
|
||||
HideUIForPhoto(true);
|
||||
|
||||
// Wait a frame for UI to hide, then capture
|
||||
StartCoroutine(CapturePhotoCoroutine());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Capture photo after UI is hidden
|
||||
/// </summary>
|
||||
private System.Collections.IEnumerator CapturePhotoCoroutine()
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
// Capture the photo area
|
||||
Texture2D photo = CaptureScreenshotArea();
|
||||
|
||||
if (photo != null)
|
||||
{
|
||||
// Save photo to album
|
||||
SavePhotoToAlbum(photo);
|
||||
|
||||
// Award cards
|
||||
AwardCards();
|
||||
|
||||
// Update town icon
|
||||
UpdateTownIcon(photo);
|
||||
|
||||
// Show completion feedback
|
||||
ShowCompletionFeedback();
|
||||
|
||||
_minigameCompleted = true;
|
||||
}
|
||||
|
||||
// Restore UI
|
||||
HideUIForPhoto(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Capture screenshot of specific area
|
||||
/// </summary>
|
||||
private Texture2D CaptureScreenshotArea()
|
||||
{
|
||||
if (photoArea == null)
|
||||
{
|
||||
Logging.Warning("[StatueDecorationController] No photo area specified, capturing full screen");
|
||||
|
||||
// Capture full screen
|
||||
Texture2D screenshot = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
|
||||
screenshot.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
|
||||
screenshot.Apply();
|
||||
return screenshot;
|
||||
}
|
||||
|
||||
// Get world corners of the rect
|
||||
Vector3[] corners = new Vector3[4];
|
||||
photoArea.GetWorldCorners(corners);
|
||||
|
||||
// Convert to screen space
|
||||
Vector2 min = RectTransformUtility.WorldToScreenPoint(Camera.main, corners[0]);
|
||||
Vector2 max = RectTransformUtility.WorldToScreenPoint(Camera.main, corners[2]);
|
||||
|
||||
int width = (int)(max.x - min.x);
|
||||
int height = (int)(max.y - min.y);
|
||||
|
||||
Logging.Debug($"[StatueDecorationController] Capturing area: {width}x{height} at ({min.x}, {min.y})");
|
||||
|
||||
// Capture the specified area
|
||||
Texture2D screenshot = new Texture2D(width, height, TextureFormat.RGB24, false);
|
||||
screenshot.ReadPixels(new Rect(min.x, min.y, width, height), 0, 0);
|
||||
screenshot.Apply();
|
||||
|
||||
return screenshot;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save photo to card album
|
||||
/// </summary>
|
||||
private void SavePhotoToAlbum(Texture2D photo)
|
||||
{
|
||||
// TODO: Integrate with existing album save system
|
||||
// For now, save to PlayerPrefs as base64
|
||||
byte[] bytes = photo.EncodeToPNG();
|
||||
string base64 = System.Convert.ToBase64String(bytes);
|
||||
PlayerPrefs.SetString(photoSaveKey, base64);
|
||||
PlayerPrefs.Save();
|
||||
|
||||
Logging.Debug("[StatueDecorationController] Photo saved to album");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Award Blokkemon cards to player
|
||||
/// </summary>
|
||||
private void AwardCards()
|
||||
{
|
||||
// TODO: Integrate with MinigameBoosterGiver
|
||||
// MinigameBoosterGiver.GiveBooster();
|
||||
|
||||
Logging.Debug("[StatueDecorationController] Cards awarded (TODO: implement)");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update town menu icon with decorated statue
|
||||
/// </summary>
|
||||
private void UpdateTownIcon(Texture2D photo)
|
||||
{
|
||||
// TODO: Integrate with town system
|
||||
// TownIconUpdater.SetStatueIcon(photo);
|
||||
|
||||
Logging.Debug("[StatueDecorationController] Town icon updated (TODO: implement)");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show completion feedback to player
|
||||
/// </summary>
|
||||
private void ShowCompletionFeedback()
|
||||
{
|
||||
// TODO: Show success message/animation
|
||||
DebugUIMessage.Show("Photo captured! Mr. Cement looks amazing!", Color.green);
|
||||
Logging.Debug("[StatueDecorationController] Minigame completed!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hide/show UI elements for photo
|
||||
/// </summary>
|
||||
private void HideUIForPhoto(bool hide)
|
||||
{
|
||||
foreach (var element in uiElementsToHideForPhoto)
|
||||
{
|
||||
if (element != null)
|
||||
{
|
||||
element.SetActive(!hide);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save current statue decoration state
|
||||
/// </summary>
|
||||
private void SaveStatueState()
|
||||
{
|
||||
// TODO: Implement save system
|
||||
// Save slot ID -> decoration ID mapping
|
||||
|
||||
Logging.Debug("[StatueDecorationController] State saved (TODO: implement persistence)");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load saved statue decoration state
|
||||
/// </summary>
|
||||
private void LoadStatueState()
|
||||
{
|
||||
// TODO: Implement load system
|
||||
// Restore decorations to slots
|
||||
|
||||
Logging.Debug("[StatueDecorationController] State loaded (TODO: implement persistence)");
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
// Cleanup button listener
|
||||
if (takePhotoButton != null)
|
||||
{
|
||||
takePhotoButton.onClick.RemoveListener(OnTakePhoto);
|
||||
}
|
||||
|
||||
// Cleanup slot listeners
|
||||
foreach (var slot in statueSlots)
|
||||
{
|
||||
if (slot != null)
|
||||
{
|
||||
slot.OnOccupied -= HandleDecorationPlaced;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19e312ceaffa40ae90ac87b8209319cb
|
||||
timeCreated: 1763745610
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6e7dfb0a39c441fb8ac888a5e58a91e
|
||||
timeCreated: 1763745500
|
||||
@@ -1,47 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Minigames.StatueDressup.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// ScriptableObject data definition for statue decorations
|
||||
/// </summary>
|
||||
[CreateAssetMenu(fileName = "DecorationData", menuName = "AppleHills/Minigames/Decoration Data", order = 1)]
|
||||
public class DecorationData : ScriptableObject
|
||||
{
|
||||
[Header("Identity")]
|
||||
[SerializeField] private string decorationId;
|
||||
[SerializeField] private string decorationName;
|
||||
|
||||
[Header("Visual")]
|
||||
[SerializeField] private Sprite decorationSprite;
|
||||
|
||||
[Header("Size Configuration")]
|
||||
[Tooltip("Full size when placed on statue (actual sprite size)")]
|
||||
[SerializeField] private Vector2 authoredSize = new Vector2(128f, 128f);
|
||||
|
||||
[Tooltip("Small size in menu icon")]
|
||||
[SerializeField] private Vector2 iconSize = new Vector2(64f, 64f);
|
||||
|
||||
[Header("Progression (Optional)")]
|
||||
[SerializeField] private bool isUnlocked = true;
|
||||
|
||||
// Properties
|
||||
public string DecorationId => decorationId;
|
||||
public string DecorationName => decorationName;
|
||||
public Sprite DecorationSprite => decorationSprite;
|
||||
public DecorationCategory Category => category;
|
||||
public Vector2 AuthoredSize => authoredSize;
|
||||
public Vector2 IconSize => iconSize;
|
||||
public bool IsUnlocked => isUnlocked;
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
// Auto-generate ID from name if empty
|
||||
if (string.IsNullOrEmpty(decorationId) && !string.IsNullOrEmpty(decorationName))
|
||||
{
|
||||
decorationId = decorationName.Replace(" ", "_").ToLower();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74c6ae9aa803480c8fb918dd58cfb809
|
||||
timeCreated: 1763745511
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c3389a935534b7b86800516ffa42acb
|
||||
timeCreated: 1763745531
|
||||
@@ -1,146 +0,0 @@
|
||||
using Core;
|
||||
using Minigames.StatueDressup.Data;
|
||||
using Minigames.StatueDressup.Utils;
|
||||
using UI.DragAndDrop.Core;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Minigames.StatueDressup.DragDrop
|
||||
{
|
||||
/// <summary>
|
||||
/// Individual decoration item that can be dragged from menu to statue slots
|
||||
/// </summary>
|
||||
public class DecorationItem : DraggableObject
|
||||
{
|
||||
[Header("Decoration Data")]
|
||||
[SerializeField] private DecorationData decorationData;
|
||||
[SerializeField] private Image decorationImage;
|
||||
|
||||
private Vector2 _iconSize;
|
||||
private Vector2 _authoredSize;
|
||||
private Vector2 _originalMenuPosition;
|
||||
private bool _isInMenu = true;
|
||||
|
||||
// Properties
|
||||
public DecorationData Data => decorationData;
|
||||
public DecorationCategory Category => decorationData?.Category ?? DecorationCategory.Hats;
|
||||
public bool IsInMenu => _isInMenu;
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
if (decorationData != null)
|
||||
{
|
||||
_iconSize = decorationData.IconSize;
|
||||
_authoredSize = decorationData.AuthoredSize;
|
||||
|
||||
// Set initial icon size
|
||||
if (RectTransform != null)
|
||||
{
|
||||
RectTransform.sizeDelta = _iconSize;
|
||||
}
|
||||
|
||||
// Set sprite
|
||||
if (decorationImage != null && decorationData.DecorationSprite != null)
|
||||
{
|
||||
decorationImage.sprite = decorationData.DecorationSprite;
|
||||
}
|
||||
}
|
||||
|
||||
// Store original menu position
|
||||
if (RectTransform != null)
|
||||
{
|
||||
_originalMenuPosition = RectTransform.anchoredPosition;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set decoration data (for spawned instances)
|
||||
/// </summary>
|
||||
public void SetDecorationData(DecorationData data)
|
||||
{
|
||||
decorationData = data;
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
_iconSize = data.IconSize;
|
||||
_authoredSize = data.AuthoredSize;
|
||||
|
||||
// Update visual
|
||||
if (decorationImage != null && data.DecorationSprite != null)
|
||||
{
|
||||
decorationImage.sprite = data.DecorationSprite;
|
||||
}
|
||||
|
||||
// Set icon size
|
||||
if (RectTransform != null)
|
||||
{
|
||||
RectTransform.sizeDelta = _iconSize;
|
||||
}
|
||||
|
||||
Logging.Debug($"[DecorationItem] Set data: {data.DecorationName}, iconSize={_iconSize}, authoredSize={_authoredSize}");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDragStartedHook()
|
||||
{
|
||||
Logging.Debug($"[DecorationItem] OnDragStarted: {decorationData?.DecorationName}");
|
||||
|
||||
// Scale to authored size when dragging starts
|
||||
if (RectTransform != null)
|
||||
{
|
||||
TweenAnimationUtility.AnimateScale(transform, Vector3.one, 0.2f);
|
||||
|
||||
// Animate size delta to authored size
|
||||
RectTransform.sizeDelta = _authoredSize;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDragEndedHook()
|
||||
{
|
||||
Logging.Debug($"[DecorationItem] OnDragEnded: {decorationData?.DecorationName}, currentSlot={CurrentSlot?.name}");
|
||||
|
||||
// If not placed in a slot, return to menu
|
||||
if (CurrentSlot == null)
|
||||
{
|
||||
ReturnToMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
_isInMenu = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return item to menu with animation
|
||||
/// </summary>
|
||||
private void ReturnToMenu()
|
||||
{
|
||||
Logging.Debug($"[DecorationItem] Returning to menu: {decorationData?.DecorationName}");
|
||||
|
||||
_isInMenu = true;
|
||||
|
||||
if (RectTransform != null)
|
||||
{
|
||||
// Animate back to icon size
|
||||
RectTransform.sizeDelta = _iconSize;
|
||||
TweenAnimationUtility.AnimateScale(transform, Vector3.one, 0.2f);
|
||||
|
||||
// Animate back to original position
|
||||
TweenAnimationUtility.AnimateAnchoredPosition(RectTransform, _originalMenuPosition, 0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set original menu position (called by menu controller)
|
||||
/// </summary>
|
||||
public void SetOriginalMenuPosition(Vector2 position)
|
||||
{
|
||||
_originalMenuPosition = position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31a82dde0ffb439e86b79499b9daa92b
|
||||
timeCreated: 1763745531
|
||||
@@ -1,125 +0,0 @@
|
||||
using Core;
|
||||
using Minigames.StatueDressup.Data;
|
||||
using Minigames.StatueDressup.Utils;
|
||||
using UI.DragAndDrop.Core;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Minigames.StatueDressup.DragDrop
|
||||
{
|
||||
/// <summary>
|
||||
/// Slot on the statue where decorations can be placed
|
||||
/// </summary>
|
||||
public class StatueDecorationSlot : DraggableSlot, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
[Header("Slot Configuration")]
|
||||
[SerializeField] private DecorationCategory allowedCategory;
|
||||
[SerializeField] private bool isPermanent = true; // Can't remove once placed
|
||||
|
||||
[Header("Glow Effect")]
|
||||
[SerializeField] private GameObject glowEffect;
|
||||
[SerializeField] private float glowPulseAmount = 1.1f;
|
||||
[SerializeField] private float glowPulseDuration = 0.8f;
|
||||
|
||||
private bool _isGlowing;
|
||||
private Pixelplacement.TweenSystem.TweenBase _glowTween;
|
||||
|
||||
// Properties
|
||||
public DecorationCategory AllowedCategory => allowedCategory;
|
||||
public bool IsPermanent => isPermanent;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Hide glow effect initially
|
||||
if (glowEffect != null)
|
||||
{
|
||||
glowEffect.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public new void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
// Only glow when dragging a matching decoration
|
||||
if (eventData.pointerDrag != null)
|
||||
{
|
||||
var decoration = eventData.pointerDrag.GetComponent<DecorationItem>();
|
||||
if (decoration != null && decoration.Category == allowedCategory && !IsOccupied)
|
||||
{
|
||||
StartGlow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
StopGlow();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start glow effect
|
||||
/// </summary>
|
||||
private void StartGlow()
|
||||
{
|
||||
if (_isGlowing || glowEffect == null)
|
||||
return;
|
||||
|
||||
_isGlowing = true;
|
||||
glowEffect.SetActive(true);
|
||||
|
||||
Logging.Debug($"[StatueDecorationSlot] Starting glow on {name}");
|
||||
|
||||
// Pulse animation
|
||||
_glowTween = TweenAnimationUtility.StartGlowPulse(glowEffect.transform, glowPulseAmount, glowPulseDuration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop glow effect
|
||||
/// </summary>
|
||||
private void StopGlow()
|
||||
{
|
||||
if (!_isGlowing || glowEffect == null)
|
||||
return;
|
||||
|
||||
_isGlowing = false;
|
||||
|
||||
Logging.Debug($"[StatueDecorationSlot] Stopping glow on {name}");
|
||||
|
||||
// Stop pulse animation
|
||||
if (_glowTween != null)
|
||||
{
|
||||
TweenAnimationUtility.StopTweens(glowEffect.transform);
|
||||
_glowTween = null;
|
||||
}
|
||||
|
||||
glowEffect.SetActive(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override to check category matching (uses base CanAccept)
|
||||
/// </summary>
|
||||
public new bool CanAccept(DraggableObject draggable)
|
||||
{
|
||||
// First check base conditions
|
||||
if (!base.CanAccept(draggable))
|
||||
return false;
|
||||
|
||||
// Then check category matching
|
||||
if (draggable is DecorationItem decoration)
|
||||
{
|
||||
bool matches = decoration.Category == allowedCategory;
|
||||
Logging.Debug($"[StatueDecorationSlot] CanAccept: {decoration.Data?.DecorationName}, " +
|
||||
$"category={decoration.Category}, allowed={allowedCategory}, matches={matches}");
|
||||
return matches;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// Clean up glow on disable
|
||||
StopGlow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f68e3749518141b6bc818938dd8dc57d
|
||||
timeCreated: 1763745550
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe03648f638e4872abafaf49234a3f55
|
||||
timeCreated: 1763745490
|
||||
@@ -1,151 +0,0 @@
|
||||
using Pixelplacement;
|
||||
using Pixelplacement.TweenSystem;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
namespace Minigames.StatueDressup.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Common animation utilities extracted from CardAnimator pattern.
|
||||
/// Provides reusable tween animations for UI elements.
|
||||
/// </summary>
|
||||
public static class TweenAnimationUtility
|
||||
{
|
||||
#region Scale Animations
|
||||
|
||||
/// <summary>
|
||||
/// Animate scale to target value with ease in-out
|
||||
/// </summary>
|
||||
public static TweenBase AnimateScale(Transform transform, Vector3 targetScale, float duration, Action onComplete = null)
|
||||
{
|
||||
return Tween.LocalScale(transform, targetScale, duration, 0f, Tween.EaseInOut, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pulse scale animation (scale up then back to original)
|
||||
/// </summary>
|
||||
public static void PulseScale(Transform transform, float pulseAmount = 1.1f, float duration = 0.2f, Action onComplete = null)
|
||||
{
|
||||
Vector3 originalScale = transform.localScale;
|
||||
Vector3 pulseScale = originalScale * pulseAmount;
|
||||
|
||||
Tween.LocalScale(transform, pulseScale, duration, 0f, Tween.EaseOutBack,
|
||||
completeCallback: () =>
|
||||
{
|
||||
Tween.LocalScale(transform, originalScale, duration, 0f, Tween.EaseInBack, completeCallback: onComplete);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pop-in animation (scale from 0 to target with overshoot)
|
||||
/// </summary>
|
||||
public static TweenBase PopIn(Transform transform, Vector3 targetScale, float duration = 0.5f, Action onComplete = null)
|
||||
{
|
||||
transform.localScale = Vector3.zero;
|
||||
return Tween.LocalScale(transform, targetScale, duration, 0f, Tween.EaseOutBack, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pop-out animation (scale from current to 0)
|
||||
/// </summary>
|
||||
public static TweenBase PopOut(Transform transform, float duration = 0.3f, Action onComplete = null)
|
||||
{
|
||||
return Tween.LocalScale(transform, Vector3.zero, duration, 0f, Tween.EaseInBack, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Smooth scale transition with bounce
|
||||
/// </summary>
|
||||
public static TweenBase ScaleWithBounce(Transform transform, Vector3 targetScale, float duration, Action onComplete = null)
|
||||
{
|
||||
return Tween.LocalScale(transform, targetScale, duration, 0f, Tween.EaseOutBack, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Position Animations
|
||||
|
||||
/// <summary>
|
||||
/// Animate anchored position (for RectTransform UI elements)
|
||||
/// </summary>
|
||||
public static TweenBase AnimateAnchoredPosition(RectTransform rectTransform, Vector2 targetPosition, float duration, Action onComplete = null)
|
||||
{
|
||||
return Tween.AnchoredPosition(rectTransform, targetPosition, duration, 0f, Tween.EaseInOut, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Animate local position (for regular transforms)
|
||||
/// </summary>
|
||||
public static TweenBase AnimateLocalPosition(Transform transform, Vector3 targetPosition, float duration, Action onComplete = null)
|
||||
{
|
||||
return Tween.LocalPosition(transform, targetPosition, duration, 0f, Tween.EaseInOut, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move with bounce effect
|
||||
/// </summary>
|
||||
public static TweenBase MoveWithBounce(RectTransform rectTransform, Vector2 targetPosition, float duration, Action onComplete = null)
|
||||
{
|
||||
return Tween.AnchoredPosition(rectTransform, targetPosition, duration, 0f, Tween.EaseOutBack, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Combined Hover Animations
|
||||
|
||||
/// <summary>
|
||||
/// Hover enter animation (lift and scale) for RectTransform
|
||||
/// </summary>
|
||||
public static void HoverEnter(RectTransform rectTransform, Vector2 originalPosition, float liftAmount = 20f,
|
||||
float scaleMultiplier = 1.05f, float duration = 0.2f, Action onComplete = null)
|
||||
{
|
||||
Vector2 targetPos = originalPosition + Vector2.up * liftAmount;
|
||||
|
||||
Tween.AnchoredPosition(rectTransform, targetPos, duration, 0f, Tween.EaseOutBack);
|
||||
Tween.LocalScale(rectTransform, Vector3.one * scaleMultiplier, duration, 0f, Tween.EaseOutBack, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hover exit animation (return to original position and scale) for RectTransform
|
||||
/// </summary>
|
||||
public static void HoverExit(RectTransform rectTransform, Vector2 originalPosition, float duration = 0.2f, Action onComplete = null)
|
||||
{
|
||||
Tween.AnchoredPosition(rectTransform, originalPosition, duration, 0f, Tween.EaseInBack);
|
||||
Tween.LocalScale(rectTransform, Vector3.one, duration, 0f, Tween.EaseInBack, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Glow pulse effect (scale up/down repeatedly)
|
||||
/// </summary>
|
||||
public static TweenBase StartGlowPulse(Transform transform, float pulseAmount = 1.1f, float duration = 0.8f)
|
||||
{
|
||||
Vector3 originalScale = transform.localScale;
|
||||
Vector3 pulseScale = originalScale * pulseAmount;
|
||||
|
||||
return Tween.LocalScale(transform, pulseScale, duration, 0f, Tween.EaseInOutSine, Tween.LoopType.PingPong);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop any active tweens on transform
|
||||
/// </summary>
|
||||
public static void StopTweens(Transform transform)
|
||||
{
|
||||
Tween.Cancel(transform.GetInstanceID());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fade Animations
|
||||
|
||||
/// <summary>
|
||||
/// Fade CanvasGroup alpha
|
||||
/// </summary>
|
||||
public static TweenBase FadeCanvasGroup(CanvasGroup canvasGroup, float targetAlpha, float duration, Action onComplete = null)
|
||||
{
|
||||
return Tween.CanvasGroupAlpha(canvasGroup, targetAlpha, duration, 0f, Tween.EaseInOut, completeCallback: onComplete);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abd48147eff149508890fe2fa87b8421
|
||||
timeCreated: 1763745490
|
||||
@@ -6,7 +6,9 @@ namespace StateMachines.Quarry.AnneLise
|
||||
{
|
||||
public class AnneLiseBushBehaviour : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private GameObject dialogueCanvas;
|
||||
|
||||
|
||||
private AppleMachine _anneLiseBushStateMachine;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
@@ -16,6 +18,7 @@ namespace StateMachines.Quarry.AnneLise
|
||||
|
||||
public void TakePhoto()
|
||||
{
|
||||
dialogueCanvas?.SetActive(false);
|
||||
_anneLiseBushStateMachine.ChangeState("TakePhoto");
|
||||
}
|
||||
}
|
||||
|
||||
78
Assets/Scripts/StateMachines/Quarry/AnneLise/HiddenState.cs
Normal file
78
Assets/Scripts/StateMachines/Quarry/AnneLise/HiddenState.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
|
||||
namespace StateMachines.Quarry.AnneLise
|
||||
{
|
||||
/// <summary>
|
||||
/// Hidden state for Anne Lise that saves/restores the DialogueCanvas active state
|
||||
/// </summary>
|
||||
public class HiddenState : AppleState
|
||||
{
|
||||
private GameObject _dialogueCanvas;
|
||||
|
||||
/// <summary>
|
||||
/// Serializable data for the hidden state
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
private class HiddenStateData
|
||||
{
|
||||
public bool wasDialogueCanvasActive;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// Find the immediate child called "DialogueCanvas"
|
||||
Transform childTransform = transform.Find("DialogueCanvas");
|
||||
if (childTransform != null)
|
||||
{
|
||||
_dialogueCanvas = childTransform.gameObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[HiddenState] DialogueCanvas child not found on {gameObject.name}");
|
||||
}
|
||||
}
|
||||
|
||||
public override string SerializeState()
|
||||
{
|
||||
if (_dialogueCanvas == null)
|
||||
{
|
||||
Debug.LogWarning("[HiddenState] Cannot serialize state - DialogueCanvas is null");
|
||||
return "";
|
||||
}
|
||||
|
||||
HiddenStateData data = new HiddenStateData
|
||||
{
|
||||
wasDialogueCanvasActive = _dialogueCanvas.activeSelf
|
||||
};
|
||||
|
||||
return JsonUtility.ToJson(data);
|
||||
}
|
||||
|
||||
public override void OnRestoreState(string data)
|
||||
{
|
||||
if (string.IsNullOrEmpty(data))
|
||||
{
|
||||
Debug.LogWarning("[HiddenState] No data to restore");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_dialogueCanvas == null)
|
||||
{
|
||||
Debug.LogWarning("[HiddenState] Cannot restore state - DialogueCanvas is null");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
HiddenStateData stateData = JsonUtility.FromJson<HiddenStateData>(data);
|
||||
_dialogueCanvas.SetActive(stateData.wasDialogueCanvasActive);
|
||||
Debug.Log($"[HiddenState] Restored DialogueCanvas active state to: {stateData.wasDialogueCanvasActive}");
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogError($"[HiddenState] Failed to restore state: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fa347bfb45f473f8639842928f8cfa1
|
||||
timeCreated: 1763978213
|
||||
@@ -8,6 +8,7 @@ using UnityEngine.UI;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using DamianExperiments;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
@@ -308,6 +309,9 @@ namespace UI
|
||||
/// </summary>
|
||||
private void ApplyUIModeOverrides(bool visible)
|
||||
{
|
||||
// First, reset state to neutral
|
||||
ResetStateBeforeLevelLoad();
|
||||
|
||||
switch (currentUIMode)
|
||||
{
|
||||
case UIMode.Overworld:
|
||||
@@ -336,6 +340,11 @@ namespace UI
|
||||
}
|
||||
}
|
||||
|
||||
protected void ResetStateBeforeLevelLoad()
|
||||
{
|
||||
eagleEye.GetComponent<EagleEyeBehaviour>()?.ResetEagleEye();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Automatically manages HUD visibility based on page stack state
|
||||
/// </summary>
|
||||
|
||||
@@ -15,6 +15,7 @@ MonoBehaviour:
|
||||
showDebugUiMessages: 1
|
||||
pauseTimeOnPauseGame: 0
|
||||
useSaveLoadSystem: 1
|
||||
autoClearSaves: 0
|
||||
bootstrapLogVerbosity: 0
|
||||
settingsLogVerbosity: 0
|
||||
gameManagerLogVerbosity: 0
|
||||
|
||||
@@ -10,6 +10,7 @@ TagManager:
|
||||
- Obstacle
|
||||
- Projectile
|
||||
- Target
|
||||
- MainCinemachineCamera
|
||||
layers:
|
||||
- Default
|
||||
- TransparentFX
|
||||
|
||||
Reference in New Issue
Block a user