コード例 #1
0
    /// <summary>
    /// ノベル処理開始
    /// </summary>
    public void Execute(NovelCommand.SharedData data = null, NovelCommand.SharedVariable variable = null)
    {
        if (variable == null)
        {
            variable = new NovelCommand.SharedVariable()
            {
                index        = 0,
                handles      = new Dictionary <string, GameObject>(),
                values       = new Dictionary <string, string>(),
                groupValues  = new Dictionary <string, string>(),
                groupHistory = new Queue <NovelHistory.GroupData>(),
            };
        }

        if (data == null)
        {
            data = new NovelCommand.SharedData()
            {
                data   = novelData,
                system = this,
                view   = GetComponent <NovelView>(),
            };
        }

        if (executer == null)
        {
            executer = new NovelExecuter(novelData, commandTypeDic);
        }

        StartCoroutine(RunCoroutine(data, variable));
    }
コード例 #2
0
    public void StartNovel(NovelCommand.CommonData commonData = null, NovelCommand.CommonVariable commonVariable = null)
    {
        this.executer = new NovelExecuter(this.data);

        if (commonVariable == null)
        {
            commonVariable = new NovelCommand.CommonVariable()
            {
                currentIndex = 0
            };
        }

        if (commonData == null)
        {
            // Create Initial Common Data
            commonData = new NovelCommand.CommonData()
            {
                manager = this,
                view    = this.view,
                data    = this.data
            };
        }

        StartCoroutine(RunCoroutine(commonData, commonVariable));
    }
コード例 #3
0
        public IEnumerator Do(SharedData share, SharedVariable variable)
        {
            // メタデータの取得(ない場合は処理できない)
            NovelMetaData.GroupData data;
            if (!share.meta.groupDic.TryGetValue(share.command.parameters[0], out data))
            {
                yield break;
            }

            // 呼び出し履歴確認
            var currentGroup = variable.groupHistory.TryDequeue();
            var nextGroup    = variable.groupHistory.TryPeek();

            // 呼び出し履歴に残っている = 既にPushされている
            if (currentGroup == null)
            {
                // 呼び出し履歴登録
                share.system.history.PushGroup(true, variable.index);
            }

            // 開始位置の決定
            var startIndex = data.startIndex;

            if (currentGroup != null)
            {
                if (nextGroup != null)
                {
                    startIndex += nextGroup.historyID - currentGroup.historyID;
                }
                else
                {
                    // 自分自身(GroupRun)が実行されるとともに履歴に追加されているので、その分を引く
                    var historyID = share.system.history.GetCurrentHistoryID();
                    startIndex += historyID - currentGroup.historyID;
                }
            }

            // 実行準備
            this.executer = new NovelExecuter(share.data, share.system.commandTypeDic);
            this.variable = new SharedVariable()
            {
                // グループ引数はグループ内でしか用いらない変数なので、複製する必要がある
                groupValues  = new Dictionary <string, string>(variable.groupValues),
                groupHistory = variable.groupHistory,
                values       = variable.values,
                handles      = variable.handles,
                index        = startIndex,
            };

            // グループ引数の登録
            var parameterCount = share.command.parameters[1].ParseInt();

            for (int i = 0; i < parameterCount; ++i)
            {
                var name  = share.command.parameters[i * 2 + 2];
                var value = share.command.parameters[i * 2 + 3];
                this.variable.values[name] = value;
            }

            // グループの実行
            yield return(executer.SetupCoroutine(share));

            yield return(executer.RunCoroutine(this.variable, data.endIndex));

            // 呼び出し履歴登録
            share.system.history.PushGroup(false, variable.index);
            yield break;
        }