Beispiel #1
0
    void InitPatterns()
    {
        k514RotateOn tmp0 = (k514RotateOn)k514EnemyPatternFactory.CreatePattern <k514RotateOn>(this);

        tmp0.Init(this, Vector3.up);
        patterns.Add(tmp0);

        k514MoveDirect tmp = (k514MoveDirect)k514EnemyPatternFactory.CreatePattern <k514MoveDirect>(this);

        tmp.Init(this, Vector3.forward * 20);
        patterns.Add(tmp);

        tmp = (k514MoveDirect)k514EnemyPatternFactory.CreatePattern <k514MoveDirect>(this);
        tmp.Init(this, new Vector3(40, 0, 20));
        patterns.Add(tmp);

        k514MoveBezier tmp2 = (k514MoveBezier)k514EnemyPatternFactory.CreatePattern <k514MoveBezier>(this);

        tmp2.Init(this, new Vector3(20, 40, 20), new Vector3(40, 60, 40), new Vector3(20, 0, 20), new Vector3(0, 0, 40));
        patterns.Add(tmp2);
    }
Beispiel #2
0
    public void InitPattern(int id)
    {
        this.id          = id;
        transform.parent = null;
        float RandomCubric = 3;
        float Radius1 = Random.Range(7f, 12f), Radius2 = Random.Range(7f, 16f);
        float theta    = Random.Range(-45f, 225f) * Mathf.Deg2Rad;
        float distance = 0f;

        targetPlace  = k514SystemManager.InteractMgr.GetCrossHairTargetTransform();
        targetVector = (targetPlace == null) ? transform.position + Vector3.forward * 30f : targetPlace.position;
        // randomize
        targetVector += new Vector3(Random.Range(-RandomCubric, RandomCubric), Random.Range(-2, 2), Random.Range(-RandomCubric, RandomCubric + 2));

        // get distance
        distance = (transform.position - targetVector).magnitude;

        // add patterns

        List <k514EnemyBehaviour> tmp;
        k514PatternedShot         tmp3 = null;
        k514WaitSec    tmp4            = null;
        k514MoveDirect tmp5            = null;
        Vector3        here            = k514SystemManager.InteractMgr.GetPlayerVector();

        float sin = Mathf.Sin(theta), cos = Mathf.Cos(theta);

        k514MoveBezier tmp2 = (k514MoveBezier)k514EnemyPatternFactory.CreatePattern <k514MoveBezier>(this);

        tmp2.Init(this, here, here + new Vector3(Radius1 * cos, Radius1 * sin, distance * 0.1f), here + new Vector3(Radius2 * cos, Radius2 * sin, distance * 0.66f), targetVector);

        // set Speed
        tmp2.SetSpeed(1000f);
        tmp2.SetLifeSpanCnt(20);
        tmp2.SetMoveTime(0.005f);

        patterns.Add(tmp2);

        ActivateTrig = true;
    }
Beispiel #3
0
    // 생성 패턴 : 모든 targetPlace에서 전방으로 요정 생성.
    protected override IEnumerator spwSequence()
    {
        yield return(null);

        int offset = 100 * k514SystemManager.BlockMgr.nowBlockCount;

        if (!(offset >= GetStart() * 100 && offset <= GetEnd() * 100))
        {
            yield break;
        }
        // coroutine
        WaitForSeconds cooldown = new WaitForSeconds(3f);

        // for raycast
        int        layerMask  = -1;
        int        Radius     = 2;
        int        FIND_RANGE = 60;
        RaycastHit hit;
        bool       isHit = false;
        // for enemy pattern
        Vector3                   start, end;
        k514EnemyController       spawnedEnemy = null;
        List <k514EnemyBehaviour> patterns     = null;
        k514MoveDirect            tmp          = null;

        for (int i = 0; i < targetPlaceDirection.Length; i++)
        {
            targetPlaceDirection[i] = (new Vector3(Random.Range(10f, 70f), -5f, offset + Random.Range(30f, 99f)) - transform.position).normalized;    //(k514SystemManager.InteractMgr.GetCameraCurrentLookVector());
            isHit = Physics.SphereCast(transform.position, Radius, targetPlaceDirection[i], out hit, FIND_RANGE, layerMask);
            if (isHit)
            {
                targetPlace[i]   = hit.point;
                targetPlace[i].y = Random.Range(targetPlace[i].y, 35f);
                sortedTargetPlaceIndex.Add(new KeyValuePair <int, float>(i, targetPlace[i].z));
            }
        }

        // sorting
        sortedTargetPlaceIndex.Sort(Compare);
        //for (int i = 0; i < targetPlaceDirection.Length; i++) Debug.Log(sortedTargetPlaceIndex[i]);


        // regen enemy
        for (int j = 0; j < 1; j++)
        {
            for (int i = 0; i < targetPlace.Length; i++)
            {
                start        = targetPlace[i];
                end          = targetPlace[sortedTargetPlaceIndex[RegenCnt / 2].Key] + new Vector3(Random.Range(-10f, 10f), 0f, Random.Range(-10f, 10f));
                spawnedEnemy = CreateEnemy(ENEMY_TYPE.FAIRY, start);
                patterns     = spawnedEnemy.patterns;
                tmp          = (k514MoveDirect)k514EnemyPatternFactory.CreatePattern <k514MoveDirect>(spawnedEnemy);
                tmp.Init(spawnedEnemy, end);
                patterns.Add(tmp);
                tmp = (k514MoveDirect)k514EnemyPatternFactory.CreatePattern <k514MoveDirect>(spawnedEnemy);
                tmp.Init(spawnedEnemy, start);
                patterns.Add(tmp);
            }
            yield return(cooldown);
        }
    }
