Ejemplo n.º 1
0
        public void Perform()
        {
            DDUtils.SetMouseDispMode(true);

            // reset
            {
                //this.SkipMode = false;
                //this.AutoMode = false;

                Surface_吹き出し.Hide = false;
                //Surface_SystemButtons.Hide = false;
            }

            DDCurtain.SetCurtain(0, -1.0);
            DDCurtain.SetCurtain();

restartCurrPage:
            this.CurrPage = this.Status.Scenario.Pages[this.Status.CurrPageIndex];

            foreach (ScenarioCommand command in this.CurrPage.Commands)
            {
                command.Invoke();
            }

            this.DispSubtitleCharCount = 0;
            this.DispCharCount         = 0;
            this.DispPageEndedCount    = 0;
            this.DispFastMode          = false;

            DDEngine.FreezeInput();

            for (; ;)
            {
                bool nextPageFlag = false;

                // ★★★ キー押下は 1 マウス押下は -1 で判定する。

                // 入力:シナリオを進める。(マウスホイール)
                if (DDMouse.Rot < 0)
                {
                    //this.CancelSkipAutoMode(); // 廃止

                    if (this.DispPageEndedCount < NovelConsts.NEXT_PAGE_INPUT_INTERVAL)                     // ? ページ表示_未完了 -> ページ表示_高速化
                    {
                        this.DispFastMode = true;
                    }
                    else                     // ? ページ表示_完了 -> 次ページ
                    {
                        nextPageFlag = true;
                    }
                    DDEngine.FreezeInput(NovelConsts.SHORT_INPUT_SLEEP);
                }

                // 入力:シナリオを進める。(マウスホイール_以外)
                if (
                    DDMouse.L.GetInput() == -1 ||
                    DDInput.A.GetInput() == 1
                    )
                {
                    if (this.DispPageEndedCount < NovelConsts.NEXT_PAGE_INPUT_INTERVAL)                     // ? ページ表示_未完了 -> ページ表示_高速化
                    {
                        this.DispFastMode = true;
                    }
                    else                     // ? ページ表示_完了 -> 次ページ
                    {
                        nextPageFlag = true;
                    }
                }

                // 入力:会話スキップ
                if (DDInput.L.GetInput() == 1 || this.会話スキップ_Request)
                {
                    this.会話スキップ_Request = false;                     // reset

                    if (Ground.I.会話スキップ抑止)
                    {
                        Ground.I.SE.拒否.Play();
                    }
                    else
                    {
                        this.会話スキップした = true;
                        break;
                    }
                }
                if (this.会話終了_Request)
                {
                    break;
                }

                //if (this.SkipMode)
                //    if (1 <= this.DispPageEndedCount)
                //        nextPageFlag = true;

                //if (this.AutoMode)
                //    if (NovelConsts.AUTO_NEXT_PAGE_INTERVAL <= this.DispPageEndedCount)
                //        nextPageFlag = true;

                if (nextPageFlag)                 // 次ページ
                {
                    // スキップモード時はページを進める毎にエフェクトを強制終了する。
                    //if (this.SkipMode)
                    //    foreach (Surface surface in this.Status.Surfaces)
                    //        surface.Act.Clear();

                    this.Status.CurrPageIndex++;

                    if (this.Status.Scenario.Pages.Count <= this.Status.CurrPageIndex)
                    {
                        break;
                    }

                    goto restartCurrPage;
                }

                // 入力:過去ログ
                if (
                    DDInput.DIR_4.GetInput() == 1 ||
                    0 < DDMouse.Rot
                    )
                {
                    this.BackLog();
                }

                // 入力:鑑賞モード
                if (
                    DDMouse.R.GetInput() == -1 ||
                    DDInput.B.GetInput() == 1
                    )
                {
                    this.Appreciate();
                }

                if (
                    this.CurrPage.Subtitle.Length < this.DispSubtitleCharCount &&
                    this.CurrPage.Text.Length < this.DispCharCount
                    )
                {
                    this.DispPageEndedCount++;
                }

                //if (this.SkipMode)
                //{
                //    this.DispSubtitleCharCount += 8;
                //    this.DispCharCount += 8;
                //}
                //else
                if (this.DispFastMode)
                {
                    this.DispSubtitleCharCount += 2;
                    this.DispCharCount         += 2;
                }
                else
                {
                    if (DDEngine.ProcFrame % 2 == 0)
                    {
                        this.DispSubtitleCharCount++;
                    }

                    if (DDEngine.ProcFrame % 3 == 0)
                    {
                        this.DispCharCount++;
                    }
                }
                DDUtils.ToRange(ref this.DispSubtitleCharCount, 0, SCommon.IMAX);
                DDUtils.ToRange(ref this.DispCharCount, 0, SCommon.IMAX);

                // ====
                // 描画ここから
                // ====

                this.DrawSurfaces();

                // ====
                // 描画ここまで
                // ====

                DDEngine.EachFrame();

                // ★★★ ゲームループの終わり ★★★
            }

            DDCurtain.SetCurtain(10, -1.0);
            DDMusicUtils.Fade();

            foreach (DDScene scene in DDSceneUtils.Create(20))
            {
                this.DrawSurfaces();

                DDEngine.EachFrame();
            }

            DDEngine.FreezeInput();

            DDUtils.SetMouseDispMode(false);

            // ★★★ end of Perform() ★★★
        }
