Example #1
0
        //バイナリ読み込み
        internal void Read(AdvEngine engine, BinaryReader reader)
        {
            this.Clear();
            if (reader.BaseStream.Length <= 0)
            {
                return;
            }

            int version = reader.ReadInt32();

            if (version == Version)
            {
                int count = reader.ReadInt32();
                SubRoutineInfo[] array = new SubRoutineInfo[count];
                for (int i = 0; i < count; i++)
                {
                    array[i] = new SubRoutineInfo(engine, reader);
                }
                for (int i = count - 1; i >= 0; --i)
                {
                    subRoutineCallStack.Push(array[i]);
                }
            }
            else
            {
                Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.UnknownVersion, version));
            }
        }
Example #2
0
 public override void DoCommand(AdvEngine engine)
 {
     if (IsEnable(engine.Param))
     {
         SubRoutineInfo info = new SubRoutineInfo(engine, this.returnLabel, this.scenarioLabel, this.subroutineCommandIndex);
         CurrentTread.JumpManager.RegistoreSubroutine(jumpLabel, info);
     }
 }
Example #3
0
        //サブルーチンの帰り先を見つけて情報を設定
        internal bool TrySetSubroutineRetunInfo(int subroutineCommandIndex, SubRoutineInfo info)
        {
            info.ReturnLabel = ScenarioLabel;

            AdvCommand calledCommand = null;
            int        index         = 0;

            foreach (AdvScenarioPageData page in PageDataList)
            {
                foreach (AdvCommand cmd in page.CommandList)
                {
                    //呼び出し元のコマンドを探す
                    System.Type type = cmd.GetType();
                    if (calledCommand == null)
                    {
                        if (type == typeof(AdvCommandJumpSubroutine) || type == typeof(AdvCommandJumpSubroutineRandom))
                        {
                            if (index == subroutineCommandIndex)
                            {
                                calledCommand = cmd;
                            }
                            else
                            {
                                ++index;
                            }
                        }
                    }
                    else
                    {
                        //呼び出しもとは見つかってるので、飛び先のコマンドを見つける
                        if (calledCommand.GetType() == typeof(AdvCommandJumpSubroutine))
                        {
                            //呼び出し元のコマンドの次のコマンド
                            info.ReturnPageNo  = page.PageNo;
                            info.ReturnCommand = cmd;
                            return(true);
                        }
                        if (calledCommand.GetType() == typeof(AdvCommandJumpSubroutineRandom))
                        {
                            if (type != typeof(AdvCommandJumpSubroutineRandom) && type != typeof(AdvCommandJumpSubroutineRandom))
                            {
                                //ランダムサブルーチンが終わったところ
                                info.ReturnPageNo  = page.PageNo;
                                info.ReturnCommand = cmd;
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Example #4
0
 //登録先にジャンプ
 void JumpToReserved()
 {
     //前回の実行がまだ回ってるかもしれないので止める
     StopAllCoroutines();
     if (JumpManager.SubRoutineReturnInfo != null)
     {
         SubRoutineInfo info = JumpManager.SubRoutineReturnInfo;
         StartCoroutine(CoStartScenario(info.ReturnLabel, info.ReturnPageNo, info.ReturnCommand, false));
     }
     else
     {
         StartCoroutine(CoStartScenario(JumpManager.Label, 0, null, false));
     }
 }
        internal void DoRandomEnd(AdvScenarioThread thread, AdvEngine engine)
        {
            SubRoutineInfo calledInfo = new SubRoutineInfo(engine, this.returnLabel, this.scenarioLabel, this.subroutineCommandIndex);

            thread.JumpManager.RegistoreSubroutine(this.jumpLabel, calledInfo);
        }
Example #6
0
 //サブルーチンを登録
 internal void RegistoreSubroutine(string label, SubRoutineInfo calledInfo)
 {
     this.Label = label;
     subRoutineCallStack.Push(calledInfo);
 }
Example #7
0
        //サブルーチンの帰り先を見つけて情報を設定
        internal void SetSubroutineRetunInfo(string scenarioLabel, int subroutineCommandIndex, SubRoutineInfo info)
        {
            foreach (AdvScenarioData data in scenarioDataTbl.Values)
            {
                AdvScenarioLabelData labelData = data.FindScenarioLabelData(scenarioLabel);
                if (labelData == null)
                {
                    continue;
                }

                if (!labelData.TrySetSubroutineRetunInfo(subroutineCommandIndex, info))
                {
                    AdvScenarioLabelData nextData = NextScenarioLabelData(scenarioLabel);

                    info.ReturnLabel   = nextData.ScenarioLabel;
                    info.ReturnPageNo  = 0;
                    info.ReturnCommand = null;
                }
                break;
            }
        }
        internal void DoRandomEnd(AdvEngine engine)
        {
            SubRoutineInfo info = new SubRoutineInfo(engine, this.returnLabel, this.scenaraioLabel, this.subroutineCommandIndex);

            engine.ScenarioPlayer.JumpManager.RegistoreSubroutine(jumpLabel, info);
        }
Example #9
0
        //サブルーチンの帰り先を見つけて情報を設定
        internal void SetSubroutineRetunInfo(string scenarioLabel, int subroutineCommandIndex, SubRoutineInfo info)
        {
            foreach (AdvScenarioData data in scenarioDataTbl.Values)
            {
                AdvScenarioLabelData labelData = data.FindScenarioLabelData(scenarioLabel);
                if (labelData == null)
                {
                    continue;
                }

                labelData.SetSubroutineRetunInfo(subroutineCommandIndex, info);
                break;
            }
        }
Example #10
0
 //ジャンプしたときにクリアする
 internal void ClearOnJump()
 {
     Label = "";
     SubRoutineReturnInfo = null;
     randomInfoList.Clear();
 }
Example #11
0
 //サブルーチンを終了して、元のページの次のページに戻る
 internal void EndSubroutine()
 {
     this.SubRoutineReturnInfo = subRoutineCallStack.Pop();
 }