public void ChangeBGM(string num)
 {
     _Sound.ChangeBGM(num);
 }
Beispiel #2
0
        // 「変形」コマンド
        private void TransformCommand()
        {
            // MOD START MARGE
            //// If MainWidth <> 15 Then
            //if (GUI.NewGUIMode)
            //{
            //    // MOD END MARGE
            //    Status.ClearUnitStatus();
            //}

            GUI.LockGUI();
            var fdata = SelectedUnit.FeatureData("変形");

            if (Map.IsStatusView)
            {
                // ユニットステータスコマンドの場合
                var forms = GeneralLib.ToL(fdata).Skip(1)
                            .Select(x => SelectedUnit.OtherForm(x))
                            .Where(x => x.IsAvailable())
                            .Select(x => new ListBoxItem
                {
                    ListItemID = x.Name,
                    Text       = x.Nickname0,
                }).ToList();
                var ret = 1;
                if (forms.Count > 1)
                {
                    GUI.TopItem = 1;
                    ret         = GUI.ListBox(new ListBoxArgs
                    {
                        lb_caption = SelectedUnit.IsHero() ? "変身先" : "変形先",
                        lb_info    = "名前",
                        lb_mode    = "カーソル移動",
                        Items      = forms,
                    });

                    if (ret == 0)
                    {
                        CancelCommand();
                        GUI.UnlockGUI();
                        return;
                    }
                }

                var uname      = forms[ret - 1].ListItemID;
                var targetUnit = SRC.UDList.Item(uname);

                // 変形を実施
                var u = SelectedUnit;
                u.Transform(uname);

                // ユニットリストの表示を更新
                Event.MakeUnitList(smode: "");

                // ステータスウィンドウの表示を更新
                Status.DisplayUnitStatus(u.CurrentForm());

                // コマンドを終了
                // XXX RedrawScreen 元はしてなかった気がする
                GUI.RedrawScreen();
                GUI.UnlockGUI();
                CommandState = "ユニット選択";
                return;
            }
            {
                // 変形可能な形態の一覧を作成
                var forms = GeneralLib.ToL(fdata).Skip(1)
                            .Select(x => SelectedUnit.OtherForm(x))
                            .Where(x => x.IsAvailable())
                            .Select(x => new ListBoxItem
                {
                    ListItemID   = x.Name,
                    Text         = x.Nickname0,
                    ListItemFlag = !(x.IsAbleToEnter(SelectedUnit.x, SelectedUnit.y) || Map.IsStatusView)
                }).ToList();
                // 変形先の形態を選択
                int ret;
                if (forms.Count() == 1)
                {
                    if (forms.First().ListItemFlag)
                    {
                        GUI.Confirm("この地形では" + GeneralLib.LIndex(fdata, 1) + "できません", "", GuiConfirmOption.Ok);
                        CancelCommand();
                        GUI.UnlockGUI();
                        return;
                    }

                    ret = 1;
                }
                else
                {
                    GUI.TopItem = 1;
                    ret         = GUI.ListBox(new ListBoxArgs
                    {
                        lb_caption = SelectedUnit.IsHero() ? "変身先" : "変形先",
                        lb_info    = "名前",
                        lb_mode    = "カーソル移動",
                        HasFlag    = true,
                        Items      = forms,
                    });

                    if (ret == 0)
                    {
                        CancelCommand();
                        GUI.UnlockGUI();
                        return;
                    }
                }

                var    uname      = forms[ret - 1].ListItemID;
                var    targetUnit = SRC.UDList.Item(uname);
                string BGM;
                {
                    var u = SelectedUnit;
                    // ダイアログでメッセージを表示させるため追加パイロットをあらかじめ作成
                    AddAdditionalPilotIfNotExist(uname, u);

                    // BGMの変更
                    if (u.IsFeatureAvailable("変形BGM"))
                    {
                        foreach (var fd in u.Features.Where(x => x.Name == "変形BGM")
                                 .Where(x => GeneralLib.LIndex(x.Data, 1) == uname))
                        {
                            BGM = Sound.SearchMidiFile(Strings.Mid(fd.Data, Strings.InStr(fd.Data, " ") + 1));
                            if (Strings.Len(BGM) > 0)
                            {
                                Sound.ChangeBGM(BGM);
                                GUI.Sleep(500);
                            }
                            break;
                        }
                    }

                    // メッセージを表示
                    SelectedUnit.PilotMassageIfDefined(new string[] {
                        "変形(" + u.Name + "=>" + uname + ")",
                        "変形(" + uname + ")",
                        "変形(" + u.FeatureName("変形") + ")",
                    });

                    // アニメ表示
                    SelectedUnit.PlayAnimationIfDefined(new string[] {
                        "変形(" + u.Name + "=>" + uname + ")",
                        "変形(" + uname + ")",
                        "変形(" + u.FeatureName("変形") + ")",
                    });
                }

                // 変形
                var prev_uname = SelectedUnit.Name;
                SelectedUnit.Transform(uname);
                SelectedUnit = Map.MapDataForUnit[SelectedUnit.x, SelectedUnit.y];

                // 変形をキャンセルする?
                if (SelectedUnit.Action == 0)
                {
                    var confirmRet = GUI.Confirm(
                        "この形態ではこれ以上の行動が出来ません。" + Constants.vbCr + Constants.vbLf + "それでも変形しますか?",
                        "変形",
                        GuiConfirmOption.OkCancel | GuiConfirmOption.Question);
                    if (confirmRet == GuiDialogResult.Cancel)
                    {
                        SelectedUnit.Transform(prev_uname);
                        SelectedUnit = Map.MapDataForUnit[SelectedUnit.x, SelectedUnit.y];
                        if (SelectedUnit.IsConditionSatisfied("消耗"))
                        {
                            SelectedUnit.DeleteCondition("消耗");
                        }
                    }

                    GUI.RedrawScreen();
                }

                // 変形イベント
                {
                    Event.HandleEvent("変形", SelectedUnit.CurrentForm().MainPilot().ID, SelectedUnit.CurrentForm().Name);
                }

                if (SRC.IsScenarioFinished)
                {
                    SRC.IsScenarioFinished = false;
                    Status.ClearUnitStatus();
                    GUI.RedrawScreen();
                    CommandState = "ユニット選択";
                    GUI.UnlockGUI();
                    return;
                }

                SRC.IsCanceled = false;

                // ハイパーモード・ノーマルモードの自動発動をチェック
                SelectedUnit.CurrentForm().CheckAutoHyperMode();
                SelectedUnit.CurrentForm().CheckAutoNormalMode();

                // カーソル自動移動
                if (SelectedUnit.Status == "出撃")
                {
                    if (SRC.AutoMoveCursor)
                    {
                        GUI.MoveCursorPos("ユニット選択", SelectedUnit);
                    }

                    Status.DisplayUnitStatus(SelectedUnit);
                }

                // XXX RedrawScreen 元はしてなかった気がする
                GUI.RedrawScreen();
                CommandState = "ユニット選択";
                GUI.UnlockGUI();
            }
        }