Beispiel #4
0
    protected IEnumerator AttackPattern1()
    {
        yield return(null);

        yield return(new WaitForSeconds(firstAttackInterval));

        List <k514EnemyBehaviour> tmp;
        k514MoveBezier            tmp2 = null;
        k514PatternedShot         tmp3 = null;
        k514WaitSec          tmp4      = null;
        k514MoveDirect       tmp5      = null;
        k514PlaySoundPattern tmp6      = null;

        // 반지름 5로 나선형으로 탄막이 6개 펼쳐지는 탄
        int     emit_danmak = 4;
        float   radius = 20f, theta0, theta1, sin0, cos0, sin1, cos1, inversed_emit = 360f / emit_danmak;
        Vector3 here;

        while (true)
        {
            for (int i = 0; i < 5; i++)
            {
                k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_BULLET.SHOT1, false);
                for (int j = 0; j < emit_danmak; j++)
                {
                    // bullet generate
                    bullet                 = k514SystemManager.BulletMgr.CreateBullet <k514PatternedShot>(BULLET_TYPE.TEST2, transform.forward, 0.1f, 5f, null, 12);
                    bullet.position        = here = transform.position;
                    bullet.gameObject.name = "Test2";
                    bullet.parent          = k514SystemManager.BulletMgr.transform;
                    tmp3 = bullet.GetComponent <k514PatternedShot>();

                    // not loop the pattern
                    tmp3.SetLoop(false);

                    // set math factor
                    theta0 = j * inversed_emit * Mathf.Deg2Rad;
                    theta1 = (j * inversed_emit + 30f) * Mathf.Deg2Rad;
                    sin0   = Mathf.Sin(theta0);
                    cos0   = Mathf.Cos(theta0);
                    sin1   = Mathf.Sin(theta1);
                    cos1   = Mathf.Cos(theta1);

                    // get patterns list
                    tmp = tmp3.patterns;

                    // bullet pattern 0 : 나선
                    tmp2 = (k514MoveBezier)k514EnemyPatternFactory.CreatePattern <k514MoveBezier>(tmp3);
                    tmp3.SetInfo(tmp2);
                    tmp2.Init(tmp3, here, here + new Vector3(0.33f * radius * cos1, 0.33f * radius * sin1, 0f), here + new Vector3(0.66f * radius * cos1, 0.66f * radius * sin1, 0f), here + new Vector3(radius * cos0, radius * sin0, 0f), 1f - 0.2f * i);
                    tmp.Add(tmp2);

                    // bullet pattern 1 : 대기
                    tmp4 = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(tmp3);
                    tmp3.SetInfo(tmp4);
                    tmp4.Init(tmp3, 3f - i * 0.3f);
                    tmp.Add(tmp4);

                    if (i == 4)
                    {
                        // bullet pattern 2 : KIRA
                        tmp6 = (k514PlaySoundPattern)k514EnemyPatternFactory.CreatePattern <k514PlaySoundPattern>(tmp3);
                        tmp6.Init(tmp3, SFX_TYPE_EFFECT.KIRA);
                        tmp.Add(tmp6);
                    }

                    // bullet pattern 3 : 대기
                    tmp4 = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(tmp3);
                    tmp3.SetInfo(tmp4);
                    tmp4.Init(tmp3, 0.1f);
                    tmp.Add(tmp4);

                    // bullet pattern 4 : 발사
                    tmp5 = (k514MoveDirect)k514EnemyPatternFactory.CreatePattern <k514MoveDirect>(tmp3);
                    tmp3.SetInfo(tmp5);
                    tmp5.Init_LateMoving(tmp3);
                    tmp.Add(tmp5);

                    // bullet pattern 5 : 대기
                    tmp4 = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(tmp3);
                    tmp3.SetInfo(tmp4);
                    tmp4.Init(tmp3, 0.05f);
                    tmp.Add(tmp4);

                    // regist danmak
                    k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());
                }
                yield return(new WaitForSeconds(0.2f));
            }
            yield return(coolTime);

            yield return(coolTime);
        }
    }
