diff --git a/Assets/Scenes/Level1.shade b/Assets/Scenes/Level1.shade index f9e62d31..e06548c0 100644 --- a/Assets/Scenes/Level1.shade +++ b/Assets/Scenes/Level1.shade @@ -5255,14 +5255,14 @@ IsActive: true Scripts: ~ - EID: 460 - Name: RetryButton + Name: StealFoodLogo IsActive: true NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: -100, z: 0} + Translate: {x: 0, y: 0, z: 0} Rotate: {x: 0, y: 0, z: 0} - Scale: {x: 300, y: 300, z: 500} + Scale: {x: 0, y: 0, z: 1} IsActive: true Renderable Component: Mesh: 141771688 @@ -5273,4 +5273,20 @@ Hovered: false Clicked: false IsActive: true - Scripts: ~ \ No newline at end of file + Scripts: + - Type: SHADE_Scripting.UI.StealFoodPopUp + Enabled: true + popInDuration: 0.5 + popOutDuration: 0.5 + stayDuration: 1 + rotationAmt: 1800 + scaleAmtX: 538 + scaleAmtY: 377 +- EID: 463 + Name: TweenManager + IsActive: true + NumberOfChildren: 0 + Components: ~ + Scripts: + - Type: SHADE_Scripting.UI.TweenManager + Enabled: true \ No newline at end of file diff --git a/Assets/Scripts/UI/SC_StealFoodPopUp.cs b/Assets/Scripts/UI/SC_StealFoodPopUp.cs new file mode 100644 index 00000000..59b97e7d --- /dev/null +++ b/Assets/Scripts/UI/SC_StealFoodPopUp.cs @@ -0,0 +1,90 @@ +using System; +using SHADE; + +namespace SHADE_Scripting.UI +{ + public class StealFoodPopUp : Script + { + [NonSerialized] + private TweenThread rot; + [NonSerialized] + private TweenThread scaleX; + [NonSerialized] + private TweenThread scaleY; + [NonSerialized] + private TweenThread scaleOutX; + [NonSerialized] + private TweenThread scaleOutY; + + private Transform tran; + + public float popInDuration = 0.3f; + public float popOutDuration = 0.3f; + public float stayDuration = 1.0f; + public float rotationAmt = 1800; + public float scaleAmtX = 538; + public float scaleAmtY = 377; + + private bool popInDone = false; + private bool stayDone = false; + + private bool createThreadOnce = true; + + private float timer = 0; + + protected override void start() + { + rot = TweenManager.CreateTweenThread(popInDuration, 0, rotationAmt, EASING_METHOD.EASE_IN_SINE); + scaleX = TweenManager.CreateTweenThread(popInDuration, 0, scaleAmtX, EASING_METHOD.EASE_IN_SINE); + scaleY = TweenManager.CreateTweenThread(popInDuration, 0, scaleAmtY, EASING_METHOD.EASE_IN_SINE); + + tran = GetComponent(); + if (!tran) + Debug.LogError("Missing Transform"); + else + { + tran.LocalScale = new Vector3(0.0f,0.0f,1.0f); + tran.LocalEulerAngles = new Vector3(0.0f,0.0f,0.0f); + } + + } + //538x377 + protected override void update() + { + + if (!popInDone) + { + tran.LocalEulerAngles = new Vector3(0.0f, 0.0f, SHADE.Math.DegreesToRadians(rot.GetValue())); + tran.LocalScale = new Vector3(scaleX.GetValue(), scaleY.GetValue(), 1); + } + else + { + timer += Time.DeltaTimeF; + if (timer >= stayDuration) + stayDone = true; + } + + if (rot.IsCompleted() && scaleX.IsCompleted() && scaleY.IsCompleted()) + popInDone = true; + + if (stayDone) + { + if (createThreadOnce) + { + scaleOutX = TweenManager.CreateTweenThread(popOutDuration, scaleAmtX, 0, EASING_METHOD.EASE_IN_SINE); + scaleOutY = TweenManager.CreateTweenThread(popOutDuration, scaleAmtY, 0, EASING_METHOD.EASE_IN_SINE); + createThreadOnce = false; + } + tran.LocalScale = new Vector3(scaleOutX.GetValue(), scaleOutY.GetValue(), 1); + if (scaleOutX.IsCompleted() && scaleOutY.IsCompleted()) + { + GameObject.SetActive(false); + } + } + } + + + } + +} + diff --git a/Assets/Scripts/UI/SC_StealFoodPopUp.cs.shmeta b/Assets/Scripts/UI/SC_StealFoodPopUp.cs.shmeta new file mode 100644 index 00000000..5c17cb2f --- /dev/null +++ b/Assets/Scripts/UI/SC_StealFoodPopUp.cs.shmeta @@ -0,0 +1,3 @@ +Name: SC_StealFoodPopUp +ID: 159004097 +Type: 9 diff --git a/Assets/Scripts/UI/SC_TweenManager.cs b/Assets/Scripts/UI/SC_TweenManager.cs index bbcc8c8f..b940c9fc 100644 --- a/Assets/Scripts/UI/SC_TweenManager.cs +++ b/Assets/Scripts/UI/SC_TweenManager.cs @@ -28,10 +28,11 @@ namespace SHADE_Scripting.UI public void Update(float deltaTime) { - if (timer > duration) + if (timer >= duration) return; + timer += deltaTime; - if (timer > duration) + if (timer >= duration) timer = duration; value = EasingHelper.EaseHelp(timer/duration, method) * (endValue - startValue) + startValue ; @@ -96,7 +97,6 @@ namespace SHADE_Scripting.UI protected override void update() { - foreach (TweenThread thread in threadList) { thread.Update(Time.DeltaTimeF); diff --git a/SHADE_Application/src/Scenes/SBMainScene.cpp b/SHADE_Application/src/Scenes/SBMainScene.cpp index dd713980..a0b2d35e 100644 --- a/SHADE_Application/src/Scenes/SBMainScene.cpp +++ b/SHADE_Application/src/Scenes/SBMainScene.cpp @@ -15,6 +15,7 @@ #include "Physics/Interface/SHColliderComponent.h" #include "Graphics/MiddleEnd/Lights/SHLightComponent.h" #include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h" +#include "FRC/SHFramerateController.h" #include "Assets/SHAssetManager.h" #include "Camera/SHCameraComponent.h" @@ -43,6 +44,7 @@ namespace Sandbox void SBMainScene::Init() { sceneName = SHSerialization::DeserializeSceneFromFile(sceneAssetID); + SHFrameRateController::ResetDT(); /*-----------------------------------------------------------------------*/ /* TESTING CODE */ diff --git a/SHADE_Engine/src/Editor/SHEditor.cpp b/SHADE_Engine/src/Editor/SHEditor.cpp index bc238b96..346bfbed 100644 --- a/SHADE_Engine/src/Editor/SHEditor.cpp +++ b/SHADE_Engine/src/Editor/SHEditor.cpp @@ -25,7 +25,7 @@ #include "SHEditorWidgets.hpp" #include "Math/Transform/SHTransformSystem.h" - +#include "FRC/SHFramerateController.h" //#==============================================================# //|| Editor Window Includes || //#==============================================================# @@ -612,6 +612,7 @@ namespace SHADE editorState = State::PLAY; SHCommandManager::SwapStacks(); SHEventManager::BroadcastEvent(STATE_CHANGE_EVENT, SH_EDITOR_ON_PLAY_EVENT); + SHFrameRateController::ResetDT(); } else if (editorState == State::PAUSE) { diff --git a/SHADE_Engine/src/FRC/SHFramerateController.cpp b/SHADE_Engine/src/FRC/SHFramerateController.cpp index af015531..e504698f 100644 --- a/SHADE_Engine/src/FRC/SHFramerateController.cpp +++ b/SHADE_Engine/src/FRC/SHFramerateController.cpp @@ -32,6 +32,11 @@ namespace SHADE rawDeltaTime = deltaTime.count(); elapsedTime += rawDeltaTime; } + + void SHFrameRateController::ResetDT() noexcept + { + prevFrameTime = std::chrono::high_resolution_clock::now(); + } } //TODO Legacy code. Delete soon diff --git a/SHADE_Engine/src/FRC/SHFramerateController.h b/SHADE_Engine/src/FRC/SHFramerateController.h index f1a8695f..b45745bf 100644 --- a/SHADE_Engine/src/FRC/SHFramerateController.h +++ b/SHADE_Engine/src/FRC/SHFramerateController.h @@ -43,6 +43,8 @@ namespace SHADE //Updates the raw delta time accordingly static void UpdateFRC() noexcept; + static void ResetDT() noexcept; + }; }