コード例 #1
0
    IEnumerator RunActions()
    {
        for (actionIndex = 0; actionIndex < actions.Length; actionIndex++)
        {
            switch (actions[actionIndex].type)
            {
            case (BulletActionType.Wait):
                float waitT;
                if (actions[actionIndex].randomWait)
                {
                    waitT = Random.Range(actions[actionIndex].waitTime.x, actions[actionIndex].waitTime.y);
                }
                else
                {
                    waitT = actions[actionIndex].waitTime.x;
                }
                if (actions[actionIndex].rankWait)
                {
                    waitT += BulletManager.instance.rank * actions[actionIndex].waitTime.z;
                }
                waitT *= BulletManager.instance.timePerFrame;
                yield return(new WaitForSeconds(waitT));

                break;

            case (BulletActionType.ChangeDirection):
                if (actions[actionIndex].waitForChange)
                {
                    yield return(StartCoroutine(ChangeDirection(actionIndex)));
                }
                else
                {
                    StartCoroutine(ChangeDirection(actionIndex));
                }
                break;

            case (BulletActionType.ChangeSpeed):
                if (actions[actionIndex].waitForChange)
                {
                    yield return(StartCoroutine(ChangeSpeed(actionIndex, false)));
                }
                else
                {
                    StartCoroutine(ChangeSpeed(actionIndex, false));
                }
                break;

            case (BulletActionType.StartRepeat):
                yield return(StartCoroutine(RunNestedActions()));

                break;

            case (BulletActionType.Fire):
                if (master != null)
                {
                    master.Fire(tform, actions[actionIndex], param, prw);
                }
                break;

            case (BulletActionType.VerticalChangeSpeed):
                if (actions[actionIndex].waitForChange)
                {
                    yield return(StartCoroutine(ChangeSpeed(actionIndex, true)));
                }
                else
                {
                    StartCoroutine(ChangeSpeed(actionIndex, true));
                }
                break;

            case (BulletActionType.Deactivate):
                Deactivate();
                break;
            }
        }
    }