Beispiel #5
0
    // 통상패턴
    IEnumerator NormalPattern()
    {
        yield return(null);

        yield return(new WaitForSeconds(10f));

        WaitForSeconds         cooldown      = new WaitForSeconds(4f);
        WaitForSeconds         shotInterval  = null;
        Transform              bullet        = null;
        k514PatternedShot      patternedShot = null;
        k514BulletBirthPattern moveDirect    = null;
        k514WaitSec            waitPattern   = null;
        k514ChangeScale        scalePattern  = null;
        k514ChangeRotate       rotatePattern = null;
        k514PlaySoundPattern   soundPattern  = null;
        k514MoveDirect         movePattern   = null;
        k514BulletBirthPattern birthPattern  = null;
        k514MoveBezier         bezierPattern = null;

        Vector3 tar;

        List <k514EnemyBehaviour> list;

        while (this.HP > 500)
        {
            for (int i = 0; i < Random.Range(3, 6); i++)
            {
                k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_BULLET.SHOT2, false);
                bullet          = k514SystemManager.BulletMgr.CreateBullet <k514PatternedShot>(BULLET_TYPE.THUNDER, transform.forward, 0.1f, 1f, null, 100);
                bullet.position = transform.position + new Vector3(Random.Range(-14f, 14f), Random.Range(-6f, 6f), 0f);
                bullet.Rotate(Vector3.forward, Random.Range(0f, 180f));
                bullet.gameObject.name = "Thunder";
                bullet.parent          = k514SystemManager.BulletMgr.transform;
                patternedShot          = bullet.GetComponent <k514PatternedShot>();

                // not loop the pattern
                patternedShot.SetLoop(false);

                // get patterns list
                list = patternedShot.patterns;

                // 0.5초 대기
                waitPattern = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(patternedShot);
                patternedShot.SetInfo(waitPattern);
                waitPattern.Init(patternedShot, 0.5f);
                list.Add(waitPattern);


                // 스케일 키우기
                scalePattern = (k514ChangeScale)k514EnemyPatternFactory.CreatePattern <k514ChangeScale>(patternedShot);
                patternedShot.SetInfo(scalePattern);
                scalePattern.Init(patternedShot, new Vector3(1f, 80f, 1f));
                list.Add(scalePattern);

                // 0.5초 대기
                waitPattern = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(patternedShot);
                patternedShot.SetInfo(waitPattern);
                waitPattern.Init(patternedShot, 0.1f);
                list.Add(waitPattern);


                // 회전
                rotatePattern = (k514ChangeRotate)k514EnemyPatternFactory.CreatePattern <k514ChangeRotate>(patternedShot);
                patternedShot.SetInfo(rotatePattern);
                rotatePattern.Init(patternedShot, new Vector3(0f, 0f, 1f), 30f);
                list.Add(rotatePattern);

                k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());

                yield return(new WaitForSeconds(0.1f));
            }
            yield return(cooldown);
        }


//        1스펠 선언 및 체력회복
        k514SystemManager.UI_SpecaMgr.EnemySpellAnimate(0, 2f);
        k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_EFFECT.SPELL_ACTIVE);
        this.HP += 700;


        yield return(new WaitForSeconds(2f));

        cooldown = new WaitForSeconds(8f);

        float theta  = 0f;
        int   step   = 0;
        float radius = 8f;
        float r_step = 0f;

        while (this.HP > 700)
        {
            step = Random.Range(3, 9);

            // 전방사격
            StartCoroutine(ForwardShot());
            yield return(new WaitForSeconds(0.3f));

            k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_EFFECT.KIRA, false);

            for (int i = 0; i < step; i++)
            {
                r_step = 360f / step;
                theta  = i * r_step;
                theta *= Mathf.Deg2Rad;

                bullet          = k514SystemManager.BulletMgr.CreateBullet <k514PatternedShot>(BULLET_TYPE.THUNDER, transform.forward, 0.1f, 1f, null, 100);
                bullet.position = transform.position + radius * new Vector3(Mathf.Cos(theta), Mathf.Sin(theta), 2f);
                bullet.Rotate(Vector3.back, 90f - i * r_step);
                bullet.Rotate(Vector3.right, 90f);
                //bullet.up = k514SystemManager.InteractMgr.GetPlayerHitVectorFrom(bullet.position);
                Debug.Log(bullet.up);
                //bullet.LookAt(transform.position);
                bullet.gameObject.name = "Thunder";
                bullet.parent          = k514SystemManager.BulletMgr.transform;
                patternedShot          = bullet.GetComponent <k514PatternedShot>();


                // not loop the pattern
                patternedShot.SetLoop(false);


                // get patterns list
                list = patternedShot.patterns;


                // 0.2초 대기
                waitPattern = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(patternedShot);
                patternedShot.SetInfo(waitPattern);
                waitPattern.Init(patternedShot, 0.5f);
                list.Add(waitPattern);


                // 스케일 키우기
                scalePattern = (k514ChangeScale)k514EnemyPatternFactory.CreatePattern <k514ChangeScale>(patternedShot);
                patternedShot.SetInfo(scalePattern);
                scalePattern.Init(patternedShot, new Vector3(1f, 80f, 1f));
                list.Add(scalePattern);

                // 0.2초 대기
                waitPattern = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(patternedShot);
                patternedShot.SetInfo(waitPattern);
                waitPattern.Init(patternedShot, 0.2f);
                list.Add(waitPattern);

                if (i == 0)
                {
                    // bullet pattern 2 : KIRA
                    soundPattern = (k514PlaySoundPattern)k514EnemyPatternFactory.CreatePattern <k514PlaySoundPattern>(patternedShot);
                    soundPattern.Init(patternedShot, SFX_TYPE_BULLET.BEAM);
                    list.Add(soundPattern);
                }


                k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());
            }

            yield return(cooldown);
        }



