예제 #1
0
        // ----- ----- ----- ----- ----- 非STATIC ----- ----- ----- ----- -----
        public GameData Load(string path)
        {
            var table = new SettingFileReader(Path.Combine(path, CONFIG));
            string title = table["Name"][0];

            var game = new GameData(title, path);

            game.Scenarios = LoadScenarios(path);

            return game;
        }
예제 #2
0
        private IList<Callable> LoadCallable()
        {
            var table = new SettingFileReader(
                Path.Combine(_gamePath, Path.Combine("Data", "CallAble")));

            var calls = new List<Callable>();
            int index = 0;
            while (table.HasKey("Call" + index) && table.HasKey("Init" + index))
            {
                var c = new Callable(index, table["Call" + index], table["Init" + index]);
                calls.Add(c);
                index++;
            }

            return calls;
        }
예제 #3
0
        // ----- ----- ----- Method ----- ----- -----
        /// <summary>
        /// ゲームのタイトル等を読み込む。
        /// </summary>
        public GameData LoadGame()
        {
            if (_gameData != null)
                return _gameData;

            const string fileName = "Config";
            string filePath = Path.Combine(_gamePath, fileName);
            var table = new SettingFileReader(filePath);

            try
            {
                return _gameData = new GameData(table["Name"][0]);
            } catch (IndexOutOfRangeException e)
            {
                throw new DataFormatException("タイトル名が指定されていません", filePath, e);
            } catch (NullReferenceException e)
            {
                throw new DataFormatException("タイトルがありません", filePath, e);
            }
        }
예제 #4
0
        public MasterData Load(string filepath)
        {
            Contract.Requires(filepath != null, "filepath");
            var table = new SettingFileReader(filepath);

            var dirs = table["Character"];
            var music = new MasterData.MusicData(
                table["EventMusic"][0],
                table["DecisiveMusic"][0]);

            var revivals = from x in table["MasterRevival"]
                           let s = x.SplitSpace()
                           select new MasterData.Revival(
                               Int32.Parse(s[0]),
                               Int32.Parse(s[1]),
                               Int32.Parse(s[2]),
                               s[3]);

            var inherits = from x in table["MasterInherit"]
                           let s = x.SplitSpace()
                           select new MasterData.Inherit(
                               Int32.Parse(s[0]),
                               s[1],
                               Int32.Parse(s[2]),
                               Int32.Parse(s[3]),
                               s[4]);

            var ghosts = from x in table["Ghost"]
                         from y in x.SplitSpace()
                         select Int32.Parse(y);

            var battleMusic = from x in table["BattleMusic"]
                              let y = x.SplitSpace(2)
                              select new { No = int.Parse(y[0]), Music = y[1] };

            var mBattleMusic = from x in table["MasterBattleMusic"]
                               let y = x.SplitSpace(2)
                               select new { No = int.Parse(y[0]), Music = y[1] };

            int index = 0;
            var masters = new List<MasterData.Master>();
            while (table.HasKey("Master" + (++index))) {
                var data = table["Master" + index];
                var nums = data[2].SplitSpace();
                var clr = Color.FromArgb(
                    Int32.Parse(nums[1]),
                    Int32.Parse(nums[2]),
                    Int32.Parse(nums[3]));

                var battle = battleMusic.FirstOrDefault(x => x.No == index);
                var master = mBattleMusic.FirstOrDefault(x => x.No == index);

                masters.Add(new MasterData.Master(
                    index, data[0], data[1],
                    Int32.Parse(nums[0]),
                    clr, data[3],
                    battle == null ? null : battle.Music,
                    master == null ? null : master.Music,
                    ghosts.Contains(index)));
            }

            return new MasterData(
                dirs,
                music,
                revivals.ToArray(),
                inherits.ToArray(),
                masters);
        }
예제 #5
0
        public ScenarioData Load(string filepath)
        {
            Contract.Requires(File.Exists(filepath), "filepath");

            var table = new SettingFileReader(filepath);

            string title = null;
            string exp = null;
            int turn = -1;
            IList<int> areas = null;
            IEnumerable<int> takeoffs = null;
            var masters = new List<ScenarioData.Master>();
            var leagues = new List<ScenarioData.League>();
            var locates = new List<ScenarioData.Locate>();

            // 例外処理はめんどいのでパスで
            foreach (var pair in table) {
                switch (pair.Key) {

                case "Name":
                    title = pair.Value[0];
                    break;

                case "Explanation":
                    exp = pair.Value.JoinString(Environment.NewLine);
                    break;

                case "Turn":
                    turn = Int32.Parse(pair.Value[0]);
                    break;

                case "Area":
                    // TODO: areas の個数が実際のエリア数と異なっていても動くように修正
                    var list = from line in pair.Value
                               from owner in line.SplitSpace()
                               select Int32.Parse(owner);
                    areas = list.ToList();
                    break;

                case "League":
                    foreach (var l in pair.Value) {
                        var three = l.SplitSpace();
                        leagues.Add(new ScenarioData.League(
                            Int32.Parse(three[0]),
                            Int32.Parse(three[1]),
                            Int32.Parse(three[2])));
                    }
                    break;

                case "Locate":
                    foreach (var l in pair.Value) {
                        var three = l.SplitSpace();
                        locates.Add(new ScenarioData.Locate(
                            three[0],
                            Int32.Parse(three[1]),
                            Int32.Parse(three[2])));
                    }
                    break;

                case "TakeOff":
                    if (takeoffs != null)
                        break;
                    takeoffs = from l in pair.Value
                               from n in l.SplitSpace()
                               select Int32.Parse(n);
                    break;

                default:
                    if (!pair.Key.StartsWith("Master"))
                        break;
                    if (takeoffs == null) {
                        if (table.HasKey("TakeOff")) {
                            takeoffs = from l in table["TakeOff"]
                                       from n in l.SplitSpace()
                                       select Int32.Parse(n);
                        }
                        else {
                            takeoffs = new int[0];
                        }
                    }
                    int num = Int32.Parse(pair.Key.Replace("Master", ""));
                    masters.Add(new ScenarioData.Master(
                        num,
                        pair.Value[0],
                        pair.Value[1],
                        pair.Value.Skip(2).JoinString(Environment.NewLine),
                        takeoffs.Contains(num)));
                    break;
                } // end switch
            } // end table

            return new ScenarioData(
                title,
                exp,
                turn,
                masters,
                areas,
                leagues,
                locates);
        }