using System;
using UnityEngine;

public class LevelData : MonoBehaviour
{
    [Header("Level Configuration")]
    public Transform SpawnOne;
    public Transform SpawnTwo;

    public BoardManager ManagerOne;
    public BoardManager ManagerTwo;

    public Transform CameraTarget;

    [SerializeField] private string musicName;

    private void Start()
    {
	    AudioController.PlayMusic(musicName);
    }

    internal Transform GetSpawn(JoyStickInputController player)
    {
        print(SpawnOne.position);
        switch (player.controller)
        {
            case Controller.One:
                return SpawnOne;
            //var vector = SpawnOne.TransformPoint(new Vector3(0, 3, 0));
            //return new Vector3(vector.x, Mathf.Round(vector.y), vector.z);
            case Controller.Two:
                return SpawnTwo;
                //vector = SpawnTwo.TransformPoint(new Vector3(0, 3, 0));
                //return new Vector3(vector.x, Mathf.Round(vector.y), vector.z);
        }
        return null;
    }
    internal void AssignBoardManager(JoyStickInputController player)
    {
        switch (player.controller)
        {
            case Controller.One:
                player.GetComponent<Roll>().boardManager = ManagerOne;
                break;
            case Controller.Two:
                player.GetComponent<Roll>().boardManager = ManagerTwo;
                break;
            default:
	            throw new ArgumentOutOfRangeException();
        }
    }
    internal void AssignCameraTarget(CameraFollower follower)
    {
        follower.SwitchTarget(CameraTarget);
    }
}