//        통상 2
        while (this.HP > 500)
        {
            StartCoroutine(ForwardShot());

            for (int i = 0; i < Random.Range(5, 8); i++)
            {
                k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_BULLET.SHOT2, false);
                bullet          = k514SystemManager.BulletMgr.CreateBullet <k514PatternedShot>(BULLET_TYPE.THUNDER, transform.forward, 0.1f, 1f, null, 100);
                bullet.position = transform.position + new Vector3(Random.Range(-14f, 14f), Random.Range(-6f, 6f), 0f);
                bullet.Rotate(Vector3.forward, Random.Range(0f, 180f));
                bullet.gameObject.name = "Thunder";
                bullet.parent          = k514SystemManager.BulletMgr.transform;
                patternedShot          = bullet.GetComponent <k514PatternedShot>();

                // not loop the pattern
                patternedShot.SetLoop(false);

                // get patterns list
                list = patternedShot.patterns;

                // 0.5초 대기
                waitPattern = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(patternedShot);
                patternedShot.SetInfo(waitPattern);
                waitPattern.Init(patternedShot, 0.5f);
                list.Add(waitPattern);


                // 스케일 키우기
                scalePattern = (k514ChangeScale)k514EnemyPatternFactory.CreatePattern <k514ChangeScale>(patternedShot);
                patternedShot.SetInfo(scalePattern);
                scalePattern.Init(patternedShot, new Vector3(1f, 80f, 1f));
                list.Add(scalePattern);

                // 0.5초 대기
                waitPattern = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(patternedShot);
                patternedShot.SetInfo(waitPattern);
                waitPattern.Init(patternedShot, 0.1f);
                list.Add(waitPattern);


                // 회전
                rotatePattern = (k514ChangeRotate)k514EnemyPatternFactory.CreatePattern <k514ChangeRotate>(patternedShot);
                patternedShot.SetInfo(rotatePattern);
                rotatePattern.Init(patternedShot, new Vector3(0f, 0f, 1f), 30f);
                list.Add(rotatePattern);

                k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());

                yield return(new WaitForSeconds(0.1f));
            }
            yield return(cooldown);
        }


