﻿//==================================================================
using UnityEngine;
using System.Collections;
//==================================================================
public partial class ObjectCtrllerIdle : FSMSingleton<ObjectCtrllerIdle>, IFSMState<ObjectCtrllerFSM>
{
    //  VERT_ZIGZAG              /   세로 지그 재그.
    void Pattern_VZIGZAG(ObjectCtrllerFSM caller, string prefabName, int rowIdx, int totCount, int skipOffsetX, float skipOffsetZ = 1f)
    {
        float posZ = caller._startZPos;
        for (int idx = 0; idx < totCount; ++idx)
        {
            int tmpIdx = idx % 2;

            Vector3 pos = new Vector3(_posXLists[rowIdx] + (tmpIdx * skipOffsetX * 2), 0f, posZ);

            if (InstantiateObject(caller, prefabName, pos, Quaternion.identity) == null)
                break;

            posZ += caller._offsetZ * skipOffsetZ;

        }// for (int idx = 0; idx < totCount; ++idx)

    }// void Pattern_VZIGZAG(ObjectCtrllerFSM caller, string prefabName)
    //--------------------------------------
    //  COLUMN_ONE_FULL, VERT_ODD_SKIP    /  세로 1행 전체.
    void Pattern_VOF(ObjectCtrllerFSM caller, string prefabName, int rowIdx, int totCount, float skipOffset = 1f)
    {
        float posZ = caller._startZPos;
        for (int idx = 0; idx < totCount; ++idx)
        {
            Vector3 pos = new Vector3(_posXLists[rowIdx], 0f, posZ);

            if (InstantiateObject(caller, prefabName, pos, Quaternion.identity) == null)
                break;

            posZ += caller._offsetZ * skipOffset;

        }// for (int idx = 0; idx < totCount; ++idx)

    }// void Pattern_VOF(ObjectCtrllerFSM caller, string prefabName)
    //--------------------------------------
    //  V,          /  V.
    void Pattern_V(ObjectCtrllerFSM caller, string prefabName)
    {
        float posZ = caller._startZPos + caller._offsetZ * 3;
        for (int idx = 0; idx < _posXLists.Length; ++idx)
        {
            Vector3 pos = new Vector3(_posXLists[idx], 0f, posZ);

            if (InstantiateObject(caller, prefabName, pos, Quaternion.identity) == null)
                break;

            if ((_posXLists.Length * 0.5f) < (idx + 1))
                posZ += caller._offsetZ;
            else
                posZ -= caller._offsetZ;

        }// for (int idx = 0; idx < _posXLists.Length; ++idx)

    }// void Pattern_REVERSE_V(ObjectCtrllerFSM caller, string prefabName)
    //--------------------------------------
    //  REVERSE_V,  /  역 V.
    void Pattern_REVERSE_V(ObjectCtrllerFSM caller, string prefabName)
    {
        float posZ = caller._startZPos + caller._offsetZ * 3;
        for (int idx = 0; idx < _posXLists.Length; ++idx)
        {
            Vector3 pos = new Vector3(_posXLists[idx], 0f, posZ);

            if (InstantiateObject(caller, prefabName, pos, Quaternion.identity) == null)
                break;

            if ((_posXLists.Length * 0.5f) < (idx + 1))
                posZ -= caller._offsetZ;
            else
                posZ += caller._offsetZ;

        }// for (int idx = 0; idx < _posXLists.Length; ++idx)

    }// void Pattern_V(ObjectCtrllerFSM caller, string prefabName)
    //--------------------------------------
    //  HOR_LTRB            /  좌상우하.
    void Pattern_HLTRB(ObjectCtrllerFSM caller, string prefabName)
    {
        float posZ = caller._startZPos + caller._offsetZ * _posXLists.Length;
        for (int idx = 0; idx < _posXLists.Length; ++idx)
        {
            Vector3 pos = new Vector3(_posXLists[idx], 0f, posZ);

            if (InstantiateObject(caller, prefabName, pos, Quaternion.identity) == null)
                break;

            posZ -= caller._offsetZ;

        }// for (int idx = 0; idx < _posXLists.Length; ++idx)

    }// void Pattern_HLTRB(ObjectCtrllerFSM caller, string prefabName)
    //--------------------------------------
    //  HOR_LBRT,           /  좌하우상.
    void Pattern_HLBRT(ObjectCtrllerFSM caller, string prefabName)
    {
        float posZ = caller._startZPos;
        for (int idx = 0; idx < _posXLists.Length; ++idx)
        {
            Vector3 pos = new Vector3(_posXLists[idx], 0f, posZ);

            if (InstantiateObject(caller, prefabName, pos, Quaternion.identity) == null)
                break;

            posZ += caller._offsetZ;

        }// for (int idx = 0; idx < _posXLists.Length; ++idx)

    }// void Pattern_HLBRT(ObjectCtrllerFSM caller, string prefabName)
    //--------------------------------------
    //  HOR_ZIGZAG              /   가로 지그 재그.
    void Pattern_HZIGZAG(ObjectCtrllerFSM caller, string prefabName)
    {
        for (int idx = 0; idx < _posXLists.Length; ++idx)
        {
            float posZ = caller._startZPos;
            if ((idx % 2).Equals(1))
                posZ += caller._offsetZ;

            Vector3 pos = new Vector3(_posXLists[idx], 0f, posZ);

            if (InstantiateObject(caller, prefabName, pos, Quaternion.identity) == null)
                break;

        }// for (int idx = 0; idx < _posXLists.Length; ++idx)

    }// void Pattern_HZIGZAG(ObjectCtrllerFSM caller, string prefabName)
    //--------------------------------------
    //  HOR_EVEN_ONE_SKIP   /   가로 1열 짝수 스킵.
    void Pattern_HEOS(ObjectCtrllerFSM caller, string prefabName)
    {
        for (int idx = 0; idx < _posXLists.Length;)
        {
            Vector3 pos = new Vector3(_posXLists[idx], 0f, caller._startZPos);

            if (InstantiateObject(caller, prefabName, pos, Quaternion.identity) == null)
                break;

            idx += 2;

        }// for (int idx = 0; idx < _posXLists.Length; ++idx)

    }// void Pattern_HEOS(ObjectCtrllerFSM caller, string prefabName)
    //--------------------------------------
    //  HOR_ODD_ONE_SKIP    /   가로 1열 홀수 스킵.
    void Pattern_HOOS(ObjectCtrllerFSM caller, string prefabName)
    {
        for (int idx = 1; idx < _posXLists.Length;)
        {
            Vector3 pos = new Vector3(_posXLists[idx], 0f, caller._startZPos);

            if (InstantiateObject(caller, prefabName, pos, Quaternion.identity) == null)
                break;

            idx += 2;

        }// for (int idx = 0; idx < _posXLists.Length; ++idx)

    }// void Pattern_HOOS(ObjectCtrllerFSM caller, string prefabName)
    //--------------------------------------
    //  HOR_ONE_FULL        /   가로 1열 전체.
    void Pattern_HOF(ObjectCtrllerFSM caller, string prefabName)
    {
        for (int idx = 0; idx < _posXLists.Length; ++idx)
        {
            Vector3 pos = new Vector3(_posXLists[idx], 0f, caller._startZPos);

            if (InstantiateObject(caller, prefabName, pos, Quaternion.identity) == null)
                break;

        }// for (int idx = 0; idx < _posXLists.Length; ++idx)

    }// void Pattern_HOF( ObjectCtrllerFSM caller, string prefabName )
    //--------------------------------------
    //  RANDOM              /  랜덤.
    void PatternRandom(ObjectCtrllerFSM caller, string prefabName)
    {
        int rndPosXIdx = Random.Range(0, _posXListLength);
        Vector3 pos = new Vector3(_posXLists[rndPosXIdx], 0f, caller._startZPos);

        if (InstantiateObject(caller, prefabName, pos, Quaternion.identity) == null)
            return;

    }// void PatternRandom( ObjectCtrllerFSM caller, string prefabName )
    //--------------------------------------

}//	public class ObjectCtrllerIdle : FSMSingleton<ObjectCtrllerIdle>, IFSMState<ObstacleCtrllerFSM>
//==================================================================