Merge pull request 'DamianBranch' (#48) from DamianBranch into main

Reviewed-on: #48
This commit is contained in:
2025-11-06 16:16:18 +00:00
6 changed files with 269 additions and 0 deletions

View File

@@ -0,0 +1,168 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6980564769726958139
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5445689290567702089}
- component: {fileID: 1185116518380125445}
- component: {fileID: 4446188106673991604}
- component: {fileID: 823686888810001266}
- component: {fileID: 5048269179280902459}
- component: {fileID: 4259846497128417657}
m_Layer: 0
m_Name: EagleEyeButton
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5445689290567702089
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6980564769726958139}
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: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -225, y: 75}
m_SizeDelta: {x: 128, y: 128}
m_Pivot: {x: 1, y: 0}
--- !u!222 &1185116518380125445
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6980564769726958139}
m_CullTransparentMesh: 1
--- !u!114 &4446188106673991604
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6980564769726958139}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.78039217}
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: -3518187381767867529, 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!114 &823686888810001266
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6980564769726958139}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
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: 4446188106673991604}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 4259846497128417657}
m_TargetAssemblyTypeName: EagleEyeBehaviour, AppleHillsScripts
m_MethodName: ActivateEagleEye
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 &5048269179280902459
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6980564769726958139}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 494d0aedce9744308499355006071138, type: 3}
m_Name:
m_EditorClassIdentifier: AppleHillsScripts::UI.DummyInput
--- !u!114 &4259846497128417657
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6980564769726958139}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f5a0fae2a16515d46aca1e6cc631cee0, type: 3}
m_Name:
m_EditorClassIdentifier: AppleHillsScripts::EagleEyeBehaviour
virtualCamera: {fileID: 0}
confiner2D: {fileID: 0}
zoomOutOrthoSize: 30
normalOrthoSize: 15
transitionDuration: 0.5
eagleEyeDuration: 3
disablePlayerInputDuringEagleEye: 0
eagleEyeButton: {fileID: 823686888810001266}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 428a0feafda9d6d4e87ecf43ad41dc20
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,84 @@
using Unity.Cinemachine;
using UnityEngine;
using System.Collections;
public class EagleEyeBehaviour : MonoBehaviour
{
[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()
{
//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());
}
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)
{
confiner2D.InvalidateBoundingShapeCache();
}
yield return null;
}
cam.Lens.OrthographicSize = targetSize;
if (confiner2D != null)
{
confiner2D.InvalidateBoundingShapeCache();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f5a0fae2a16515d46aca1e6cc631cee0

View File

@@ -62,6 +62,10 @@ public class cameraSwitcher : MonoBehaviour
{
elapsed += Time.deltaTime;
cam.Lens.OrthographicSize = Mathf.Lerp(startSize, targetSize, elapsed / duration);
if (confiner2D != null)
{
confiner2D.InvalidateBoundingShapeCache();
}
yield return null;
}
cam.Lens.OrthographicSize = targetSize;

View File

@@ -49,6 +49,10 @@ public class cameraSwitcherNailBird : MonoBehaviour
{
elapsed += Time.deltaTime;
cam.Lens.OrthographicSize = Mathf.Lerp(startSize, targetSize, elapsed / duration);
if (confiner2D != null)
{
confiner2D.InvalidateBoundingShapeCache();
}
yield return null;
}
cam.Lens.OrthographicSize = targetSize;