Added a troll window with moving close button
This commit is contained in:
30
Assets/Scripts/Windows/TrollWindow.cs
Normal file
30
Assets/Scripts/Windows/TrollWindow.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Windows/TrollWindow.cs.meta
Normal file
3
Assets/Scripts/Windows/TrollWindow.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdeff80fcdb04744b0f3151d7370e6f1
|
||||
timeCreated: 1768419826
|
||||
Reference in New Issue
Block a user