Ejemplo n.º 1
0
 // 装備名から、基地航空隊の中隊を選択する(デバッグ用)
 // LINQにおけるIndexの取り方:
 // http://shirakamisauto.hatenablog.com/entry/2016/06/27/080017
 private int BAUIndex(string name)
 {
     return(BasedAirUnitList
            .Select((c, i) => new { Content = c, Index = i })
            .Where(pair => pair.Content == name)
            .Select(pair => pair.Index)
            .First());
 }
Ejemplo n.º 2
0
        // 基地航空隊の読み込み処理
        private void LoadBasedAirUnit()
        {
            var ofd = new Microsoft.Win32.OpenFileDialog()
            {
                FileName = "bau_data.bau",
                Filter   = "基地航空隊情報(*.bau)|*.bau|すべてのファイル(*.*)|*.*",
                Title    = "読み込むのファイルを選択"
            };

            if ((bool)ofd.ShowDialog())
            {
                try {
                    // ファイルを読み込み
                    using (var sr = new System.IO.StreamReader(ofd.FileName)) {
                        // テキストとして読み込んでパース
                        string output  = sr.ReadToEnd();
                        var    bauData = new BasedAirUnitGroup(output);
                        #region 基地航空隊の情報を初期化
                        for (int ui = 0; ui < 3; ++ui)
                        {
                            BasedAirUnitMode[ui].Value = 0;
                            for (int wi = 0; wi < 4; ++wi)
                            {
                                BasedAirUnitIndex[ui][wi].Value = 0;
                                BasedAirUnitMas[ui][wi].Value   = 0;
                                BasedAirUnitRf[ui][wi].Value    = 0;
                            }
                        }
                        #endregion
                        // 基地航空隊の情報を書き込む
                        for (int ui = 0; ui < bauData.BasedAirUnitList.Count; ++ui)
                        {
                            // 出撃回数
                            int count = bauData.BasedAirUnitList[ui].SallyCount;
                            BasedAirUnitMode[ui].Value = count;
                            // 装備情報
                            var weaponList = bauData.BasedAirUnitList[ui].WeaponList;
                            for (int wi = 0; wi < weaponList.Count; ++wi)
                            {
                                var weapon = weaponList[wi];
                                BasedAirUnitIndex[ui][wi].Value = BasedAirUnitList.IndexOf($"{weapon.Name}:{weapon.AntiAir}:{weapon.BasedAirUnitRange}");
                                BasedAirUnitMas[ui][wi].Value   = weapon.Mas;
                                BasedAirUnitRf[ui][wi].Value    = weapon.Rf;
                            }
                        }
                    }
                } catch (Exception e) {
                    Console.WriteLine(e.ToString());
                    MessageBox.Show("ファイルを開けませんでした", "AWSK");
                }
            }
        }
Ejemplo n.º 3
0
        // 自装備選択のコンボボックスを書き換え
        private void ResetWeaponListByType(int index1, int index2, int typeIndex)
        {
            string type = BAUTypeList[typeIndex];

            // 特殊処理
            if (type == "--")
            {
                BasedAirUnitIndex[index1][index2].Value = 0;
            }
            else
            {
                // 自動選択
                int bauIndex = BasedAirUnitList.IndexOf($"【{type}】");
                BasedAirUnitIndex[index1][index2].Value = bauIndex;
            }
        }