From 0d451302e0fd6edf68f5ebbef1112e1d09efce2a Mon Sep 17 00:00:00 2001 From: milan Date: Mon, 15 May 2023 09:13:12 +0200 Subject: [PATCH] only allow using elevator while on it --- Assets/Scenes/PuzzleTest.unity | 18 +++++------ .../Modules/Button Stand/Button Stand.prefab | 6 ++-- .../Button Stand/Timed Button Stand.prefab | 12 +------ .../Elevated Platform.prefab | 26 +++++++++++++-- .../Scripts/PlatformElevator.cs | 32 +++++++++++++++++-- 5 files changed, 67 insertions(+), 27 deletions(-) diff --git a/Assets/Scenes/PuzzleTest.unity b/Assets/Scenes/PuzzleTest.unity index a71cb34..ec16817 100644 --- a/Assets/Scenes/PuzzleTest.unity +++ b/Assets/Scenes/PuzzleTest.unity @@ -1471,14 +1471,14 @@ Transform: - {fileID: 604728745} - {fileID: 681930983} - {fileID: 6067357455631746734} - - {fileID: 1853180256} - {fileID: 1949077063} - {fileID: 1532540192886921385} + - {fileID: 3750376657174321754} + - {fileID: 2343402481646314946} + - {fileID: 1853180256} - {fileID: 675198211105780961} - {fileID: 538618498} - {fileID: 9336441} - - {fileID: 3750376657174321754} - - {fileID: 2343402481646314946} m_Father: {fileID: 1340421038} m_RootOrder: -1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -1498,7 +1498,7 @@ PrefabInstance: - target: {fileID: 4465959117638929429, guid: 7e73939d683dfbd41b3d359167a157cd, type: 3} propertyPath: m_LocalPosition.x - value: 5.0000005 + value: 5 objectReference: {fileID: 0} - target: {fileID: 4465959117638929429, guid: 7e73939d683dfbd41b3d359167a157cd, type: 3} @@ -3246,7 +3246,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &1340421038 Transform: m_ObjectHideFlags: 0 @@ -3694,7 +3694,7 @@ PrefabInstance: - target: {fileID: 2216350971831476633, guid: 7854eeba0cc4ea4419f74ce50bc9c514, type: 3} propertyPath: m_RootOrder - value: 0 + value: -1 objectReference: {fileID: 0} - target: {fileID: 2216350971831476633, guid: 7854eeba0cc4ea4419f74ce50bc9c514, type: 3} @@ -3719,17 +3719,17 @@ PrefabInstance: - target: {fileID: 2216350971831476633, guid: 7854eeba0cc4ea4419f74ce50bc9c514, type: 3} propertyPath: m_LocalRotation.x - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 2216350971831476633, guid: 7854eeba0cc4ea4419f74ce50bc9c514, type: 3} propertyPath: m_LocalRotation.y - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 2216350971831476633, guid: 7854eeba0cc4ea4419f74ce50bc9c514, type: 3} propertyPath: m_LocalRotation.z - value: 0 + value: -0 objectReference: {fileID: 0} - target: {fileID: 2216350971831476633, guid: 7854eeba0cc4ea4419f74ce50bc9c514, type: 3} diff --git a/Assets/Station46/Modules/Button Stand/Button Stand.prefab b/Assets/Station46/Modules/Button Stand/Button Stand.prefab index 2c27ff7..d2d1480 100644 --- a/Assets/Station46/Modules/Button Stand/Button Stand.prefab +++ b/Assets/Station46/Modules/Button Stand/Button Stand.prefab @@ -153,7 +153,7 @@ Transform: - {fileID: 852813185195933073} - {fileID: 979859350274255980} m_Father: {fileID: 0} - m_RootOrder: -1 + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &7351803888791370729 GameObject: @@ -285,8 +285,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 352860bb2c6549d0b3e84104afef3f54, type: 3} m_Name: m_EditorClassIdentifier: - hideWhenDisabled: 0 - startInactive: 0 + hideWhenDisabled: 1 + startInactive: 1 holoRenderer: {fileID: 7222608493507710839} --- !u!114 &3852086329416498098 MonoBehaviour: diff --git a/Assets/Station46/Modules/Button Stand/Timed Button Stand.prefab b/Assets/Station46/Modules/Button Stand/Timed Button Stand.prefab index 401bb22..c8c7987 100644 --- a/Assets/Station46/Modules/Button Stand/Timed Button Stand.prefab +++ b/Assets/Station46/Modules/Button Stand/Timed Button Stand.prefab @@ -8,20 +8,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 874298466439840366, guid: 866e3516e2f8502408e17cb19c4e57cc, - type: 3} - propertyPath: startInactive - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 874298466439840366, guid: 866e3516e2f8502408e17cb19c4e57cc, - type: 3} - propertyPath: hideWhenDisabled - value: 1 - objectReference: {fileID: 0} - target: {fileID: 1223383990908721599, guid: 866e3516e2f8502408e17cb19c4e57cc, type: 3} propertyPath: m_RootOrder - value: -1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 1223383990908721599, guid: 866e3516e2f8502408e17cb19c4e57cc, type: 3} diff --git a/Assets/Station46/Modules/Elevated Platform/Elevated Platform.prefab b/Assets/Station46/Modules/Elevated Platform/Elevated Platform.prefab index 65bad9f..c75d409 100644 --- a/Assets/Station46/Modules/Elevated Platform/Elevated Platform.prefab +++ b/Assets/Station46/Modules/Elevated Platform/Elevated Platform.prefab @@ -43,7 +43,8 @@ GameObject: - component: {fileID: 8648774459861283546} - component: {fileID: 716647553232511872} - component: {fileID: 2841556225424433569} - m_Layer: 0 + - component: {fileID: 5292547662050914046} + m_Layer: 7 m_Name: Elevator m_TagString: Untagged m_Icon: {fileID: 0} @@ -101,6 +102,27 @@ Animator: m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorStateOnDisable: 0 m_WriteDefaultValuesOnDisable: 0 +--- !u!65 &5292547662050914046 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1636625108852260585} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 1 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 2, z: 1} + m_Center: {x: 0, y: 1, z: 0} --- !u!1 &2903613370134496792 GameObject: m_ObjectHideFlags: 0 @@ -272,7 +294,7 @@ Transform: - {fileID: 6915102081068721723} - {fileID: 4453669748914392433} m_Father: {fileID: 0} - m_RootOrder: -1 + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &6525843738508825059 MonoBehaviour: diff --git a/Assets/Station46/Modules/Elevated Platform/Scripts/PlatformElevator.cs b/Assets/Station46/Modules/Elevated Platform/Scripts/PlatformElevator.cs index d4e8f95..11129ed 100644 --- a/Assets/Station46/Modules/Elevated Platform/Scripts/PlatformElevator.cs +++ b/Assets/Station46/Modules/Elevated Platform/Scripts/PlatformElevator.cs @@ -8,7 +8,7 @@ using LogType = EscapeRoomEngine.Engine.Runtime.Utilities.LogType; namespace Station46.Modules.Elevated_Platform.Scripts { - [RequireComponent(typeof(Animator))] + [RequireComponent(typeof(Animator), typeof(Collider))] public class PlatformElevator : MonoBehaviour { public enum Status @@ -34,7 +34,11 @@ namespace Station46.Modules.Elevated_Platform.Scripts case Status.Bottom: case Status.Top: ReleasePlayer(); - _button.Enable(); + if (!_leftElevatorWhileMoving) + { + _button.Enable(); + } + _leftElevatorWhileMoving = false; break; case Status.Moving: _button.Disable(); @@ -49,6 +53,7 @@ namespace Station46.Modules.Elevated_Platform.Scripts private Status _status = Status.Bottom; private Animator _animator; private Transform _previousPlayerParent; + private bool _leftElevatorWhileMoving; private void Awake() { @@ -104,5 +109,28 @@ namespace Station46.Modules.Elevated_Platform.Scripts throw new ArgumentOutOfRangeException(); } } + + private void OnTriggerEnter(Collider other) + { + if (_status != Status.Moving && other.CompareTag("MainCamera")) + { + _button.Enable(); + } + } + + private void OnTriggerExit(Collider other) + { + if (other.CompareTag("MainCamera")) + { + if (_status == Status.Moving) + { + _leftElevatorWhileMoving = true; + } + else + { + _button.Disable(); + } + } + } } } \ No newline at end of file