Cleaned up window base code
This commit is contained in:
@@ -4,28 +4,20 @@ namespace InterfaceOff
|
||||
{
|
||||
public class MovingWindow : WindowBase
|
||||
{
|
||||
private int m_Health = int.MaxValue;
|
||||
|
||||
public override void OnWindowInstantiation()
|
||||
{
|
||||
/* Creates a random health value */
|
||||
m_Health = Random.Range(2, 6);
|
||||
Components.InfoText.text = $"{m_Health}";
|
||||
|
||||
/* Adds a random advert to the display */
|
||||
Components.WindowImage.sprite = AdvertRegistry.GetRandomAdvert();
|
||||
Components.WindowImage.color = new Color(1, 1, 1, 1);
|
||||
|
||||
/* Calculates a random velocity direction */
|
||||
float angle = Random.Range(0, Mathf.PI * 2);
|
||||
Velocity = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)) * 100;
|
||||
}
|
||||
|
||||
public override void OnWindowClicked()
|
||||
public override void OnWindowCloseButtonClicked()
|
||||
{
|
||||
/* Decreases health and destroys if at 0 */
|
||||
m_Health--;
|
||||
Components.InfoText.text = $"{m_Health}";
|
||||
|
||||
if (m_Health <= 0)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user