using System.Collections;
using System.Collections.Generic;
using Unicorn.Hitbox;
using UnityEngine;
using NotImplementedException = System.NotImplementedException;

namespace Unicorn.Boss
{
    internal enum UnicornPhase
    {
        Start, P1, P2, P3, End 
    }
    public class Tuna : LivingEntity
    {
        
        private UnicornPhase _unicornPhase = UnicornPhase.Start;
        private Queue<GameObject> _p1Ps = new Queue<GameObject>();
        private const float P1PC = 12;

        public Transform projContainer;
        public GameObject phase1Proj;
        
        
        private void Start()
        {
            StartCoroutine(Started());
        }

        private IEnumerator Started()
        {
            while (_p1Ps.Count < 50)
            {
                for (var i = 0; i < 5 && _p1Ps.Count < 50; i++) //프레임당 5개씩 생성
                {
                    var instantiate = Instantiate(phase1Proj, projContainer);
                    _p1Ps.Enqueue(instantiate);
                    instantiate.SetActive(false);
                }
                yield return new WaitForEndOfFrame();
            }
            StartCoroutine(Phase1());
        }

        private void FixedUpdate()
        {
            
        }

        private IEnumerator Phase1()
        {
            _unicornPhase = UnicornPhase.P1;
            for (int i = 0; i < 360 / P1PC; i++)
            {
                var dequeue = _p1Ps.Dequeue();
                dequeue.SetActive(true);
                dequeue.transform.position = transform.position;
                var rotationEulerAngles = transform.rotation.eulerAngles;
                rotationEulerAngles.z += (360 / P1PC) * i;
                dequeue.transform.rotation = Quaternion.Euler(rotationEulerAngles);
                _p1Ps.Enqueue(dequeue);
            }
            yield return new WaitForSeconds(5);
            StartCoroutine(Phase1());
        }

        protected override void OnKnockback(DamageInfo info)
        {   
            //No KnockBack
        }
    }
}