Ejemplo n.º 2
0
        public Scenario(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new DDError();
            }

            this.Name = name;
            this.Pages.Clear();

            string[]     lines = ReadScenarioLines(name);
            ScenarioPage page  = null;

            // memo: lines タブスペース除去済み

            for (int index = 0; index < lines.Length; index++)
            {
                string line = lines[index].Trim();

                if (line == "")
                {
                    continue;
                }

                if (line[0] == '#')                 // ? 外部ファイル参照
                {
                    line = line.Substring(1);       // # 除去

                    string[] tokens    = SCommon.Tokenize(line, " ", false, true);
                    string   subName   = tokens[0];
                    string[] arguments = tokens.Skip(1).ToArray();
                    string[] subLines  = ReadScenarioLines(subName);

                    subLines = SolveArguments(subLines, ParseArguments(arguments));

                    lines = lines.Take(index).Concat(subLines).Concat(lines.Skip(index + 1)).ToArray();
                }
            }

            {
                Dictionary <string, string> def_dic = SCommon.CreateDictionary <string>();

                for (int index = 0; index < lines.Length; index++)
                {
                    string line = lines[index].Trim();

                    if (line == "")
                    {
                        continue;
                    }

                    if (line[0] == '^')                     // ? 定義
                    {
                        line = line.Substring(1);           // ^ 除去

                        string[] tokens    = SCommon.Tokenize(line, " ", false, true, 2);
                        string   def_name  = tokens[0];
                        string   def_value = tokens[1];

                        def_dic.Add(def_name, def_value);

                        lines[index] = "";
                    }
                }
                for (int index = 0; index < lines.Length; index++)
                {
                    string line = lines[index];

                    foreach (KeyValuePair <string, string> pair in def_dic)
                    {
                        line = line.Replace(pair.Key, pair.Value);
                    }

                    lines[index] = line;
                }
            }

            bool 読み込み抑止中 = false;

            foreach (string f_line in lines)
            {
                string line = f_line.Trim();

                if (line == "")
                {
                    continue;
                }

                if (line[0] == ';')                 // ? コメント行
                {
                    continue;
                }

                if (line[0] == '/')
                {
                    page = new ScenarioPage()
                    {
                        Subtitle = line.Substring(1)
                    };

                    this.Pages.Add(page);
                }
                else if (page == null)
                {
                    throw new DDError("シナリオの先頭は /xxx でなければなりません。");
                }
                else if (line[0] == '!')                 // ? コマンド
                {
                    string[] tokens = line.Substring(1).Split(' ').Where(v => v != "").ToArray();

                    if (tokens[0] == "_ifndef")
                    {
                        読み込み抑止中 =
                            Novel.I != null &&
                            Novel.I.Status.Surfaces.Any(surface => surface.InstanceName == tokens[1]);
                    }
                    else if (tokens[0] == "_endif")
                    {
                        読み込み抑止中 = false;
                    }
                    else if (読み込み抑止中)
                    {
                    }
                    else
                    {
                        page.Commands.Add(new ScenarioCommand(tokens));
                    }
                }
                else if (読み込み抑止中)
                {
                }
                else
                {
                    page.Lines.Add(line);
                }
            }
        }
