using UnityEngine;

namespace InterfaceOff
{
    public class MovingWindow : WindowBase
    {
        public override void OnWindowInstantiation()
        {
            /* Adds a random advert to the display */
            Advert advert = AdvertRegistry.GetRandomAdvert();
            Components.WindowImage.sprite = advert.Image;
            Components.InfoText.text = advert.Name;
            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 OnWindowCloseButtonClicked()
        {
            Destroy(gameObject);
        }
    }
}