예제 #1
0
파일: Command.unitsp.cs 프로젝트: 7474/SRC
        // スペシャルパワーコマンドを開始
        private void StartSpecialPowerCommand()
        {
            GUI.LockGUI();
            SelectedCommand = "スペシャルパワー";
            {
                var u = SelectedUnit;

                // スペシャルパワーを使用可能なパイロットの一覧を作成
                var pilots    = u.PilotsHaveSpecialPower();
                var listItems = pilots.Select(p =>
                {
                    return(new ListBoxItem
                    {
                        Text = GeneralLib.RightPaddedString(p.get_Nickname(false), 17)
                               + GeneralLib.RightPaddedString($"{p.SP}/{p.MaxSP}", 8)
                               + string.Join("", Enumerable.Range(1, p.CountSpecialPower).Select(i =>
                        {
                            var sname = p.get_SpecialPower(i);
                            if (p.SP >= p.SpecialPowerCost(sname))
                            {
                                return SRC.SPDList.Item(sname).ShortName;
                            }
                            else
                            {
                                return "";
                            }
                        })),
                    });
                }).ToList();

                GUI.TopItem = 1;
                int i;
                if (pilots.Count > 1)
                {
                    // どのパイロットを使うか選択
                    if (Expression.IsOptionDefined("等身大基準"))
                    {
                        i = GUI.ListBox(new ListBoxArgs
                        {
                            Items      = listItems,
                            HasFlag    = false,
                            lb_caption = "キャラクター選択",
                            lb_info    = "キャラクター     " + Expression.Term("SP", SelectedUnit, 2) + "/Max" + Expression.Term("SP", SelectedUnit, 2),
                            lb_mode    = "連続表示,カーソル移動"
                        });
                    }
                    else
                    {
                        i = GUI.ListBox(new ListBoxArgs
                        {
                            Items      = listItems,
                            HasFlag    = false,
                            lb_caption = "パイロット選択",
                            lb_info    = "パイロット       " + Expression.Term("SP", SelectedUnit, 2) + "/Max" + Expression.Term("SP", SelectedUnit, 2),
                            lb_mode    = "連続表示,カーソル移動"
                        });
                    }
                }
                else
                {
                    // 一人しかいないので選択の必要なし
                    i = 1;
                }

                // 誰もスペシャルパワーを使えなければキャンセル
                if (i == 0)
                {
                    GUI.CloseListBox();
                    if (SRC.AutoMoveCursor)
                    {
                        GUI.RestoreCursorPos();
                    }

                    GUI.UnlockGUI();
                    CancelCommand();
                    return;
                }

                // スペシャルパワーを使うパイロットを設定
                SelectedPilot = pilots[i - 1];
                // そのパイロットのステータスを表示
                if (pilots.Count > 1)
                {
                    Status.DisplayPilotStatus(SelectedPilot);
                }
            }

            {
                var p = SelectedPilot;
                // 使用可能なスペシャルパワーの一覧を作成
                var spList = p.SpecialPowerNames.Select(sname =>
                {
                    var cost = p.SpecialPowerCost(sname);
                    var spd  = SRC.SPDList.Item(sname);

                    return(new ListBoxItem
                    {
                        Text = GeneralLib.RightPaddedString(sname, 13) + GeneralLib.LeftPaddedString("" + cost, 3) + " " + spd.Comment,
                        ListItemFlag = p.SP < cost || !p.IsSpecialPowerUseful(sname),
                    });
                }).ToList();

                // どのコマンドを使用するかを選択
                GUI.TopItem = 1;
                var i = GUI.ListBox(new ListBoxArgs
                {
                    Items      = spList,
                    HasFlag    = true,
                    lb_caption = Expression.Term("スペシャルパワー", SelectedUnit) + "選択",
                    lb_info    = "名称         消費" + Expression.Term("SP", SelectedUnit) + "(" + p.get_Nickname(false) + " " + Expression.Term("SP", SelectedUnit) + "=" + SrcFormatter.Format(p.SP) + "/" + SrcFormatter.Format(p.MaxSP) + ")",
                    lb_mode    = "カーソル移動(行きのみ)"
                });
                // キャンセル
                if (i == 0)
                {
                    Status.DisplayUnitStatus(SelectedUnit);
                    // カーソル自動移動
                    if (SRC.AutoMoveCursor)
                    {
                        GUI.MoveCursorPos("ユニット選択", SelectedUnit);
                    }

                    GUI.UnlockGUI();
                    CancelCommand();
                    return;
                }

                // 使用するスペシャルパワーを設定
                SelectedSpecialPower = SelectedPilot.get_SpecialPower(i);
            }

            // 味方スペシャルパワー実行の効果により他のパイロットが持っているスペシャルパワーを
            // 使う場合は記録しておき、後で消費SPを倍にする必要がある
            // TODO Impl 夢
            //if (SRC.SPDList.Item(SelectedSpecialPower).EffectType(1) == "味方スペシャルパワー実行")
            if (false)
            {
                //// スペシャルパワー一覧
                //list = new string[1];
                //var loopTo6 = SRC.SPDList.Count();
                //for (i = 1; i <= loopTo6; i++)
                //{
                //    {
                //        var withBlock5 = SRC.SPDList.Item(i);
                //        if (withBlock5.EffectType(1) != "味方スペシャルパワー実行" && withBlock5.intName != "非表示")
                //        {
                //            Array.Resize(list, Information.UBound(list) + 1 + 1);
                //            Array.Resize(strkey_list, Information.UBound(list) + 1);
                //            list[Information.UBound(list)] = withBlock5.Name;
                //            strkey_list[Information.UBound(list)] = withBlock5.KanaName;
                //        }
                //    }
                //}

                //GUI.ListItemFlag = new bool[Information.UBound(list) + 1];

                //// ソート
                //var loopTo7 = (Information.UBound(strkey_list) - 1);
                //for (i = 1; i <= loopTo7; i++)
                //{
                //    max_item = i;
                //    max_str = strkey_list[i];
                //    var loopTo8 = Information.UBound(strkey_list);
                //    for (j = (i + 1); j <= loopTo8; j++)
                //    {
                //        if (Strings.StrComp(strkey_list[j], max_str, (CompareMethod)1) == -1)
                //        {
                //            max_item = j;
                //            max_str = strkey_list[j];
                //        }
                //    }

                //    if (max_item != i)
                //    {
                //        buf = list[i];
                //        list[i] = list[max_item];
                //        list[max_item] = buf;
                //        buf = strkey_list[i];
                //        strkey_list[i] = max_str;
                //        strkey_list[max_item] = buf;
                //    }
                //}

                //// スペシャルパワーを使用可能なパイロットがいるかどうかを判定
                //var loopTo9 = Information.UBound(list);
                //for (i = 1; i <= loopTo9; i++)
                //{
                //    GUI.ListItemFlag[i] = true;
                //    foreach (Pilot currentP in SRC.PList)
                //    {
                //        p = currentP;
                //        if (p.Party == "味方")
                //        {
                //            if (p.Unit is object)
                //            {
                //                if (p.Unit.Status == "出撃" && !p.Unit.IsConditionSatisfied("憑依"))
                //                {
                //                    // 本当に乗っている?
                //                    found = false;
                //                    {
                //                        var withBlock6 = p.Unit;
                //                        if (ReferenceEquals(p, withBlock6.MainPilot()))
                //                        {
                //                            found = true;
                //                        }
                //                        else
                //                        {
                //                            var loopTo10 = withBlock6.CountPilot();
                //                            for (j = 2; j <= loopTo10; j++)
                //                            {
                //                                Pilot localPilot1() { object argIndex1 = j; var ret = withBlock6.Pilot(argIndex1); return ret; }

                //                                if (ReferenceEquals(p, localPilot1()))
                //                                {
                //                                    found = true;
                //                                    break;
                //                                }
                //                            }

                //                            var loopTo11 = withBlock6.CountSupport();
                //                            for (j = 1; j <= loopTo11; j++)
                //                            {
                //                                Pilot localSupport() { object argIndex1 = j; var ret = withBlock6.Support(argIndex1); return ret; }

                //                                if (ReferenceEquals(p, localSupport()))
                //                                {
                //                                    found = true;
                //                                    break;
                //                                }
                //                            }

                //                            if (ReferenceEquals(p, withBlock6.AdditionalSupport()))
                //                            {
                //                                found = true;
                //                            }
                //                        }
                //                    }

                //                    if (found)
                //                    {
                //                        if (p.IsSpecialPowerAvailable(list[i]))
                //                        {
                //                            GUI.ListItemFlag[i] = false;
                //                            break;
                //                        }
                //                    }
                //                }
                //            }
                //        }
                //    }
                //}

                //// 各スペシャルパワーが使用可能か判定
                //{
                //    var withBlock7 = SelectedPilot;
                //    var loopTo12 = Information.UBound(list);
                //    for (i = 1; i <= loopTo12; i++)
                //    {
                //        if (!GUI.ListItemFlag[i] && withBlock7.SP >= 2 * withBlock7.SpecialPowerCost(list[i]))
                //        {
                //            if (!withBlock7.IsSpecialPowerUseful(list[i]))
                //            {
                //                GUI.ListItemFlag[i] = true;
                //            }
                //        }
                //        else
                //        {
                //            GUI.ListItemFlag[i] = true;
                //        }
                //    }
                //}

                //// スペシャルパワーの解説を設定
                //GUI.ListItemComment = new string[Information.UBound(list) + 1];
                //var loopTo13 = Information.UBound(list);
                //for (i = 1; i <= loopTo13; i++)
                //{
                //    SpecialPowerData localItem4() { var tmp = list; object argIndex1 = tmp[i]; var ret = SRC.SPDList.Item(argIndex1); return ret; }

                //    GUI.ListItemComment[i] = localItem4().Comment;
                //}

                //// 検索するスペシャルパワーを選択
                //GUI.TopItem = 1;
                //ret = GUI.MultiColumnListBox(Expression.Term(argtname7, u: argu) + "検索", list, true);
                //if (ret == 0)
                //{
                //    SelectedSpecialPower = "";
                //    CancelCommand();
                //    GUI.UnlockGUI();
                //    return;
                //}

                //// スペシャルパワー使用メッセージ
                //if (SelectedUnit.IsMessageDefined(SelectedSpecialPower))
                //{
                //    GUI.OpenMessageForm(u1: null1, u2: null2);
                //    SelectedUnit.PilotMessage(SelectedSpecialPower, msg_mode: "");
                //    GUI.CloseMessageForm();
                //}

                //SelectedSpecialPower = list[ret];
                //WithDoubleSPConsumption = true;
            }
            else
            {
                WithDoubleSPConsumption = false;
            }

            var sd = SRC.SPDList.Item(SelectedSpecialPower);

            // ターゲットを選択する必要があるスペシャルパワーの場合
            switch (sd.TargetType ?? "")
            {
            case "味方":
            case "敵":
            case "任意":
            {
                // マップ上のユニットからターゲットを選択する
                GUI.OpenMessageForm(null, null);
                GUI.DisplaySysMessage(SelectedPilot.get_Nickname(false) + "は" + SelectedSpecialPower + "を使った。;" + "ターゲットを選んでください。");
                GUI.CloseMessageForm();

                // ターゲットのエリアを設定
                for (var i = 1; i <= Map.MapWidth; i++)
                {
                    for (var j = 1; j <= Map.MapHeight; j++)
                    {
                        Map.MaskData[i, j] = true;
                        var u = Map.MapDataForUnit[i, j];
                        if (u is null)
                        {
                            goto NextLoop;
                        }

                        // 陣営が合っている?
                        switch (sd.TargetType ?? "")
                        {
                        case "味方":
                        {
                            {
                                var withBlock8 = u;
                                if (withBlock8.Party != "味方" && withBlock8.Party0 != "味方" && withBlock8.Party != "NPC" && withBlock8.Party0 != "NPC")
                                {
                                    goto NextLoop;
                                }
                            }

                            break;
                        }

                        case "敵":
                        {
                            {
                                var withBlock9 = u;
                                if (withBlock9.Party == "味方" && withBlock9.Party0 == "味方" || withBlock9.Party == "NPC" && withBlock9.Party0 == "NPC")
                                {
                                    goto NextLoop;
                                }
                            }

                            break;
                        }
                        }

                        // スペシャルパワーを適用可能?
                        if (!sd.Effective(SelectedPilot, u))
                        {
                            goto NextLoop;
                        }

                        Map.MaskData[i, j] = false;
NextLoop:
                        ;
                    }
                }

                GUI.MaskScreen();
                CommandState = "ターゲット選択";
                GUI.UnlockGUI();
                return;
            }

            case "破壊味方":
            {
                // 破壊された味方ユニットの中からターゲットを選択する
                GUI.OpenMessageForm(null, null);
                GUI.DisplaySysMessage(SelectedPilot.get_Nickname(false) + "は" + SelectedSpecialPower + "を使った。;" + "復活させるユニットを選んでください。");
                GUI.CloseMessageForm();

                // 破壊された味方ユニットのリストを作成
                var units = SRC.UList.Items
                            .Where(u => u.Party0 == "味方" && u.Status == "破壊" && (u.CountPilot() > 0 || u.Data.PilotNum == 0))
                            .Select(u => new ListBoxItem
                    {
                        Text = GeneralLib.RightPaddedString(u.Nickname, 28)
                               + GeneralLib.RightPaddedString(u.MainPilot().get_Nickname(false), 18)
                               + GeneralLib.LeftPaddedString(SrcFormatter.Format(u.MainPilot().Level), 3),
                        ListItemID = u.ID,
                    }).ToList();

                GUI.TopItem = 1;
                var ret = GUI.ListBox(new ListBoxArgs
                    {
                        Items      = units,
                        lb_caption = "ユニット選択",
                        lb_info    = "ユニット名                  パイロット     レベル",
                        lb_mode    = "",
                    });

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

                SelectedTarget = SRC.UList.Item(units[ret - 1].ListItemID);
                break;
            }
            }

            // 自爆を選択した場合は確認を取る
            if (sd.IsEffectAvailable("自爆"))
            {
                var ret = GUI.Confirm("自爆させますか?", "自爆", GuiConfirmOption.OkCancel | GuiConfirmOption.Question);
                if (ret == GuiDialogResult.Ok)
                {
                    GUI.UnlockGUI();
                    return;
                }
            }

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

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

            // スペシャルパワーを使用
            if (WithDoubleSPConsumption)
            {
                SelectedPilot.UseSpecialPower(SelectedSpecialPower, 2d);
            }
            else
            {
                SelectedPilot.UseSpecialPower(SelectedSpecialPower);
            }

            SelectedUnit = SelectedUnit.CurrentForm();

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

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

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

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

            SelectedSpecialPower = "";
            GUI.UnlockGUI();
            CommandState = "ユニット選択";
        }
