using UnityEngine;

namespace InterfaceOff
{
    public class CanvasManager : MonoBehaviour
    {
        [field: SerializeField] public Canvas GameCanvas { get; private set; }
        [field: SerializeField] public GameObject ImagePrefab { get; private set; }
        [field: SerializeField] public ImageRegistry Images { get; set; }
        
        public static CanvasManager Instance { get; private set; }

        private void Awake()
        {
            if (DebugUtils.IsNull(Instance))
            {
                Instance = this;
                return;
            }
            
            Debug.LogError("Multiple instances of Canvas Manager have been found");
        }

        public static Vector3 GetRandomPositionOnCanvas()
        {
            Rect rect = Instance.GameCanvas.pixelRect;

            float x = Random.Range(rect.xMin + 150, rect.xMax - 150);
            float y = Random.Range(rect.yMin + 150, rect.yMax - 150);

            return new Vector3(x, y, 0f);
        }
    }
}
