using System;
using UnityEngine;

public static class MathUtil
{
    public static float EaseIn(float startNum, float endNum, float pct)
    {
        return startNum + (endNum - startNum) * (pct * pct);
    }

    public static Vector3 EaseIn(Vector3 start, Vector3 end, float pct)
    {
        return start + (end - start) * (pct * pct);
    }

    public static float EaseIn_Cube(float startNum, float endNum, float pct)
    {
        return startNum + (endNum - startNum) * (pct * pct * pct);
    }

    public static float EaseIn_Pow(float startNum, float endNum, float pct, float pow)
    {
        return startNum + (endNum - startNum) * Mathf.Pow(pct, pow);
    }

    public static float EaseOut(float startNum, float endNum, float pct)
    {
        return startNum + (endNum - startNum) * (1f - (1f - pct) * (1f - pct));
    }

    public static Vector3 EaseOut(Vector3 start, Vector3 end, float pct)
    {
        return start + (end - start) * (1f - (1f - pct) * (1f - pct));
    }

    public static float EaseOut_Cube(float startNum, float endNum, float pct)
    {
        return startNum + (endNum - startNum) * (1f - (1f - pct) * (1f - pct) * (1f - pct));
    }

    public static float EaseOut_Pow(float start, float end, float pct, float pow)
    {
        return start + (end - start) * (1f - Mathf.Pow(1f - pct, pow));
    }

    public static float EaseBoth(float startNum, float endNum, float pct)
    {
        if (pct < 0.5)
        {
            return MathUtil.EaseIn(startNum, (startNum + endNum) / 2f, pct * 2f);
        }
        return MathUtil.EaseOut((startNum + endNum) / 2f, endNum, (pct - 0.5f) * 2f);
    }

    public static Vector3 EaseBoth(Vector3 start, Vector3 end, float pct)
    {
        if (pct < 0.5)
        {
            return MathUtil.EaseIn(start, (start + end) / 2f, pct * 2f);
        }
        return MathUtil.EaseOut((start + end) / 2f, end, (pct - 0.5f) * 2f);
    }

    public static float EaseBoth_Cube(float startNum, float endNum, float pct)
    {
        if (pct < 0.5)
        {
            return MathUtil.EaseIn_Cube(startNum, (startNum + endNum) / 2f, pct * 2f);
        }
        return MathUtil.EaseOut_Cube((startNum + endNum) / 2f, endNum, (pct - 0.5f) * 2f);
    }

    public static float Bump(float startNum, float bumpAmount, float pct)
    {
        if (pct < 0.5)
        {
            return MathUtil.EaseOut(startNum, startNum + bumpAmount, pct * 2f);
        }
        return MathUtil.EaseIn(startNum + bumpAmount, startNum, (pct - 0.5f) * 2f);
    }

    public static float Linear(float startNum, float endNum, float pct)
    {
        return startNum + (endNum - startNum) * pct;
    }

    public static Vector3 Linear(Vector3 start, Vector3 end, float pct)
    {
        return start + (end - start) * pct;
    }

    public static float AvgAngle(float a, float b)
    {
        float num = Math.Abs(a - b);
        float num2;
        if (num < 180f)
        {
            num2 = (a + b) / 2f;
        }
        else
        {
            num2 = (a + b) / 2f + 180f;
        }
        return (num2 + 360f) % 360f;
    }
}
