using System;
using System.Collections.Generic;
using UnityEngine;

public sealed class RegularPlanetsView : MonoBehaviour
{
    [SerializeField]
    private GameObject planetPrefab = null;
    [SerializeField]
    private float scale = 1;
    [SerializeField]
    private PlanetData[] planets = new PlanetData[] {
        
        new PlanetData(Vector3.forward * 5, 1),
        new PlanetData(Vector3.back * 7, 2),
        new PlanetData(Vector3.left * 5, 1),
        new PlanetData(Vector3.right * 6, 3),
        new PlanetData(Vector3.forward * 10, 2),
        new PlanetData(Vector3.back * 12, 2),
        new PlanetData(Vector3.left * 16, 4),
        new PlanetData(Vector3.right * 18, 3)
    };

    private List<(Vector3 position, float radius)> positions = new List<(Vector3 position, float radius)>() {
        (Vector3.forward * 5, 1),
        (Vector3.back * 7, 2),
        (Vector3.left * 5, 1),
        (Vector3.right * 6, 3),
        (Vector3.forward * 10, 2),
        (Vector3.back * 12, 2),
        (Vector3.left * 16, 4),
        (Vector3.right * 18, 3),
    };

    [Serializable]
    public sealed class PlanetData {
        [SerializeField]
        public Vector3 Position;
        [SerializeField]
        public float Radius;
        public PlanetData(){}
        public PlanetData(Vector3 position, float radius) {
            Position = position;
            Radius = radius;
        }
    }

    private void Start()
    {
        foreach (var position in positions) {
            CreatePlanet(position.position, position.radius);
        }
    }

    private void CreatePlanet(Vector3 position, float radius)
    {
        var planet = Instantiate(planetPrefab, transform);
        planet.transform.localPosition = position * scale;
        planet.transform.localScale = Vector3.one * radius * scale;
    }
}
