Compare commits

...

2 Commits

15 changed files with 331 additions and 90 deletions

View File

@@ -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

View 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}");
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c3ba01f7bb704c17bc4f22fd726f7fee
timeCreated: 1763974355

View File

@@ -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

View File

@@ -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}

View File

@@ -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

View File

@@ -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()
{

View File

@@ -1,60 +1,106 @@
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;
public class EagleEyeBehaviour : MonoBehaviour
{
// Serialized backing fields allow manual assignment in the inspector
private GameObject _cinecameraObject;
private CinemachineCamera _virtualCamera;
private CinemachineConfiner2D _confiner2D;
// Lazy-fetched properties: if null, try to find the GameObject tagged "MainCinemachineCamera"
private CinemachineCamera VirtualCamera
{
get
{
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;
}
set => _virtualCamera = value;
}
private CinemachineConfiner2D Confiner2D
{
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;
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;
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()
{
//Assigns the Virtual Camera and Confiner if not already assigned
if (virtualCamera == null)
{
virtualCamera = FindAnyObjectByType<CinemachineCamera>();
}
if (confiner2D == null)
{
confiner2D = virtualCamera.GetComponent<CinemachineConfiner2D>();
}
// Implementation for activating eagle eye behaviour
if (disablePlayerInputDuringEagleEye)
{
currentOrthoSize = virtualCamera.Lens.OrthographicSize;
}
if (eagleEyeButton != null)
{
eagleEyeButton.interactable = false;
}
if (zoomCoroutine != null) StopCoroutine(zoomCoroutine);
zoomCoroutine = StartCoroutine(EagleEyeSequence());
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));
_smoothOrthoCoroutine = StartCoroutine(SmoothOrthoSize(VirtualCamera, zoomOutOrthoSize, transitionDuration));
yield return _smoothOrthoCoroutine;
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
}
float zoomInTarget = normalOrthoSize;
_smoothOrthoCoroutine = StartCoroutine(SmoothOrthoSize(VirtualCamera, zoomInTarget, transitionDuration));;
yield return _smoothOrthoCoroutine;
if (eagleEyeButton != null)
{
eagleEyeButton.interactable = true;
@@ -69,16 +115,17 @@ public class EagleEyeBehaviour : MonoBehaviour
{
elapsed += Time.deltaTime;
cam.Lens.OrthographicSize = Mathf.Lerp(startSize, targetSize, elapsed / duration);
if (confiner2D != null)
if (Confiner2D != null)
{
confiner2D.InvalidateBoundingShapeCache();
Confiner2D.InvalidateBoundingShapeCache();
}
yield return null;
}
cam.Lens.OrthographicSize = targetSize;
if (confiner2D != null)
if (Confiner2D != null)
{
confiner2D.InvalidateBoundingShapeCache();
Confiner2D.InvalidateBoundingShapeCache();
}
}
}
}

View File

@@ -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)

View File

@@ -6,6 +6,8 @@ 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
@@ -16,6 +18,7 @@ namespace StateMachines.Quarry.AnneLise
public void TakePhoto()
{
dialogueCanvas?.SetActive(false);
_anneLiseBushStateMachine.ChangeState("TakePhoto");
}
}

View 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}");
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1fa347bfb45f473f8639842928f8cfa1
timeCreated: 1763978213

View File

@@ -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>

View File

@@ -15,6 +15,7 @@ MonoBehaviour:
showDebugUiMessages: 1
pauseTimeOnPauseGame: 0
useSaveLoadSystem: 1
autoClearSaves: 0
bootstrapLogVerbosity: 0
settingsLogVerbosity: 0
gameManagerLogVerbosity: 0

View File

@@ -10,6 +10,7 @@ TagManager:
- Obstacle
- Projectile
- Target
- MainCinemachineCamera
layers:
- Default
- TransparentFX