//        2스펠 선언 및 체력회복
        k514SystemManager.UI_SpecaMgr.EnemySpellAnimate(1, 2f);
        k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_EFFECT.SPELL_ACTIVE);
        this.HP += 700;

        yield return(new WaitForSeconds(2f));

        cooldown     = new WaitForSeconds(3f);
        shotInterval = new WaitForSeconds(0.2f);

        while (this.HP > 700)
        {
            for (int i = 0; i < 5; i++)
            {
                k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_BULLET.SHOT2, true);
                theta  = Random.Range(2f, 12f);
                step   = Random.Range(12, 23);
                radius = Random.Range(-0.23f, 0.23f);
                r_step = theta / step;
                for (int j = 0; j < step; j++)
                {
                    bullet                 = k514SystemManager.BulletMgr.CreateBullet <k514OneDirectionShot>(BULLET_TYPE.SHADOW, ((k514SystemManager.InteractMgr.GetPlayerHitVector() + new Vector3(theta - 2f * j * r_step, radius, 0f) - transform.position)).normalized, 0.05f, 14f);
                    bullet.position        = transform.position;
                    bullet.gameObject.name = "Shadow";
                    bullet.parent          = k514SystemManager.BulletMgr.transform;
                    k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());

                    bullet                 = k514SystemManager.BulletMgr.CreateBullet <k514OneDirectionShot>(BULLET_TYPE.TEST, ((k514SystemManager.InteractMgr.GetPlayerHitVector() + new Vector3(-theta + 2f * j * r_step, -radius, 0f) - transform.position)).normalized, 0.05f, 14f);
                    bullet.position        = transform.position;
                    bullet.gameObject.name = "Test";
                    bullet.parent          = k514SystemManager.BulletMgr.transform;
                    k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());
                    yield return(new WaitForSeconds(0.02f));
                }

                yield return(shotInterval);
            }
            yield return(cooldown);
        }



        cooldown = new WaitForSeconds(5f);
        while (this.HP > 500)
        {
            step = Random.Range(5, 8);
            for (int i = 0; i < step; i++)
            {
                theta = Random.Range(0f, 180f);
                tar   = new Vector3(Random.Range(-14f, 14f), Random.Range(-14f, 14f), 0f);
                k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_EFFECT.KIRA, false);
                bullet          = k514SystemManager.BulletMgr.CreateBullet <k514PatternedShot>(BULLET_TYPE.THUNDER, transform.forward, 0.1f, 1f, null, 100);
                bullet.position = transform.position + tar;
                bullet.Rotate(Vector3.forward, theta);
                bullet.gameObject.name = "Thunder";
                bullet.parent          = k514SystemManager.BulletMgr.transform;
                patternedShot          = bullet.GetComponent <k514PatternedShot>();

                // not loop the pattern
                patternedShot.SetLoop(false);

                // get patterns list
                list = patternedShot.patterns;



                // 스케일 키우기
                scalePattern = (k514ChangeScale)k514EnemyPatternFactory.CreatePattern <k514ChangeScale>(patternedShot);
                patternedShot.SetInfo(scalePattern);
                scalePattern.Init(patternedShot, new Vector3(1f, 80f, 1f));
                list.Add(scalePattern);


                // 회전
                rotatePattern = (k514ChangeRotate)k514EnemyPatternFactory.CreatePattern <k514ChangeRotate>(patternedShot);
                patternedShot.SetInfo(rotatePattern);
                rotatePattern.Init(patternedShot, new Vector3(0f, 0f, 1f), 45f);
                list.Add(rotatePattern);

                k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());


                bullet          = k514SystemManager.BulletMgr.CreateBullet <k514PatternedShot>(BULLET_TYPE.THUNDER, transform.forward, 0.1f, 1f, null, 100);
                bullet.position = transform.position + tar;
                bullet.Rotate(Vector3.forward, theta + 90f);
                bullet.gameObject.name = "Thunder";
                bullet.parent          = k514SystemManager.BulletMgr.transform;
                patternedShot          = bullet.GetComponent <k514PatternedShot>();

                // not loop the pattern
                patternedShot.SetLoop(false);

                // get patterns list
                list = patternedShot.patterns;



                // 스케일 키우기
                scalePattern = (k514ChangeScale)k514EnemyPatternFactory.CreatePattern <k514ChangeScale>(patternedShot);
                patternedShot.SetInfo(scalePattern);
                scalePattern.Init(patternedShot, new Vector3(1f, 80f, 1f));
                list.Add(scalePattern);


                // 회전
                rotatePattern = (k514ChangeRotate)k514EnemyPatternFactory.CreatePattern <k514ChangeRotate>(patternedShot);
                patternedShot.SetInfo(rotatePattern);
                rotatePattern.Init(patternedShot, new Vector3(0f, 0f, 1f), 45f);
                list.Add(rotatePattern);

                k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());


                for (int j = 0; j < 10; j++)
                {
                    bullet                 = k514SystemManager.BulletMgr.CreateBullet <k514OneDirectionShot>(BULLET_TYPE.TEST, ((k514SystemManager.InteractMgr.GetPlayerHitVector() - transform.position)).normalized, 0.05f, 14f);
                    bullet.position        = transform.position + tar + new Vector3(5 - j, 0, 0);
                    bullet.gameObject.name = "Test";
                    bullet.parent          = k514SystemManager.BulletMgr.transform;
                    k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());
                }
                for (int k = 0; k < 10; k++)
                {
                    bullet                 = k514SystemManager.BulletMgr.CreateBullet <k514OneDirectionShot>(BULLET_TYPE.TEST, ((k514SystemManager.InteractMgr.GetPlayerHitVector() - transform.position)).normalized, 0.05f, 14f);
                    bullet.position        = transform.position + tar + new Vector3(0, 5 - k, 0);
                    bullet.gameObject.name = "Test";
                    bullet.parent          = k514SystemManager.BulletMgr.transform;
                    k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());
                }


                yield return(new WaitForSeconds(0.15f));
            }
            yield return(cooldown);
        }



