コード例 #1
0
        public void Load()
        {
            string gamePicturePath = Path.Combine(_scenarioPath, "Picture");
            string gameDataPath = Path.Combine(_scenarioPath, "Data");

            // 地形タイプ情報の読み込み
            var landformInfos = LoadInfo();

            // 各チップ画像の取得
            var landImages = WarGlobal.BmpManager.GetSurfaces(
                Path.Combine(gamePicturePath, "BMAPCHAR.BMP"), WarGlobal.ChipSize);

            var objectImages = WarGlobal.BmpManager.GetSurfaces(
                Path.Combine(gamePicturePath, "BMAPOBJ.BMP"), WarGlobal.ChipSize,
                path => BitmapUtil.Load(path, Color.Black));

            // 地形チップの生成
            var landforms = new Landform[landImages.Count];
            // 地形タイプの読み込み
            using (var reader = new StreamReader(Path.Combine(gameDataPath, "TikeiType"), WarGlobal.Encoding))
            {
                var sc = new Scanner(reader);
                for (int i = 0; i < landforms.Length; i++)
                {
                    int id = sc.NextInt32(NumberStyles.HexNumber);
                    landforms[i] = new Landform(landImages[i], landformInfos[id + 1]);
                }
            }
            WarGlobal.Landforms = landforms;

            // オブジェクトチップの生成
            var constructs = new Construct[objectImages.Count + 2];
            // 0番目は移動不可, 1番目はnull
            for (int i = 2; i < objectImages.Count; i++)
            {
                int id;
                if (i > EndWall)
                    id = 18;
                else if (i > EndCity)
                    id = 17;
                else
                    id = 16;
                constructs[i] = new Construct(objectImages[i - 1], landformInfos[id + 1]);
            }
            // 移動不可オブジェクトの生成
            constructs[0] = new Construct(null, landformInfos[0]);

            WarGlobal.Constructs = constructs;
        }
コード例 #2
0
        public static IList<Skill> Load(IList<string> charaDirPathes)
        {
            foreach (string dpath in charaDirPathes)
            {
                var fpath = Path.Combine(dpath, "SpecialTable");
                if (!File.Exists(fpath)) continue;

                try
                {
                    using (var reader = new StreamReader(fpath, Global.Encoding))
                    {
                        var sc = new Scanner(reader);
                        var skillList = new List<Skill>();

                        while (sc.HasNext() && sc.Current() != "End")
                        {
                            var skill = new Skill {
                                name = sc.Next(),
                                scopeType = ((ScopeType)sc.NextInt32()),
                                skillType = ((SkillType)sc.NextInt32()),
                                mpCost = sc.NextInt32(),
                                range = sc.NextInt32(),
                                area = sc.NextInt32(),
                                power = sc.NextInt32(),
                                attackDependency = ((AttackDependency)sc.NextInt32()),
                                defenseDependency = ((DefenseDependency)sc.NextInt32()),
                                attackType = ((AttackType)sc.NextInt32()),
                                soundName = sc.Next(),
                                sideSize = sc.NextInt32(),
                                imageCount = sc.NextInt32(),
                            };
                            skillList.Add(skill);
                        }

                        return skillList;
                    }
                } catch (Exception)
                {
                }
            }

            return null;
        }
