From 07c89104f9408140ec341379c3c4c149def4a58d Mon Sep 17 00:00:00 2001 From: cyndrdev Date: Tue, 13 Apr 2021 15:33:59 +0100 Subject: [PATCH] fixed time freeze not working --- game/Assets/Prefabs/PlayerObjects.prefab | 59 +++++++++++++++++++ game/Assets/Scenes/Main.unity | 8 --- .../Assets/Scripts/Player/PlayerController.cs | 7 ++- game/Assets/Scripts/Traps/FallawayFloor.cs | 2 +- game/Assets/Scripts/Traps/TrapSettings.cs | 2 +- game/Assets/Scripts/Util/SerialFloat.cs | 1 + .../Assets/Settings/Traps/Trap Settings.asset | 7 +-- 7 files changed, 71 insertions(+), 15 deletions(-) diff --git a/game/Assets/Prefabs/PlayerObjects.prefab b/game/Assets/Prefabs/PlayerObjects.prefab index 68e644a..ca8ffc6 100644 --- a/game/Assets/Prefabs/PlayerObjects.prefab +++ b/game/Assets/Prefabs/PlayerObjects.prefab @@ -318,18 +318,54 @@ PrefabInstance: propertyPath: m_Camera value: objectReference: {fileID: 4676633831388223340} + - target: {fileID: 13726836969441780, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_ActionEvents.Array.size + value: 10 + objectReference: {fileID: 0} - target: {fileID: 13726836969441780, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} propertyPath: m_ActionEvents.Array.data[5].m_ActionId value: 0eb55067-1328-4b0a-9494-b427befe049a objectReference: {fileID: 0} + - target: {fileID: 13726836969441780, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_ActionEvents.Array.data[9].m_ActionId + value: 5b0a923b-469a-4829-8f31-6fcd7cb49281 + objectReference: {fileID: 0} - target: {fileID: 13726836969441780, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} propertyPath: m_ActionEvents.Array.data[5].m_ActionName value: CoreMap/New action objectReference: {fileID: 0} + - target: {fileID: 13726836969441780, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_ActionEvents.Array.data[9].m_ActionName + value: ArtefactPreview/LookEnable[/Mouse/leftButton] + objectReference: {fileID: 0} + - target: {fileID: 13726836969441780, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_ActionEvents.Array.data[8].m_PersistentCalls.m_Calls.Array.size + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 13726836969441780, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_ActionEvents.Array.data[8].m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: 4676633831945762667} + - target: {fileID: 13726836969441780, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_ActionEvents.Array.data[8].m_PersistentCalls.m_Calls.Array.data[0].m_CallState + value: 2 + objectReference: {fileID: 0} - target: {fileID: 13726836969441780, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} propertyPath: m_ActionEvents.Array.data[5].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName value: Blink objectReference: {fileID: 0} + - target: {fileID: 13726836969441780, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_ActionEvents.Array.data[8].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: Freeze + objectReference: {fileID: 0} + - target: {fileID: 13726836969441780, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_ActionEvents.Array.data[8].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName + value: PlayerInputHandler, Assembly-CSharp + objectReference: {fileID: 0} + - target: {fileID: 13726836969441780, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: m_ActionEvents.Array.data[8].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} - target: {fileID: 13726836969441781, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} propertyPath: m_Name value: Player @@ -342,6 +378,18 @@ PrefabInstance: propertyPath: _freeze value: objectReference: {fileID: 11400000, guid: 0cd9cf6494bb6f54d9b97631010d780e, type: 2} + - target: {fileID: 13726837176080779, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: _cheatBlink + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 13726837176080779, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: _cheatBoost + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 13726837176080779, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + propertyPath: _cheatFreeze + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} --- !u!4 &4676633831945762709 stripped @@ -349,6 +397,17 @@ Transform: m_CorrespondingSourceObject: {fileID: 13726836969441544, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} m_PrefabInstance: {fileID: 4672055586710847133} m_PrefabAsset: {fileID: 0} +--- !u!114 &4676633831945762667 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 13726836969441782, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} + m_PrefabInstance: {fileID: 4672055586710847133} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e12816fc78a8ca3429be019aa4e51fdd, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!4 &3150647428828152554 stripped Transform: m_CorrespondingSourceObject: {fileID: 7741442472643640439, guid: 5efe0b059275dbe48a4108d03ad03fd9, type: 3} diff --git a/game/Assets/Scenes/Main.unity b/game/Assets/Scenes/Main.unity index eff5bd5..a174e48 100644 --- a/game/Assets/Scenes/Main.unity +++ b/game/Assets/Scenes/Main.unity @@ -2314,14 +2314,6 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - propertyPath: m_LocalRotation.y - value: 0.15792163 - objectReference: {fileID: 0} - - target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} - propertyPath: m_LocalRotation.z - value: -0.0165495 - objectReference: {fileID: 0} - target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3} propertyPath: m_Name value: PlayerObjects diff --git a/game/Assets/Scripts/Player/PlayerController.cs b/game/Assets/Scripts/Player/PlayerController.cs index ea041f1..8e465ca 100644 --- a/game/Assets/Scripts/Player/PlayerController.cs +++ b/game/Assets/Scripts/Player/PlayerController.cs @@ -171,15 +171,20 @@ public class PlayerController : MonoBehaviour { _powers.Freeze.Consume(); objectTimeScale.Value = 0f; + Debug.Log( "[PlayerController] time frozen" ); } - if (_powers.Freeze.timeSinceConsume > frozenTime) + if ( _powers.Freeze.timeSinceConsume > frozenTime && TimeIsFrozen ) { UnfreezeTime(); + Debug.Log( "[PlayerController] time unfrozen" ); } } + public bool TimeIsFrozen + => objectTimeScale.AsBool; + private void UnfreezeTime() { objectTimeScale.Value = 1f; diff --git a/game/Assets/Scripts/Traps/FallawayFloor.cs b/game/Assets/Scripts/Traps/FallawayFloor.cs index ca06600..931fb77 100644 --- a/game/Assets/Scripts/Traps/FallawayFloor.cs +++ b/game/Assets/Scripts/Traps/FallawayFloor.cs @@ -73,7 +73,7 @@ public class FallawayFloor : MonoBehaviour if (_triggered) return; // time stop - if (_settings.ObjectTimeScale == 0) return; + if ( _settings.ObjectTimeScale.AsBool ) return; StartCoroutine(FallCR()); } diff --git a/game/Assets/Scripts/Traps/TrapSettings.cs b/game/Assets/Scripts/Traps/TrapSettings.cs index b53b067..5a6265b 100644 --- a/game/Assets/Scripts/Traps/TrapSettings.cs +++ b/game/Assets/Scripts/Traps/TrapSettings.cs @@ -14,7 +14,7 @@ public class TrapSettings : ScriptableObject // in a safe zone [SerializeField] private SerialFloat _safeTime; - public float ObjectTimeScale => _objectTimeScale; + public SerialFloat ObjectTimeScale => _objectTimeScale; [SerializeField] private SerialFloat _objectTimeScale; [Serializable] diff --git a/game/Assets/Scripts/Util/SerialFloat.cs b/game/Assets/Scripts/Util/SerialFloat.cs index 204f6ff..acf0c35 100644 --- a/game/Assets/Scripts/Util/SerialFloat.cs +++ b/game/Assets/Scripts/Util/SerialFloat.cs @@ -7,5 +7,6 @@ namespace Ktyl.Util [CreateAssetMenu(menuName = "ktyl/Util/Float")] public class SerialFloat : SerialVar { + public bool AsBool => Mathf.Abs( Value ) <= float.Epsilon; } } \ No newline at end of file diff --git a/game/Assets/Settings/Traps/Trap Settings.asset b/game/Assets/Settings/Traps/Trap Settings.asset index 6e8b4ef..512b3fb 100644 --- a/game/Assets/Settings/Traps/Trap Settings.asset +++ b/game/Assets/Settings/Traps/Trap Settings.asset @@ -12,13 +12,12 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 93dc605253d04fe45a05492fb3feacc2, type: 3} m_Name: Trap Settings m_EditorClassIdentifier: + _safeTime: {fileID: 11400000, guid: 27c10a061baeec8469e96d4f995c1445, type: 2} _objectTimeScale: {fileID: 11400000, guid: 9b68e167db44c0c42837e9a679da964e, type: 2} _fallawayFloor: - _prefab: {fileID: 8773676356524340268, guid: d145f0e5906f91a4fad7f384f1b2a6ec, type: 3} + _safeResetTime: 0 _fmodEvent: event:/Environment/Traps/FallingPlatform - _respawnTime: {fileID: 11400000, guid: 1d2951ab5083d4d48a319ff00a9eb8bd, type: 2} - _safeTime: {fileID: 11400000, guid: 27c10a061baeec8469e96d4f995c1445, type: 2} _shakeStrength: 0.1 _popInEase: 27 _arrowWall: - delay: 2 + _safeResetTime: 0