예제 #2
0
파일: Command.unitsp.cs 프로젝트: 7474/SRC
        // スペシャルパワーコマンドを終了
        private void FinishSpecialPowerCommand()
        {
            GUI.LockGUI();

            // 自爆を選択した場合は確認を取る
            {
                var spd = SRC.SPDList.Item(SelectedSpecialPower);
                if (spd.Effects.Any(x => x.strEffectType == "自爆"))
                {
                    if (GUI.Confirm("自爆させますか?", "自爆", GuiConfirmOption.OkCancel | GuiConfirmOption.Question) != GuiDialogResult.Ok)
                    {
                        CommandState = "ユニット選択";
                        GUI.UnlockGUI();
                        return;
                    }
                }
            }

            // 使用イベント
            Event.HandleEvent("使用", SelectedUnit.MainPilot().ID, SelectedSpecialPower);
            if (SRC.IsScenarioFinished)
            {
                SRC.IsScenarioFinished = false;
                CommandState           = "ユニット選択";
                GUI.UnlockGUI();
                return;
            }

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

            // スペシャルパワーを使用
            if (WithDoubleSPConsumption)
            {
                SelectedPilot.UseSpecialPower(SelectedSpecialPower, 2d);
            }
            else
            {
                SelectedPilot.UseSpecialPower(SelectedSpecialPower);
            }

            SelectedUnit = SelectedUnit.CurrentForm();

            // ステータスウィンドウを更新
            if (SelectedTarget is object)
            {
                if (SelectedTarget.CurrentForm().Status == "出撃")
                {
                    Status.DisplayUnitStatus(SelectedTarget);
                }
            }

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

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

            SelectedSpecialPower = "";
            GUI.UnlockGUI();
            CommandState = "ユニット選択";
        }