コード例 #3
0
        public List<AreaData> Load(string filepath)
        {
            Contract.Requires(File.Exists(filepath), "filepath");

            var list = new List<AreaData>();
            using (var reader = new StreamReader(filepath, Global.Encoding))
            {
                var sc = new Scanner(reader,
                    c => c == ' ' || c == ' ' || c == '\t' || c == '\r',
                    c => c == '\n');
                int id = 0;
                while (sc.HasNext() && sc.Current() != "End")
                {
                    list.Add(new AreaData(++id) {
                        Name = sc.Next(),
                        AreaType = sc.NextInt32(),
                        DefaultIncome = sc.NextInt32(),
                        NumCity = sc.NextInt32(),
                        NumWall = sc.NextInt32(),
                        NumRoad = sc.NextInt32(),
                        NeutralPower = sc.NextInt32(),
                        DefautlWallRate = sc.NextInt32(),
                        FlagLocation = new Point(
                            sc.NextInt32(),
                            sc.NextInt32()),
                        Adjacent = new[] {
                            sc.NextInt32(),
                            sc.NextInt32(),
                            sc.NextInt32(),
                            sc.NextInt32(), // 4
                            sc.NextInt32(),
                            sc.NextInt32(),
                            sc.NextInt32(),
                            sc.NextInt32(), // 8
                        },
                        MusicFileName = sc.Next(),
                    });
                    Debug.Assert(sc.LastDelimiter == '\n'); // 念のために改行が存在するかチェック
                }
            } // end using
            return list;
        }
コード例 #4
0
        private List<LandformInfo> LoadInfo()
        {
            const int nMoveType = 10;

            var landformNames = new[] {
                "移動不可",
                null, "平地", "木", "岩", "雪木", "浅瀬", "海", "深海", "荒地", "雪原",
                "砂漠", "山地", "火口", "沼地", "森", null, "街", "壁", "道", "城",
            };
            var neededMobilities = new int[landformNames.Length][];
            var techniqueOffsets = new int[landformNames.Length][];
            for (int i = 0; i < landformNames.Length; i++)
            {
                neededMobilities[i] = new int[nMoveType];
                techniqueOffsets[i] = new int[nMoveType];
            }

            var path = Path.Combine(_scenarioPath, Path.Combine("Data", "Move&Skill"));
            using (var reader = new StreamReader(path, WarGlobal.Encoding))
            {
                var sc = new Scanner(reader);
                for (int i = 0; i < nMoveType; i++)
                {
                    // 移動不可
                    neededMobilities[0][i] = 999;
                    for (int j = 1; j < landformNames.Length; j++)
                    {
                        neededMobilities[j][i] = sc.NextInt32();
                        techniqueOffsets[j][i] = sc.NextInt32();
                    }
                }
            }

            var landforms = new List<LandformInfo>(landformNames.Length);
            for (int i = 0; i < landformNames.Length; i++)
            {
                landforms.Add(new LandformInfo(landformNames[i], neededMobilities[i], techniqueOffsets[i]));
            }
            return landforms;
        }
コード例 #5
0
        private static IList<MagicData> Load(string gameDirPath)
        {
            var dataDir = Path.Combine(gameDirPath, "Data");
            var magicDataFile = Path.Combine(dataDir, "MagicTable");
            var soundNameFile = Path.Combine(dataDir, "SoundFileName");

            var magicList = new List<MagicData>();

            using (var magicReader = new StreamReader(magicDataFile, Global.Encoding))
            using (var soundReader = new StreamReader(soundNameFile, Global.Encoding))
            {
                var sc = new Scanner(magicReader);
                var soundScanner = new Scanner(soundReader);

                int count = 0;
                while(sc.HasNext() && soundScanner.HasNext() && soundScanner.Current() != "End")
                {
                    // シナリオに非依存な魔法のインデックスを利用して属性を分ける
                    var element = AttackTypes.Magic[count / 8];

                    magicList.Add(new MagicData(sc.Next(), (MagicType)sc.NextInt32(),
                        new[]{
                            new MagicCore((byte)sc.NextInt32(), (byte)sc.NextInt32(), (byte)sc.NextInt32(), (byte)sc.NextInt32()),
                            new MagicCore((byte)sc.NextInt32(), (byte)sc.NextInt32(), (byte)sc.NextInt32(), (byte)sc.NextInt32()),
                            new MagicCore((byte)sc.NextInt32(), (byte)sc.NextInt32(), (byte)sc.NextInt32(), (byte)sc.NextInt32())
                        },
                        sc.Next(), element, soundScanner.Next(), "Magic" + count + ".bmp"
                    ));

                    count++;
                }
            }
            return magicList;
        }