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

public class FlowManager : MonoBehaviour
{
    public static FlowManager Inst;
    public List<FlowBase> flows;
    public int flowIndex;
    public FlowBase currFlowBase;

    void Start()
    {
        Inst = this;

        StartFlow();
    }

    // Update is called once per frame
    void Update()
    {
        if (currFlowBase != null)
        {
            currFlowBase.UpdateFlow();
        }
    }

    private void StartFlow()
    {
        if (FacadeComponent.Instance.GetController<PointController>() == null)
            FacadeComponent.Instance.CreateController<PointController>().OpenView();
        flowIndex = 0;
        currFlowBase = flows[flowIndex];
    }

    public void NextFlow()
    {
        flowIndex += 1;
        if (flowIndex < flows.Count)
        {
            currFlowBase = flows[flowIndex];
            currFlowBase.StartFlow();
        }
        else
        {
            Debug.Log("Á÷³Ì½áÊø");
        }
    }

    public void LastFlow() { }

    private void EndFlow() { }

    public void CheckCollider(Collider collider, bool isEnter)
    {
        if (currFlowBase.state == FlowBase.FlowState.Collider)
        {
            ((FlowCollider)currFlowBase).CheckPoint(collider, isEnter);
        }
    }
}