예제 #3
0
        // 「換装」コマンド
        public void ExchangeFormCommand()
        {
            GUI.LockGUI();
            var fd = SelectedUnit.Feature("換装");

            // 選択可能な換装先のリストを作成
            var uList = fd.DataL.Select(x => SelectedUnit.OtherForm(x))
                        .Where(x => x.IsAvailable())
                        .Select(u =>
            {
                // 各形態の表示内容を作成
                var msg = "";
                msg    += (u.Nickname == SelectedUnit.Nickname0)
                        ? GeneralLib.RightPaddedString(u.Name, 27)
                        : GeneralLib.RightPaddedString(u.Nickname0, 27);
                // ユニットに関する情報
                msg += GeneralLib.LeftPaddedString(SrcFormatter.Format(u.MaxHP), 6);
                msg += GeneralLib.LeftPaddedString(SrcFormatter.Format(u.MaxEN), 5);
                msg += GeneralLib.LeftPaddedString(SrcFormatter.Format(u.get_Armor("")), 5);
                msg += GeneralLib.LeftPaddedString(SrcFormatter.Format(u.get_Mobility("")), 5);

                var weapons = u.Weapons.Where(uw => uw.IsDisplayFor(WeaponListMode.List)).ToList();
                // 最大攻撃力
                var maxPower = weapons.Max(uw => uw.WeaponPower(""));
                msg         += GeneralLib.LeftPaddedString("" + maxPower, 7);
                // 最大射程
                var maxRange = weapons.Max(uw => uw.WeaponMaxRange());
                msg         += GeneralLib.LeftPaddedString("" + maxRange, 5);

                // 換装先が持つ特殊能力一覧
                var comment = string.Join(" ", u.Features
                                          .Select(fd => fd.FeatureName(u))
                                          .Where(x => !string.IsNullOrEmpty(x))
                                          .Distinct());
                return(new ListBoxItem(msg, u.ID)
                {
                    ListItemComment = comment,
                });
            })
                        .ToList();

            // どの形態に換装するかを選択
            GUI.TopItem = 1;
            var tfRet = GUI.ListBox(new ListBoxArgs
            {
                Items      = uList,
                lb_caption = "変更先選択",
                lb_info    = "ユニット                     "
                             + Expression.Term("HP", null, 4) + " " + Expression.Term("EN", null, 4) + " "
                             + Expression.Term("装甲", null, 4) + " " + Expression.Term("運動", u: null) + " 適応 攻撃力 射程",
                lb_mode = "連続表示,コメント",
            });

            // キャンセル?
            if (tfRet == 0)
            {
                CancelCommand();
                GUI.UnlockGUI();
                return;
            }

            // 換装を実施
            SelectedUnit.Transform(SelectedUnit.OtherForm(uList[tfRet - 1].ListItemID).Name);

            // ユニットリストの再構築
            Event.MakeUnitList(smode: "");

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

            Status.DisplayUnitStatus(SelectedUnit.CurrentForm());

            CommandState = "ユニット選択";
            GUI.UnlockGUI();
        }
