using System;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;

public static class TrajectoryBank
{
	private static Sinusoid _linear = new Sinusoid((x) => 0f, 1f, 1f, 0f);
	private static Sinusoid _sin = new Sinusoid((x) => Mathf.Sin(x), 0.3f, 3f, 0.3f);
	private static Sinusoid _cos = new Sinusoid((x) => Mathf.Cos(x), 1f, 1f, 0f);
	private static Sinusoid _pow = new Sinusoid((x) => (x * x) * 0.1f, 1f, 1f, 0f);

	private static List<Func<float, float>> _shapes = new List<Func<float, float>>()
	{
		{ (x) => Mathf.Sin(x) }, // Sin
		{ (x) => Mathf.Cos(x) }, // Cos
		// { (x) => x * x * x * 0.05f  },
		// { (x) => x * x * 0.1f  },
		// { (x) => Mathf.Log(x) }, // Log
		// { (x) => x * x }, // Square
		// { (x) => {
		// 		x = x != 0f ? x : 0.001f;
		// 		return 1f / x;
		// }}
	};

	public static Sinusoid Linear => _linear;

	public static Sinusoid GetRandomCurve()
	{
		int randShapeIndex = Random.Range(0, _shapes.Count);
		Func<float, float> shape = _shapes[randShapeIndex];

		return new Sinusoid(
			shape,
			Random.Range(-0.5f, 0.5f),
			Random.Range(-2f, 2f),
			Random.Range(-2f, 2f)
		);
	}
}
