Added a troll window with moving close button

This commit is contained in:
2026-01-14 19:52:54 +00:00
parent f10d0bf7ca
commit 14e6c341e7
4 changed files with 36 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
using UnityEngine;
namespace InterfaceOff
{
public class TrollWindow : WindowBase
{
private int m_Health = int.MaxValue;
public override void OnWindowInstantiation()
{
m_Health = Random.Range(2, 6);
Components.InfoText.text = "TROLL";
}
public override void OnWindowClicked()
{
/* Decreases health and destroys if at 0 */
m_Health--;
if (m_Health <= 0)
{
Destroy(gameObject);
return;
}
/* If not at zero randomly moves the close button */
float randX = Random.Range(-80, 80);
Components.CloseButtonRectTransform.anchoredPosition = new Vector2(randX, 0);
}
}
}