예제 #4
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();
        }
예제 #5
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();
            }
        }
예제 #6
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();
        }
예제 #7
0
        // 「待機」コマンド
        // 他のコマンドの終了処理にも使われる
        private void WaitCommand(bool WithoutAction = false)
        {
            LogDebug();

            // コマンド終了時はターゲットを解除
            SelectedTarget = null;

            // ユニットにパイロットが乗っていない?
            if (SelectedUnit.CountPilot() == 0)
            {
                CommandState = "ユニット選択";
                GUI.RedrawScreen();
                Status.ClearUnitStatus();
                return;
            }

            if (!WithoutAction)
            {
                // 残り行動数を減少させる
                SelectedUnit.UseAction();

                // 持続期間が「移動」のスペシャルパワー効果を削除
                if (Strings.InStr(CommandState, "移動後") > 0)
                {
                    SelectedUnit.RemoveSpecialPowerInEffect("移動");
                }
            }

            CommandState = "ユニット選択";

            // アップデート
            SelectedUnit.Update();
            SRC.PList.UpdateSupportMod(SelectedUnit);

            // ユニットが既に出撃していない?
            if (SelectedUnit.Status != "出撃")
            {
                GUI.RedrawScreen();
                Status.ClearUnitStatus();
                return;
            }

            GUI.LockGUI();
            GUI.RedrawScreen();
            var p = SelectedUnit.Pilots.First();

            // 接触イベント
            foreach (var unit in Map.AdjacentUnit(SelectedUnit))
            {
                SelectedTarget = unit;
                Event.HandleEvent("接触", SelectedUnit.MainPilot().ID, SelectedTarget.MainPilot().ID);
                SelectedTarget = null;
                if (SRC.IsScenarioFinished)
                {
                    SRC.IsScenarioFinished = false;
                    return;
                }

                if (SelectedUnit.Status != "出撃")
                {
                    GUI.RedrawScreen();
                    Status.ClearUnitStatus();
                    GUI.UnlockGUI();
                    return;
                }
            }

            // 進入イベント
            Event.HandleEvent("進入", SelectedUnit.MainPilot().ID, "" + SelectedUnit.x, "" + SelectedUnit.y);
            if (SRC.IsScenarioFinished)
            {
                SRC.IsScenarioFinished = false;
                return;
            }

            if (SelectedUnit.CountPilot() == 0)
            {
                GUI.RedrawScreen();
                Status.ClearUnitStatus();
                GUI.UnlockGUI();
                return;
            }

            // 行動終了イベント
            Event.HandleEvent("行動終了", SelectedUnit.MainPilot().ID);
            if (SRC.IsScenarioFinished)
            {
                SRC.IsScenarioFinished = false;
                return;
            }

            if (SelectedUnit.CountPilot() == 0)
            {
                GUI.RedrawScreen();
                Status.ClearUnitStatus();
                GUI.UnlockGUI();
                return;
            }

            if (p.Unit is object)
            {
                SelectedUnit = p.Unit;
            }

            if (SelectedUnit.Action > 0 && SelectedUnit.CountPilot() > 0)
            {
                // カーソル自動移動
                if (SRC.AutoMoveCursor)
                {
                    GUI.MoveCursorPos("ユニット選択", SelectedUnit);
                }
            }

            // ハイパーモード・ノーマルモードの自動発動をチェック
            SelectedUnit.CurrentForm().CheckAutoHyperMode();
            SelectedUnit.CurrentForm().CheckAutoNormalMode();
            if (GUI.IsPictureVisible || GUI.IsCursorVisible)
            {
                GUI.RedrawScreen();
            }

            GUI.UnlockGUI();

            //// ステータスウィンドウの表示内容を更新
            //if (SelectedUnit.Status == "出撃" && GUI.MainWidth == 15)
            //{
            //    Status.DisplayUnitStatus(SelectedUnit);
            //}
            //else
            //{
            //    Status.ClearUnitStatus();
            //}
        }