using System;
using UnityEngine;
using UnityEngine.UI;

public class EnvArgsChanger : MonoBehaviour
{
    public GameObject DataTransfer;

    [Header("EnemyNum")]
    public Text EnemyNumText;
    public InputField EnemyNumInput;

    [Header("TimeLimit")]
    public Text TimeLimText;
    public InputField TimelimInput;

    [Header("Decision Period")]
    public Slider DecisionPeriodSlide;
    public Text DecisionPeriodDataText;
    public Toggle TakeActionsBetweenDecisionsToggle;

    [Header("Lock Mouse")]
    public Toggle LockMouseToggle;

    [Header("Default Camera")]
    public Toggle FPToggle;
    public Text FPText;
    public Toggle TPToggle;
    public Text TPText;

    private StartSeneData startSeneData;
    private void Start()
    {
        startSeneData = DataTransfer.GetComponent<StartSeneData>();
    }


    public void onEnemynumValueChanged()
    {
        // enemy total num value control
        if (EnemyNumInput.GetComponent<InputField>().text == "" || EnemyNumInput.GetComponent<InputField>().text.Contains("-"))
        {
            EnemyNumText.color = Color.gray;
        }
        else
        {
            EnemyNumText.color = Color.yellow;
            startSeneData.EnemyNum = Math.Abs(int.Parse(EnemyNumInput.GetComponent<InputField>().text));
        }
    }

    public void onTimeValueChanged()
    {
        // time limit value control
        if (TimelimInput.GetComponent<InputField>().text == "" || TimelimInput.GetComponent<InputField>().text.Contains("-"))
        {
            TimeLimText.color = Color.gray;
        }
        else
        {
            TimeLimText.color = Color.yellow;
            startSeneData.Timelim = Math.Abs(int.Parse(TimelimInput.GetComponent<InputField>().text));
        }
    }

    public void onDPSlideValueChanged()
    {
        // DecisionPeriod(DP) value Control
        startSeneData.DecisionPeriod = (int)(DecisionPeriodSlide.GetComponent<Slider>().value);
        DecisionPeriodDataText.text = startSeneData.DecisionPeriod.ToString();
    }
    public void onABDToggleChanged()
    {
        // Actions Between Decisions(ABD) Toggle Control
        startSeneData.ActionsBetweenDecisions = TakeActionsBetweenDecisionsToggle.isOn;
    }
    public void onLockMouseToggleChanged()
    {
        // lock mouse or not
        startSeneData.lockMouse = LockMouseToggle.isOn;
    }
    public void onTPCamToggleChanged()
    {
        startSeneData.defaultTPCamera = true;

        FPToggle.interactable = true;
        FPToggle.SetIsOnWithoutNotify(false);
        FPText.color = Color.gray;

        TPToggle.SetIsOnWithoutNotify(true);
        TPToggle.interactable = false;
        TPText.color = Color.green;
    }
    public void onFPCameToggleChanged()
    {
        startSeneData.defaultTPCamera = false;

        TPToggle.interactable = true;
        TPToggle.SetIsOnWithoutNotify(false);
        TPText.color = Color.gray;

        FPToggle.SetIsOnWithoutNotify(true);
        FPToggle.interactable = false;
        FPText.color = Color.green;
    }
}