//        3스펠 선언 및 체력회복
        k514SystemManager.UI_SpecaMgr.EnemySpellAnimate(2, 2f);
        k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_EFFECT.SPELL_ACTIVE);
        this.HP += 900;

        yield return(new WaitForSeconds(2f));

        cooldown     = new WaitForSeconds(3f);
        shotInterval = new WaitForSeconds(0.2f);

        while (this.HP > 700)
        {
            k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_EFFECT.KIRA, true);
            for (int i = 0; i < 20; i++)
            {
                bullet          = k514SystemManager.BulletMgr.CreateBullet <k514PatternedShot>(BULLET_TYPE.THUNDER, transform.forward, 0.1f, 1f, null, 100);
                bullet.position = transform.position + Vector3.up * (20f - 2 * i);
                bullet.Rotate(Vector3.back, 90f);
                bullet.gameObject.name = "Thunder";
                bullet.parent          = k514SystemManager.BulletMgr.transform;
                patternedShot          = bullet.GetComponent <k514PatternedShot>();


                // not loop the pattern
                patternedShot.SetLoop(false);


                // get patterns list
                list = patternedShot.patterns;


                // 0.2초 대기
                waitPattern = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(patternedShot);
                patternedShot.SetInfo(waitPattern);
                waitPattern.Init(patternedShot, 0.1f);
                list.Add(waitPattern);


                // 스케일 키우기
                scalePattern = (k514ChangeScale)k514EnemyPatternFactory.CreatePattern <k514ChangeScale>(patternedShot);
                patternedShot.SetInfo(scalePattern);
                scalePattern.Init(patternedShot, new Vector3(0.3f, 80f, 0.3f));
                list.Add(scalePattern);

                // 0.2초 대기
                waitPattern = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(patternedShot);
                patternedShot.SetInfo(waitPattern);
                waitPattern.Init(patternedShot, 0.2f);
                list.Add(waitPattern);

                if (i == 0)
                {
                    // bullet pattern 2 : KIRA
                    soundPattern = (k514PlaySoundPattern)k514EnemyPatternFactory.CreatePattern <k514PlaySoundPattern>(patternedShot);
                    soundPattern.Init(patternedShot, SFX_TYPE_BULLET.BEAM);
                    list.Add(soundPattern);
                }


                //  이동
                movePattern = (k514MoveDirect)k514EnemyPatternFactory.CreatePattern <k514MoveDirect>(patternedShot);
                movePattern.SetSpeed(5f);
                if (i % 2 == 0)
                {
                    movePattern.Init(patternedShot, Vector3.up * 100f);
                }
                else
                {
                    movePattern.Init(patternedShot, Vector3.down * 100f);
                }
                list.Add(movePattern);

                k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());
            }


            for (int i = 0; i < 5; i++)
            {
                k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_BULLET.SHOT2, true);
                theta  = Random.Range(2f, 12f);
                step   = Random.Range(12, 23);
                radius = Random.Range(-0.23f, 0.23f);
                r_step = theta / step;
                for (int j = 0; j < step; j++)
                {
                    bullet                 = k514SystemManager.BulletMgr.CreateBullet <k514OneDirectionShot>(BULLET_TYPE.SHADOW, ((k514SystemManager.InteractMgr.GetPlayerHitVector() + new Vector3(theta - 2f * j * r_step, radius + Random.Range(-0.2f, 0.2f), 0f) - transform.position)).normalized, 0.05f, 14f);
                    bullet.position        = transform.position;
                    bullet.gameObject.name = "Shadow";
                    bullet.parent          = k514SystemManager.BulletMgr.transform;
                    k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());

                    bullet                 = k514SystemManager.BulletMgr.CreateBullet <k514OneDirectionShot>(BULLET_TYPE.SHADOW, ((k514SystemManager.InteractMgr.GetPlayerHitVector() + new Vector3(-theta + 2f * j * r_step, -radius + Random.Range(-0.2f, 0.2f), 0f) - transform.position)).normalized, 0.05f, 14f);
                    bullet.position        = transform.position;
                    bullet.gameObject.name = "Shadow";
                    bullet.parent          = k514SystemManager.BulletMgr.transform;
                    k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());
                    yield return(new WaitForSeconds(0.005f));
                }
                yield return(shotInterval);
            }

            yield return(cooldown);
        }


