From e58db7d6af51b3db22d940180a176728f8b33e95 Mon Sep 17 00:00:00 2001 From: Pasha Date: Mon, 19 Jan 2026 21:18:50 +0000 Subject: [PATCH] Gave an exit animation to windows --- Assets/Scripts/WindowBase.cs | 19 ++++++++++++++++++- Assets/Scripts/Windows/BasicWindow.cs | 2 +- Assets/Scripts/Windows/ImageWindow.cs | 2 +- Assets/Scripts/Windows/MovingWindow.cs | 2 +- Assets/Scripts/Windows/TriviaWindow.cs | 2 +- Assets/Scripts/Windows/TrollWindow.cs | 2 +- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Assets/Scripts/WindowBase.cs b/Assets/Scripts/WindowBase.cs index c4c2f17..b3aeba9 100644 --- a/Assets/Scripts/WindowBase.cs +++ b/Assets/Scripts/WindowBase.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using UnityEngine; namespace InterfaceOff @@ -55,14 +56,30 @@ namespace InterfaceOff Components.RectTransform.anchoredPosition = position; // Updates position if it is supposed to change } - public virtual void OnWindowInstantiation() { } + protected virtual void OnWindowInstantiation() { } /* Default close button closes the window */ public virtual void OnWindowCloseButtonClicked() => DestroyWindow(); public void DestroyWindow() { + StartCoroutine(routine: DeathSequence()); Creator.AlertOfDespawnedWindow(); + } + + private IEnumerator DeathSequence() + { + float duration = 0f; + while (duration < 1f) + { + duration += Time.deltaTime; + float scale = 1f - duration; + + transform.localScale = new Vector3(scale, scale, 1f); + + yield return null; + } + Destroy(gameObject); } } diff --git a/Assets/Scripts/Windows/BasicWindow.cs b/Assets/Scripts/Windows/BasicWindow.cs index 7ec088a..a6f5f47 100644 --- a/Assets/Scripts/Windows/BasicWindow.cs +++ b/Assets/Scripts/Windows/BasicWindow.cs @@ -4,7 +4,7 @@ namespace InterfaceOff { public class BasicWindow : WindowBase { - public override void OnWindowInstantiation() + protected override void OnWindowInstantiation() { /* Adds a random advert to the display */ Advert advert = AdvertRegistry.GetRandomAdvert(); diff --git a/Assets/Scripts/Windows/ImageWindow.cs b/Assets/Scripts/Windows/ImageWindow.cs index 3825bb2..4aefd29 100644 --- a/Assets/Scripts/Windows/ImageWindow.cs +++ b/Assets/Scripts/Windows/ImageWindow.cs @@ -15,7 +15,7 @@ namespace InterfaceOff private int m_TilesRotatedCorrectly; - public override void OnWindowInstantiation() + protected override void OnWindowInstantiation() { /* Lets the player know what to do via text */ Components.InfoText.text = "Rotate"; diff --git a/Assets/Scripts/Windows/MovingWindow.cs b/Assets/Scripts/Windows/MovingWindow.cs index 7dd5992..d33d35a 100644 --- a/Assets/Scripts/Windows/MovingWindow.cs +++ b/Assets/Scripts/Windows/MovingWindow.cs @@ -4,7 +4,7 @@ namespace InterfaceOff { public class MovingWindow : WindowBase { - public override void OnWindowInstantiation() + protected override void OnWindowInstantiation() { /* Adds a random advert to the display */ Advert advert = AdvertRegistry.GetRandomAdvert(); diff --git a/Assets/Scripts/Windows/TriviaWindow.cs b/Assets/Scripts/Windows/TriviaWindow.cs index 35d0310..3aa47bb 100644 --- a/Assets/Scripts/Windows/TriviaWindow.cs +++ b/Assets/Scripts/Windows/TriviaWindow.cs @@ -45,7 +45,7 @@ namespace InterfaceOff Trivia = JsonUtility.FromJson(json); } - public override void OnWindowInstantiation() + protected override void OnWindowInstantiation() { /* Fetches a random question and sets it as the title */ TriviaQuestion question = Trivia.questions[Random.Range(0, Trivia.questions.Length)]; diff --git a/Assets/Scripts/Windows/TrollWindow.cs b/Assets/Scripts/Windows/TrollWindow.cs index b4c7a7d..081d607 100644 --- a/Assets/Scripts/Windows/TrollWindow.cs +++ b/Assets/Scripts/Windows/TrollWindow.cs @@ -7,7 +7,7 @@ namespace InterfaceOff private int m_Health = int.MaxValue; private bool m_SpawnOnRight; - public override void OnWindowInstantiation() + protected override void OnWindowInstantiation() { /* Adds a random advert to the display */ Advert advert = AdvertRegistry.GetRandomAdvert();