Updated advert registry

This commit is contained in:
Pasha Bibko
2026-01-15 12:09:22 +00:00
parent 4eea7f8836
commit b5ae378453
24 changed files with 280 additions and 267 deletions

View File

@@ -2,16 +2,23 @@
namespace InterfaceOff
{
[System.Serializable]
public struct Advert
{
[field: SerializeField] public string Name { get; private set; }
[field: SerializeField] public Sprite Image { get; private set; }
}
[CreateAssetMenu(fileName = "Advert Registry", menuName = "Custom/Create Advert Registry")]
public class AdvertRegistry : ScriptableObject
{
[field: SerializeField] public Sprite[] m_Adverts;
[field: SerializeField] public Advert[] m_Adverts;
private static AdvertRegistry Instance;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void LoadRegistry() => Instance = Resources.Load<AdvertRegistry>("AdvertRegistry");
public static Sprite GetRandomAdvert()
public static Advert GetRandomAdvert()
{
int index = Random.Range(0, Instance.m_Adverts.Length);
return Instance.m_Adverts[index];

View File

@@ -7,7 +7,9 @@ namespace InterfaceOff
public override void OnWindowInstantiation()
{
/* Adds a random advert to the display */
Components.WindowImage.sprite = AdvertRegistry.GetRandomAdvert();
Advert advert = AdvertRegistry.GetRandomAdvert();
Components.WindowImage.sprite = advert.Image;
Components.InfoText.text = advert.Name;
Components.WindowImage.color = new Color(1, 1, 1, 1);
}

View File

@@ -7,7 +7,9 @@ namespace InterfaceOff
public override void OnWindowInstantiation()
{
/* Adds a random advert to the display */
Components.WindowImage.sprite = AdvertRegistry.GetRandomAdvert();
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 */

View File

@@ -10,7 +10,9 @@ namespace InterfaceOff
public override void OnWindowInstantiation()
{
/* Adds a random advert to the display */
Components.WindowImage.sprite = AdvertRegistry.GetRandomAdvert();
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 health value */