//    4통상
        cooldown = new WaitForSeconds(5f);
        while (this.HP > 600)
        {
            step = Random.Range(5, 8);
            for (int i = 0; i < step; i++)
            {
                theta = Random.Range(0f, 180f);
                tar   = new Vector3(Random.Range(-14f, 14f), Random.Range(-14f, 14f), 0f);
                k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_EFFECT.KIRA, false);
                bullet          = k514SystemManager.BulletMgr.CreateBullet <k514PatternedShot>(BULLET_TYPE.THUNDER, transform.forward, 0.1f, 1f, null, 100);
                bullet.position = transform.position + tar;
                bullet.Rotate(Vector3.forward, theta);
                bullet.gameObject.name = "Thunder";
                bullet.parent          = k514SystemManager.BulletMgr.transform;
                patternedShot          = bullet.GetComponent <k514PatternedShot>();

                // not loop the pattern
                patternedShot.SetLoop(false);

                // get patterns list
                list = patternedShot.patterns;



                // 스케일 키우기
                scalePattern = (k514ChangeScale)k514EnemyPatternFactory.CreatePattern <k514ChangeScale>(patternedShot);
                patternedShot.SetInfo(scalePattern);
                scalePattern.Init(patternedShot, new Vector3(1f, 80f, 1f));
                list.Add(scalePattern);


                // 회전
                rotatePattern = (k514ChangeRotate)k514EnemyPatternFactory.CreatePattern <k514ChangeRotate>(patternedShot);
                patternedShot.SetInfo(rotatePattern);
                rotatePattern.Init(patternedShot, new Vector3(0f, 0f, 1f), 45f);
                list.Add(rotatePattern);

                k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());


                bullet          = k514SystemManager.BulletMgr.CreateBullet <k514PatternedShot>(BULLET_TYPE.THUNDER, transform.forward, 0.1f, 1f, null, 100);
                bullet.position = transform.position + tar;
                bullet.Rotate(Vector3.forward, theta + 90f);
                bullet.gameObject.name = "Thunder";
                bullet.parent          = k514SystemManager.BulletMgr.transform;
                patternedShot          = bullet.GetComponent <k514PatternedShot>();

                // not loop the pattern
                patternedShot.SetLoop(false);

                // get patterns list
                list = patternedShot.patterns;



                // 스케일 키우기
                scalePattern = (k514ChangeScale)k514EnemyPatternFactory.CreatePattern <k514ChangeScale>(patternedShot);
                patternedShot.SetInfo(scalePattern);
                scalePattern.Init(patternedShot, new Vector3(1f, 80f, 1f));
                list.Add(scalePattern);


                // 회전
                rotatePattern = (k514ChangeRotate)k514EnemyPatternFactory.CreatePattern <k514ChangeRotate>(patternedShot);
                patternedShot.SetInfo(rotatePattern);
                rotatePattern.Init(patternedShot, new Vector3(0f, 0f, 1f), 45f);
                list.Add(rotatePattern);

                k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());


                for (int j = 0; j < 10; j++)
                {
                    bullet                 = k514SystemManager.BulletMgr.CreateBullet <k514OneDirectionShot>(BULLET_TYPE.TEST, ((k514SystemManager.InteractMgr.GetPlayerHitVector() - transform.position)).normalized, 0.05f, 14f);
                    bullet.position        = transform.position + tar + new Vector3(5 - j, 0, 0);
                    bullet.gameObject.name = "Test";
                    bullet.parent          = k514SystemManager.BulletMgr.transform;
                    k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());
                }
                for (int k = 0; k < 10; k++)
                {
                    bullet                 = k514SystemManager.BulletMgr.CreateBullet <k514OneDirectionShot>(BULLET_TYPE.TEST, ((k514SystemManager.InteractMgr.GetPlayerHitVector() - transform.position)).normalized, 0.05f, 14f);
                    bullet.position        = transform.position + tar + new Vector3(0, 5 - k, 0);
                    bullet.gameObject.name = "Test";
                    bullet.parent          = k514SystemManager.BulletMgr.transform;
                    k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());
                }


                yield return(new WaitForSeconds(0.15f));
            }
            yield return(cooldown);
        }



        // 4스펠 선언 및 체력회복
        k514SystemManager.UI_SpecaMgr.EnemySpellAnimate(3, 2f);
        k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_EFFECT.SPELL_ACTIVE);
        this.HP += 900;

        yield return(new WaitForSeconds(2f));

        cooldown     = new WaitForSeconds(3f);
        shotInterval = new WaitForSeconds(0.2f);
        float theta0, theta1, sin0, cos0, sin1, cos1, inversed_emit = 0f;

        // Vail scale down
        SetVail(true);
        Vector3 here;

        k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_EFFECT.MUSOU_START, true);
        float time = 2f, inversedTime = 1f / time;
        float startTime = 0f, normalize = 0f;

        while (startTime < time)
        {
            startTime      += Time.deltaTime;
            normalize       = startTime * inversedTime;
            Vail.localScale = Vector3.Lerp(Vector3.one * 0.1f, Vector3.one * 4f, normalize);
            yield return(null);
        }


        while (this.HP > 700)
        {
            // 나선
            k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_EFFECT.MUSOU_START, false);
            step   = Random.Range(2, 8);
            radius = Random.Range(15, 25);

            for (int i = 0; i < step; i++)
            {
                inversed_emit = 360f / step;
                theta0        = i * inversed_emit * Mathf.Deg2Rad;
                theta1        = (i * inversed_emit + 30f) * Mathf.Deg2Rad;
                sin0          = Mathf.Sin(theta0);
                cos0          = Mathf.Cos(theta0);
                sin1          = Mathf.Sin(theta1);
                cos1          = Mathf.Cos(theta1);


                // gene bullet
                k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_BULLET.SHOT1, false);
                bullet                 = k514SystemManager.BulletMgr.CreateBullet <k514PatternedShot>(BULLET_TYPE.RUMIA, transform.forward, 0.1f, 1f, null, 10);
                bullet.position        = here = transform.position + Vector3.forward * 5f;
                bullet.gameObject.name = "Rumia";
                bullet.parent          = k514SystemManager.BulletMgr.transform;
                patternedShot          = bullet.GetComponent <k514PatternedShot>();

                // not loop the pattern
                patternedShot.SetLoop(false);

                // get patterns list
                list = patternedShot.patterns;

                // bullet pattern 0 : 나선
                bezierPattern = (k514MoveBezier)k514EnemyPatternFactory.CreatePattern <k514MoveBezier>(patternedShot);
                patternedShot.SetInfo(bezierPattern);
                bezierPattern.Init(patternedShot, here, here + new Vector3(0.33f * radius * cos1, 0.33f * radius * sin1, 1f), here + new Vector3(0.66f * radius * cos1, 0.66f * radius * sin1, 2f), here + new Vector3(radius * cos0, radius * sin0, 3f), 1f);
                list.Add(bezierPattern);

                // p1 : birth p
                birthPattern = (k514BulletBirthPattern)k514EnemyPatternFactory.CreatePattern <k514BulletBirthPattern>(patternedShot);
                patternedShot.SetInfo(birthPattern);
                birthPattern.Init(patternedShot);
                list.Add(birthPattern);

                k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());
            }


            yield return(cooldown);
        }

        // Vail scale down
        time         = 2f;
        inversedTime = 1f / time;
        startTime    = 0f;
        normalize    = 0f;
        while (startTime < time)
        {
            startTime      += Time.deltaTime;
            normalize       = startTime * inversedTime;
            Vail.localScale = Vector3.Lerp(Vector3.one * 4f, Vector3.one * 0.1f, normalize);
            yield return(null);
        }

        SetVail(false);
        this.HP += 400;
        yield return(new WaitForSeconds(2f));

        // 5 스펠
        k514SystemManager.UI_SpecaMgr.EnemySpellAnimate(4, 2f);
        k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_EFFECT.SPELL_ACTIVE);
        yield return(new WaitForSeconds(2f));

        cooldown     = new WaitForSeconds(3f);
        shotInterval = new WaitForSeconds(0.2f);
        int clip = -1;

        while (this.HP > 0)
        {
            for (int i = 0; i < 3; i++)
            {
                k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_BULLET.BEAM, true);
                theta  = Random.Range(2f, 12f);
                step   = Random.Range(1, 4);
                radius = Random.Range(-0.23f, 0.23f);
                r_step = theta / step;
                for (int j = 0; j < step; j++)
                {
                    bullet                 = k514SystemManager.BulletMgr.CreateBullet <k514OneDirectionShot>(BULLET_TYPE.RUMIA2, ((k514SystemManager.InteractMgr.GetPlayerHitVector() + new Vector3((theta - 2f * j * r_step) * clip, 0f, 0f) - transform.position)).normalized, 0.05f, 14f);
                    bullet.position        = transform.position;
                    bullet.localScale      = Vector3.one * 0.2f;
                    bullet.gameObject.name = "Rumia2";
                    bullet.parent          = k514SystemManager.BulletMgr.transform;
                    k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());

                    bullet                 = k514SystemManager.BulletMgr.CreateBullet <k514OneDirectionShot>(BULLET_TYPE.RUMIA2, ((k514SystemManager.InteractMgr.GetPlayerHitVector() + new Vector3(0f, (-theta + 2f * j * r_step) * clip, 0f) - transform.position)).normalized, 0.05f, 14f);
                    bullet.position        = transform.position;
                    bullet.localScale      = Vector3.one * 0.2f;
                    bullet.gameObject.name = "Rumia2";
                    bullet.parent          = k514SystemManager.BulletMgr.transform;
                    k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());
                    clip *= -1;
                    yield return(new WaitForSeconds(0.02f));
                }

                yield return(shotInterval);
            }

            int x = 1 + ((int)MAX_HP - (int)HP) / 120;
            Debug.Log(MAX_HP + " : " + HP + " : " + x);
            for (int xi = 0; xi < x; xi++)
            {
                k514SystemManager.SoundMgr.PlayAudioClip(SFX_TYPE_BULLET.SHOT2, false);
                bullet          = k514SystemManager.BulletMgr.CreateBullet <k514PatternedShot>(BULLET_TYPE.THUNDER, transform.forward, 0.1f, 1f, null, 100);
                bullet.position = transform.position + new Vector3(Random.Range(-20f, 20f), Random.Range(-9f, 9f), Random.Range(10f, 20f));
                bullet.Rotate(Vector3.forward, Random.Range(0f, 180f));
                bullet.gameObject.name = "Thunder";
                bullet.parent          = k514SystemManager.BulletMgr.transform;
                patternedShot          = bullet.GetComponent <k514PatternedShot>();

                // not loop the pattern
                patternedShot.SetLoop(false);

                // get patterns list
                list = patternedShot.patterns;

                // 0.5초 대기
                waitPattern = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(patternedShot);
                patternedShot.SetInfo(waitPattern);
                waitPattern.Init(patternedShot, 0.5f);
                list.Add(waitPattern);


                // 스케일 키우기
                scalePattern = (k514ChangeScale)k514EnemyPatternFactory.CreatePattern <k514ChangeScale>(patternedShot);
                patternedShot.SetInfo(scalePattern);
                scalePattern.Init(patternedShot, new Vector3(0.5f, 80f, 0.5f));
                list.Add(scalePattern);

                // 0.5초 대기
                waitPattern = (k514WaitSec)k514EnemyPatternFactory.CreatePattern <k514WaitSec>(patternedShot);
                patternedShot.SetInfo(waitPattern);
                waitPattern.Init(patternedShot, 0.1f);
                list.Add(waitPattern);


                // 회전
                rotatePattern = (k514ChangeRotate)k514EnemyPatternFactory.CreatePattern <k514ChangeRotate>(patternedShot);
                patternedShot.SetInfo(rotatePattern);
                rotatePattern.Init(patternedShot, new Vector3(0f, 0f, Random.Range(-1f, 1f)), 30f);
                list.Add(rotatePattern);

                k514SystemManager.BulletMgr.bulletPool.Add(bullet.GetComponent <k514BulletBridge>());
            }
            yield return(cooldown);
        }
    }