Beispiel #3
0
        // 「ハイパーモード」コマンド
        private void HyperModeCommand()
        {
            //// MOD START MARGE
            //// If MainWidth <> 15 Then
            //if (GUI.NewGUIMode)
            //{
            //    // MOD END MARGE
            //    Status.ClearUnitStatus();
            //}

            GUI.LockGUI();
            var uname = GeneralLib.LIndex(SelectedUnit.FeatureData("ハイパーモード"), 2);
            var fname = SelectedUnit.FeatureName("ハイパーモード");

            if (Map.IsStatusView)
            {
                // ユニットステータスコマンドの場合
                if (!SelectedUnit.IsFeatureAvailable("ハイパーモード"))
                {
                    uname = GeneralLib.LIndex(SelectedUnit.FeatureData("ノーマルモード"), 1);
                }

                // ハイパーモードを発動
                SelectedUnit.Transform(uname);

                // ユニットリストの表示を更新
                Event.MakeUnitList(smode: "");

                // ステータスウィンドウの表示を更新
                Status.DisplayUnitStatus(SelectedUnit.CurrentForm());

                // コマンドを終了
                GUI.UnlockGUI();
                CommandState = "ユニット選択";
                return;
            }

            // ハイパーモードを発動可能かどうかチェック
            {
                var withBlock1 = SelectedUnit.OtherForm(uname);
                if (!withBlock1.IsAbleToEnter(SelectedUnit.x, SelectedUnit.y) && !string.IsNullOrEmpty(Map.MapFileName))
                {
                    GUI.Confirm("この地形では変形できません", "", GuiConfirmOption.Ok);
                    GUI.UnlockGUI();
                    CancelCommand();
                    return;
                }
            }

            // ダイアログでメッセージを表示させるため追加パイロットをあらかじめ作成
            AddAdditionalPilotIfNotExist(uname, SelectedUnit);

            {
                // BGMを変更
                if (SelectedUnit.IsFeatureAvailable("ハイパーモードBGM"))
                {
                    var loopTo11 = SelectedUnit.CountFeature();
                    for (var i = 1; i <= loopTo11; i++)
                    {
                        var fdata = SelectedUnit.Feature(i).Data;
                        if (SelectedUnit.Feature(i).Name == "ハイパーモードBGM" &&
                            (GeneralLib.LIndex(fdata, 1) ?? "") == uname)
                        {
                            var BGM = Sound.SearchMidiFile(Strings.Mid(fdata, Strings.InStr(fdata, " ") + 1));
                            if (Strings.Len(BGM) > 0)
                            {
                                Sound.ChangeBGM(BGM);
                                GUI.Sleep(500);
                            }
                            break;
                        }
                    }
                }

                // メッセージを表示
                SelectedUnit.PilotMassageIfDefined(new string[]
                {
                    "ハイパーモード(" + SelectedUnit.Name + "=>" + uname + ")",
                    "ハイパーモード(" + uname + ")",
                    "ハイパーモード(" + fname + ")"
                });

                // アニメ表示
                SelectedUnit.PlayAnimation(new string[] {
                    "ハイパーモード(" + SelectedUnit.Name + "=>" + uname + ")",
                    "ハイパーモード(" + uname + ")",
                    "ハイパーモード(" + fname + ")",
                    "ハイパーモード",
                });
            }

            // ハイパーモード発動
            SelectedUnit.Transform(uname);

            // ハイパーモード・ノーマルモードの自動発動をチェック
            SelectedUnit.CurrentForm().CheckAutoHyperMode();
            SelectedUnit.CurrentForm().CheckAutoNormalMode();
            SelectedUnit = Map.MapDataForUnit[SelectedUnit.x, SelectedUnit.y];

            // 変形イベント
            {
                var withBlock4 = SelectedUnit.CurrentForm();
                Event.HandleEvent("変形", withBlock4.MainPilot().ID, withBlock4.Name);
            }

            if (SRC.IsScenarioFinished)
            {
                SRC.IsScenarioFinished = false;
                Status.ClearUnitStatus();
                GUI.RedrawScreen();
                CommandState = "ユニット選択";
                GUI.UnlockGUI();
                return;
            }

            SRC.IsCanceled = false;

            // カーソル自動移動
            if (SelectedUnit.Status == "出撃")
            {
                if (SRC.AutoMoveCursor)
                {
                    GUI.MoveCursorPos("ユニット選択", SelectedUnit);
                }

                Status.DisplayUnitStatus(SelectedUnit);
            }

            CommandState = "ユニット選択";
            GUI.UnlockGUI();
        }