Ejemplo n.º 3
0
        public void Perform()
        {
            DDUtils.SetMouseDispMode(true);

            // reset
            {
                this.SkipMode    = false;
                this.AutoMode    = false;
                this.BacklogMode = false;

                Surface_MessageWindow.Hide = false;
                Surface_SystemButtons.Hide = false;
            }

            DDCurtain.SetCurtain(0, -1.0);
            DDCurtain.SetCurtain();

restartCurrPage:
            this.CurrPage = this.Status.Scenario.Pages[this.Status.CurrPageIndex];

            foreach (ScenarioCommand command in this.CurrPage.Commands)
            {
                command.Invoke();
            }

            this.DispSubtitleCharCount = 0;
            this.DispCharCount         = 0;
            this.DispPageEndedCount    = 0;
            this.DispFastMode          = false;

            DDEngine.FreezeInput();

            for (; ;)
            {
                bool nextPageFlag = false;

                // ★★★ キー押下は 1 マウス押下は -1 で判定する。

                // 入力:シナリオを進める。(マウスホイール)
                if (DDMouse.Rot < 0)
                {
                    this.CancelSkipAutoMode();

                    if (this.DispPageEndedCount < NovelConsts.NEXT_PAGE_INPUT_INTERVAL)                     // ? ページ表示_未完了 -> ページ表示_高速化
                    {
                        this.DispFastMode = true;
                    }
                    else                     // ? ページ表示_完了 -> 次ページ
                    {
                        if (!this.Status.HasSelect())
                        {
                            nextPageFlag = true;
                        }
                    }
                    DDEngine.FreezeInput(NovelConsts.SHORT_INPUT_SLEEP);
                }

                // 入力:シナリオを進める。(マウスホイール_以外)
                if (
                    DDMouse.L.GetInput() == -1 && this.SelectedSystemButtonIndex == -1 ||                     // システムボタン以外を左クリック
                    DDInput.A.GetInput() == 1
                    )
                {
                    if (this.DispPageEndedCount < NovelConsts.NEXT_PAGE_INPUT_INTERVAL)                     // ? ページ表示_未完了 -> ページ表示_高速化
                    {
                        this.DispFastMode = true;
                    }
                    else                              // ? ページ表示_完了 -> 次ページ
                    {
                        if (!this.Status.HasSelect()) // ? 選択肢表示中ではない。
                        {
                            nextPageFlag = true;
                        }
                        else                         // ? 選択肢表示中
                        {
                            int index = this.Status.GetSelect().GetMouseFocusedIndex();

                            if (index != -1)                             // 選択中の選択肢へ進む
                            {
                                string scenarioName = this.Status.GetSelect().Options[index].ScenarioName;

                                this.Status.Scenario      = new Scenario(scenarioName);
                                this.Status.CurrPageIndex = 0;
                                this.Status.RemoveSelect();                                 // 選択肢_終了

                                goto restartCurrPage;
                            }
                        }
                    }
                }

                if (this.SkipMode)
                {
                    if (!this.Status.HasSelect())
                    {
                        if (1 <= this.DispPageEndedCount)
                        {
                            nextPageFlag = true;
                        }
                    }
                }

                if (this.AutoMode)
                {
                    if (!this.Status.HasSelect())
                    {
                        if (NovelConsts.AUTO_NEXT_PAGE_INTERVAL <= this.DispPageEndedCount)
                        {
                            nextPageFlag = true;
                        }
                    }
                }

                if (nextPageFlag)                 // 次ページ
                {
                    // スキップモード時はページを進める毎にエフェクトを強制終了する。
                    if (this.SkipMode)
                    {
                        foreach (Surface surface in this.Status.Surfaces)
                        {
                            surface.Act.Flush();
                        }
                    }

                    this.Status.CurrPageIndex++;

                    if (this.Status.Scenario.Pages.Count <= this.Status.CurrPageIndex)
                    {
                        break;
                    }

                    goto restartCurrPage;
                }

                // 入力:過去ログ
                if (
                    DDInput.DIR_4.GetInput() == 1 ||
                    0 < DDMouse.Rot
                    )
                {
                    this.Backlog();
                }

                // 入力:鑑賞モード
                if (
                    DDMouse.R.GetInput() == -1 ||
                    DDInput.B.GetInput() == 1
                    )
                {
                    this.Appreciate();
                }

                // 入力:システムボタン
                if (DDMouse.L.GetInput() == -1 && this.SelectedSystemButtonIndex != -1)                 // システムボタンを左クリック
                {
                    switch (this.SelectedSystemButtonIndex)
                    {
                    case 0: this.SkipMode = !this.SkipMode; break;

                    case 1: this.AutoMode = !this.AutoMode; break;

                    case 2: this.Backlog(); break;

                    case 3: this.SystemMenu(); break;

                    default:
                        throw null;                                 // never
                    }
                    if (this.SystemMenu_ReturnToTitleMenu)
                    {
                        break;
                    }
                }

                if (
                    this.CurrPage.Subtitle.Length < this.DispSubtitleCharCount &&
                    this.CurrPage.Text.Length < this.DispCharCount
                    )
                {
                    this.DispPageEndedCount++;
                }

                if (this.SkipMode)
                {
                    this.DispSubtitleCharCount += 8;
                    this.DispCharCount         += 8;
                }
                else if (this.DispFastMode)
                {
                    this.DispSubtitleCharCount += Ground.I.NovelMessageSpeed;
                    this.DispCharCount         += Ground.I.NovelMessageSpeed;
                }
                else
                {
                    int speed = (NovelConsts.MESSAGE_SPEED_MAX + NovelConsts.MESSAGE_SPEED_MIN) - Ground.I.NovelMessageSpeed;

                    if (DDEngine.ProcFrame % speed == 0)
                    {
                        this.DispSubtitleCharCount++;
                    }

                    if (DDEngine.ProcFrame % (speed + 1) == 0)
                    {
                        this.DispCharCount++;
                    }
                }
                DDUtils.ToRange(ref this.DispSubtitleCharCount, 0, SCommon.IMAX);
                DDUtils.ToRange(ref this.DispCharCount, 0, SCommon.IMAX);

                // ====
                // 描画ここから
                // ====

                this.DrawSurfaces();

                // ====
                // 描画ここまで
                // ====

                DDEngine.EachFrame();

                // ★★★ ゲームループの終わり ★★★
            }

            DDCurtain.SetCurtain(30, -1.0);
            DDMusicUtils.Fade();

            foreach (DDScene scene in DDSceneUtils.Create(40))
            {
                this.DrawSurfaces();

                DDEngine.EachFrame();
            }

            DDEngine.FreezeInput();

            DDUtils.SetMouseDispMode(false);

            // ★★★ end of Perform() ★★★
        }
