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

[CreateAssetMenu(menuName = "Game Settings")]
public class GameSettings : ScriptableObject
{
    [Header("Max Events")]
    [SerializeField] private int[] m_MaxEvents;
    [SerializeField] private float m_MaxEventsFactor;

    [Header("Fail Threshold")]
    [SerializeField] private int[] m_FailThreshold;
    [SerializeField] private float m_FailThresholdFactor;

    [Header("Score Threshold")]
    [SerializeField] private int[] m_ScoreThreshold;
    [SerializeField] private float m_ScoreThresholdFactor;

    [Header("Random events")]
    [SerializeField] private Vector2[] m_RandomEventTimes;

    [Header("Event duration")]
    [SerializeField] private float[] m_EventDuration;

    public int GetMaxEvents(int level)
    {
        if (level - 1 < m_MaxEvents.Length)
            return m_MaxEvents[level - 1];
        else
            return m_MaxEvents[m_MaxEvents.Length - 1] + Mathf.FloorToInt(m_MaxEventsFactor * (level - m_MaxEvents.Length + 1));
    }

    public int GetFailThreshold(int level)
    {
        if (level - 1 < m_FailThreshold.Length)
            return m_FailThreshold[level - 1];
        else
            return m_FailThreshold[m_MaxEvents.Length - 1] + Mathf.FloorToInt(m_FailThresholdFactor * (level - m_FailThreshold.Length + 1));
    }

    public int GetScoreThreshold(int level)
    {
        if (level - 1 < m_ScoreThreshold.Length)
            return m_ScoreThreshold[level - 1];
        else
            return m_ScoreThreshold[m_MaxEvents.Length - 1] + Mathf.FloorToInt(m_ScoreThresholdFactor * (level - m_ScoreThreshold.Length + 1));
    }

    public Vector2 GetRandomEventTimes(int level)
    {
        if (level - 1 < m_RandomEventTimes.Length)
            return m_RandomEventTimes[level - 1];
        else
            return m_RandomEventTimes[m_RandomEventTimes.Length - 1];
    }

    public float GetEventDuration(int level)
    {
        if (level - 1 < m_EventDuration.Length)
            return m_EventDuration[level - 1];
        else
            return m_EventDuration[m_EventDuration.Length - 1];
    }
}