Beispiel #4
0
        // 「アビリティ」コマンドを開始
        // is_item=True の場合は「アイテム」コマンドによる使い捨てアイテムのアビリティ
        private void StartAbilityCommand(bool is_item = false)
        {
            string cap;

            GUI.LockGUI();

            // 使用するアビリティを選択
            if (is_item)
            {
                cap = "アイテム選択";
            }
            else
            {
                cap = Expression.Term("アビリティ", SelectedUnit) + "選択";
            }

            UnitAbility unitAbility;

            if (CommandState == "コマンド選択")
            {
                unitAbility = GUI.AbilityListBox(SelectedUnit, new UnitAbilityList(AbilityListMode.BeforeMove, SelectedUnit), cap, "移動前", is_item);
            }
            else
            {
                unitAbility = GUI.AbilityListBox(SelectedUnit, new UnitAbilityList(AbilityListMode.AfterMove, SelectedUnit), cap, "移動後", is_item);
            }

            // キャンセル
            if (unitAbility == null)
            {
                SelectedAbility = 0;
                if (SRC.AutoMoveCursor)
                {
                    GUI.RestoreCursorPos();
                }

                CancelCommand();
                GUI.UnlockGUI();
                return;
            }
            SelectedAbility = unitAbility.AbilityNo();

            var currentUnit = SelectedUnit;

            // アビリティ専用BGMがあればそれを演奏
            if (currentUnit.IsFeatureAvailable("アビリティBGM"))
            {
                var BGM = currentUnit.Features.Where(x => x.Name == "アビリティBGM")
                          .Where(x => GeneralLib.LIndex(x.Data, 1) == unitAbility.Data.Name)
                          .Select(x => Sound.SearchMidiFile(Strings.Mid(x.Data, Strings.InStr(x.Data, " ") + 1)))
                          .FirstOrDefault();
                if (!string.IsNullOrEmpty(BGM))
                {
                    Sound.ChangeBGM(BGM);
                }
            }

            // 射程0のアビリティはその場で実行
            if (unitAbility.Data.MaxRange == 0)
            {
                SelectedTarget = SelectedUnit;

                // 変身アビリティであるか判定
                var is_transformation = unitAbility.Data.Effects.Any(x => x.EffectType == "変身");

                SelectedAbilityName = unitAbility.Data.Name;

                // 使用イベント
                Event.HandleEvent("使用", SelectedUnit.MainPilot().ID, SelectedAbilityName);
                if (SRC.IsScenarioFinished)
                {
                    SRC.IsScenarioFinished = false;
                    GUI.UnlockGUI();
                    return;
                }

                if (SRC.IsCanceled)
                {
                    SRC.IsCanceled = false;
                    WaitCommand();
                    return;
                }

                // アビリティを実行
                SelectedUnit.ExecuteAbility(unitAbility, SelectedUnit);
                SelectedUnit = SelectedUnit.CurrentForm();
                GUI.CloseMessageForm();

                // 破壊イベント
                {
                    var withBlock1 = SelectedUnit;
                    if (withBlock1.Status == "破壊")
                    {
                        if (withBlock1.CountPilot() > 0)
                        {
                            Event.HandleEvent("破壊", withBlock1.MainPilot().ID);
                            if (SRC.IsScenarioFinished)
                            {
                                SRC.IsScenarioFinished = false;
                                GUI.UnlockGUI();
                                return;
                            }

                            if (SRC.IsCanceled)
                            {
                                SRC.IsCanceled = false;
                                GUI.UnlockGUI();
                                return;
                            }
                        }

                        WaitCommand();
                        return;
                    }
                }

                // 使用後イベント
                {
                    var withBlock2 = SelectedUnit;
                    if (withBlock2.CountPilot() > 0)
                    {
                        Event.HandleEvent("使用後", withBlock2.MainPilot().ID, SelectedAbilityName);
                        if (SRC.IsScenarioFinished)
                        {
                            SRC.IsScenarioFinished = false;
                            GUI.UnlockGUI();
                            return;
                        }

                        if (SRC.IsCanceled)
                        {
                            SRC.IsCanceled = false;
                            GUI.UnlockGUI();
                            return;
                        }
                    }
                }

                // 変身アビリティの場合は行動終了しない
                if (!is_transformation || CommandState == "移動後コマンド選択")
                {
                    WaitCommand();
                }
                else
                {
                    if (SelectedUnit.Status == "出撃")
                    {
                        // カーソル自動移動
                        if (SRC.AutoMoveCursor)
                        {
                            GUI.MoveCursorPos("ユニット選択", SelectedUnit);
                        }

                        Status.DisplayUnitStatus(SelectedUnit);
                    }
                    else
                    {
                        Status.ClearUnitStatus();
                    }

                    CommandState = "ユニット選択";
                    GUI.UnlockGUI();
                }

                return;
            }

            // アビリティの射程を求めておく
            var min_range = unitAbility.AbilityMinRange();
            var max_range = unitAbility.AbilityMaxRange();

            {
                // マップ型アビリティかどうかで今後のコマンド処理の進行の仕方が異なる
                if (is_item)
                {
                    if (unitAbility.IsAbilityClassifiedAs("M"))
                    {
                        SelectedCommand = "マップアイテム";
                    }
                    else
                    {
                        SelectedCommand = "アイテム";
                    }
                }
                else
                {
                    if (unitAbility.IsAbilityClassifiedAs("M"))
                    {
                        SelectedCommand = "マップアビリティ";
                    }
                    else
                    {
                        SelectedCommand = "アビリティ";
                    }
                }


                // アビリティの効果範囲を設定
                if (unitAbility.IsAbilityClassifiedAs("M直"))
                {
                    Map.AreaInCross(currentUnit.x, currentUnit.y, min_range, max_range);
                }
                else if (unitAbility.IsAbilityClassifiedAs("M拡"))
                {
                    Map.AreaInWideCross(currentUnit.x, currentUnit.y, min_range, max_range);
                }
                else if (unitAbility.IsAbilityClassifiedAs("M扇"))
                {
                    Map.AreaInSectorCross(currentUnit.x, currentUnit.y, min_range, max_range, (int)unitAbility.AbilityLevel("M扇"));
                }
                else if (unitAbility.IsAbilityClassifiedAs("M移"))
                {
                    Map.AreaInMoveAction(SelectedUnit, max_range);
                }
                else
                {
                    Map.AreaInRange(currentUnit.x, currentUnit.y, max_range, min_range, "すべて");
                }

                // 射程1の合体技はパートナーで相手を取り囲んでいないと使用できない
                if (unitAbility.IsAbilityClassifiedAs("合") && !unitAbility.IsAbilityClassifiedAs("M") && unitAbility.Data.MaxRange == 1)
                {
                    foreach (var t in Map.AdjacentUnit(currentUnit))
                    {
                        if (currentUnit.IsAlly(t))
                        {
                            var partners = unitAbility.CombinationPartner(t.x, t.y);
                            if (partners.Count == 0)
                            {
                                Map.MaskData[t.x, t.y] = true;
                            }
                        }
                    }
                }
            }

            // ユニットがいるマスの処理
            if (!unitAbility.IsAbilityClassifiedAs("M投") &&
                !unitAbility.IsAbilityClassifiedAs("M線") &&
                !unitAbility.IsAbilityClassifiedAs("M移"))
            {
                var loopTo2 = GeneralLib.MinLng(currentUnit.x + max_range, Map.MapWidth);
                for (var i = GeneralLib.MaxLng(currentUnit.x - max_range, 1); i <= loopTo2; i++)
                {
                    var loopTo3 = GeneralLib.MinLng(currentUnit.y + max_range, Map.MapHeight);
                    for (var j = GeneralLib.MaxLng(currentUnit.y - max_range, 1); j <= loopTo3; j++)
                    {
                        if (!Map.MaskData[i, j])
                        {
                            var t = Map.MapDataForUnit[i, j];
                            if (t is object)
                            {
                                // 有効?
                                if (unitAbility.IsAbilityEffective(t))
                                {
                                    Map.MaskData[i, j] = false;
                                }
                                else
                                {
                                    Map.MaskData[i, j] = true;
                                }
                            }
                        }
                    }
                }
            }

            // 支援専用アビリティは自分には使用できない
            if (!Map.MaskData[currentUnit.x, currentUnit.y])
            {
                if (unitAbility.IsAbilityClassifiedAs("援"))
                {
                    Map.MaskData[currentUnit.x, currentUnit.y] = true;
                }
            }

            if (!Expression.IsOptionDefined("大型マップ"))
            {
                GUI.Center(currentUnit.x, currentUnit.y);
            }

            GUI.MaskScreen();

            if (CommandState == "コマンド選択")
            {
                CommandState = "ターゲット選択";
            }
            else
            {
                CommandState = "移動後ターゲット選択";
            }

            // カーソル自動移動を行う?
            if (!SRC.AutoMoveCursor)
            {
                GUI.UnlockGUI();
                return;
            }

            // 自分から最も近い味方ユニットを探す
            {
                Unit t = null;
                foreach (Unit u in SRC.UList.Items)
                {
                    if (u.Status == "出撃" && u.Party == "味方")
                    {
                        if (Map.MaskData[u.x, u.y] == false && !ReferenceEquals(u, SelectedUnit))
                        {
                            if (t is null)
                            {
                                t = u;
                            }
                            else if (Math.Pow(Math.Abs((SelectedUnit.x - u.x)), 2d) + Math.Pow(Math.Abs((SelectedUnit.y - u.y)), 2d) < Math.Pow(Math.Abs((SelectedUnit.x - t.x)), 2d) + Math.Pow(Math.Abs((SelectedUnit.y - t.y)), 2d))
                            {
                                t = u;
                            }
                        }
                    }
                }

                // 適当がユニットがなければ自分自身を選択
                if (t is null)
                {
                    t = SelectedUnit;
                }

                // カーソルを移動
                GUI.MoveCursorPos("ユニット選択", t);

                // ターゲットのステータスを表示
                if (!ReferenceEquals(SelectedUnit, t))
                {
                    Status.DisplayUnitStatus(t);
                }
            }
            GUI.UnlockGUI();
        }