Ejemplo n.º 4
0
        public Scenario(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new DDError();
            }

            this.Name = name;
            this.Pages.Clear();

            string[]     lines = this.ReadScenarioLines(name);
            ScenarioPage page  = null;

            for (int index = 0; index < lines.Length; index++)
            {
                string line = lines[index].Trim();

                if (line == "")
                {
                    continue;
                }

                if (line[0] == '#')                 // ? 外部ファイル参照
                {
                    string   subName  = line.Substring(1);
                    string[] subLines = this.ReadScenarioLines(subName);

                    lines = lines.Take(index).Concat(subLines).Concat(lines.Skip(index + 1)).ToArray();

                    // HACK: このへん要調整, 問題ないか要チェック
                }
            }

            {
                Dictionary <string, string> def_dic = SCommon.CreateDictionary <string>();

                for (int index = 0; index < lines.Length; index++)
                {
                    string line = lines[index].Trim();

                    if (line == "")
                    {
                        continue;
                    }

                    if (line[0] == '^')                     // ? 定義
                    {
                        line = line.Substring(1);           // ^ 除去

                        string[] tokens    = SCommon.Tokenize(line, " ", false, true, 2);
                        string   def_name  = tokens[0];
                        string   def_value = tokens[1];

                        def_dic.Add(def_name, def_value);

                        lines[index] = "";
                    }
                }
                for (int index = 0; index < lines.Length; index++)
                {
                    string line = lines[index];

                    foreach (KeyValuePair <string, string> pair in def_dic)
                    {
                        line = line.Replace(pair.Key, pair.Value);
                    }

                    lines[index] = line;
                }
            }

            foreach (string f_line in lines)
            {
                string line = f_line.Trim();

                if (line == "")
                {
                    continue;
                }

                if (line[0] == ';')                 // ? コメント行
                {
                    continue;
                }

                if (line[0] == '/')
                {
                    page = new ScenarioPage()
                    {
                        Subtitle = line.Substring(1)
                    };

                    this.Pages.Add(page);
                }
                else if (page == null)
                {
                    throw new DDError("シナリオの先頭は /xxx でなければなりません。");
                }
                else if (line[0] == '!')                 // ? コマンド
                {
                    string[] tokens = line.Substring(1).Split(' ').Where(v => v != "").ToArray();

                    page.Commands.Add(new ScenarioCommand(tokens));
                }
                else
                {
                    page.Lines.Add(line);
                }
            }
            this.各ページの各行の長さ調整();
        }