Cleaned up window base code
This commit is contained in:
@@ -5,25 +5,28 @@ namespace InterfaceOff
|
||||
public class TrollWindow : WindowBase
|
||||
{
|
||||
private int m_Health = int.MaxValue;
|
||||
private bool m_SpawnOnRight = true;
|
||||
|
||||
public override void OnWindowInstantiation()
|
||||
{
|
||||
/* Calculates a random health value */
|
||||
m_Health = Random.Range(2, 6);
|
||||
Components.InfoText.text = "TROLL";
|
||||
}
|
||||
|
||||
public override void OnWindowClicked()
|
||||
public override void OnWindowCloseButtonClicked()
|
||||
{
|
||||
/* Decreases health and destroys if at 0 */
|
||||
m_Health--;
|
||||
if (m_Health <= 0)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
DestroyWindow();
|
||||
return;
|
||||
}
|
||||
|
||||
/* If not at zero randomly moves the close button */
|
||||
float randX = Random.Range(-80, 80);
|
||||
float randX = m_SpawnOnRight ? Random.Range(0, 80) : Random.Range(-80, 0);
|
||||
m_SpawnOnRight = !m_SpawnOnRight; // Makes sure the close button is semi far away
|
||||
|
||||
Components.CloseButtonRectTransform.anchoredPosition = new Vector2(randX, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user