Gave an exit animation to windows

This commit is contained in:
2026-01-19 21:18:50 +00:00
parent 59596fead8
commit e58db7d6af
6 changed files with 23 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections;
using UnityEngine; using UnityEngine;
namespace InterfaceOff namespace InterfaceOff
@@ -55,14 +56,30 @@ namespace InterfaceOff
Components.RectTransform.anchoredPosition = position; // Updates position if it is supposed to change 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 */ /* Default close button closes the window */
public virtual void OnWindowCloseButtonClicked() => DestroyWindow(); public virtual void OnWindowCloseButtonClicked() => DestroyWindow();
public void DestroyWindow() public void DestroyWindow()
{ {
StartCoroutine(routine: DeathSequence());
Creator.AlertOfDespawnedWindow(); 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); Destroy(gameObject);
} }
} }

View File

@@ -4,7 +4,7 @@ namespace InterfaceOff
{ {
public class BasicWindow : WindowBase public class BasicWindow : WindowBase
{ {
public override void OnWindowInstantiation() protected override void OnWindowInstantiation()
{ {
/* Adds a random advert to the display */ /* Adds a random advert to the display */
Advert advert = AdvertRegistry.GetRandomAdvert(); Advert advert = AdvertRegistry.GetRandomAdvert();

View File

@@ -15,7 +15,7 @@ namespace InterfaceOff
private int m_TilesRotatedCorrectly; private int m_TilesRotatedCorrectly;
public override void OnWindowInstantiation() protected override void OnWindowInstantiation()
{ {
/* Lets the player know what to do via text */ /* Lets the player know what to do via text */
Components.InfoText.text = "Rotate"; Components.InfoText.text = "Rotate";

View File

@@ -4,7 +4,7 @@ namespace InterfaceOff
{ {
public class MovingWindow : WindowBase public class MovingWindow : WindowBase
{ {
public override void OnWindowInstantiation() protected override void OnWindowInstantiation()
{ {
/* Adds a random advert to the display */ /* Adds a random advert to the display */
Advert advert = AdvertRegistry.GetRandomAdvert(); Advert advert = AdvertRegistry.GetRandomAdvert();

View File

@@ -45,7 +45,7 @@ namespace InterfaceOff
Trivia = JsonUtility.FromJson<TriviaSet>(json); Trivia = JsonUtility.FromJson<TriviaSet>(json);
} }
public override void OnWindowInstantiation() protected override void OnWindowInstantiation()
{ {
/* Fetches a random question and sets it as the title */ /* Fetches a random question and sets it as the title */
TriviaQuestion question = Trivia.questions[Random.Range(0, Trivia.questions.Length)]; TriviaQuestion question = Trivia.questions[Random.Range(0, Trivia.questions.Length)];

View File

@@ -7,7 +7,7 @@ namespace InterfaceOff
private int m_Health = int.MaxValue; private int m_Health = int.MaxValue;
private bool m_SpawnOnRight; private bool m_SpawnOnRight;
public override void OnWindowInstantiation() protected override void OnWindowInstantiation()
{ {
/* Adds a random advert to the display */ /* Adds a random advert to the display */
Advert advert = AdvertRegistry.GetRandomAdvert(); Advert advert = AdvertRegistry.GetRandomAdvert();