using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace Framework.Utility
{
    // TODO, Comment!
    // TODO, Null Timer
    [Serializable]
    public class UnityTimer
    {
        public string time;

        private float end;
        private float current;
        private bool complete;

        public UnityTimer(float end, bool startComplete)
        {
            this.end = end;
            if (startComplete)
            {
                this.complete = true;
                this.current = end;
            }
            else
            {
                this.complete = false;
                this.current = 0f;
            }
        }

        public void SetEnd(float end)
        {
            this.end = end;
        }

        public void SetComplete(bool complete)
        {
            this.complete = complete;
        }

        public void Advance()
        {
            this.current += Time.smoothDeltaTime;
            this.time = this.current + "/" + this.end;
            if (this.current >= this.end)
                this.complete = true;
        }

        public bool IsComplete()
        {
            return this.complete;
        }

        public float GetCurrent()
        {
            return this.current;
        }

        public float GetEnd()
        {
            return this.end;
        }

        public void Reset()
        {
            this.complete = false;
            this.current = 0f;
        }
    }
}
