Esempio n. 1
0
        /// <summary>
        /// ファイル読み込み
        /// </summary>
        public static GameInfo LoadFile(string baseDir)
        {
            var gameInfo = new GameInfo();

            //mod読み込み
            List <string> modLines = ApplicationUtil.LoadFileLines(Path.Combine(baseDir, "index.mod"));

            gameInfo.ScenerioVersion = int.Parse(ExtractModProperty(modLines, "version"));
            gameInfo.BasicYear       = int.Parse(ExtractModProperty(modLines, "basicyear"));
            gameInfo.Season          = (SeasonEnum)int.Parse(ExtractModProperty(modLines, "season"));
            gameInfo.SteamYear       = int.Parse(ExtractModProperty(modLines, "steamyear"));
            gameInfo.Kamotu          = (KamotsuEnum)int.Parse(ExtractModProperty(modLines, "kamotu"));
            gameInfo.FarePerKm       = int.Parse(ExtractModProperty(modLines, "km"));
            gameInfo.Rpm             = int.Parse(ExtractModProperty(modLines, "rpm"));
            gameInfo.LineMakeCost    = int.Parse(ExtractModProperty(modLines, "linemc"));
            gameInfo.TechCost        = int.Parse(ExtractModProperty(modLines, "tecc"));
            //mapは省略
            gameInfo.InfoPosi = (InfoPosiEnum)int.Parse(ExtractModProperty(modLines, "infoh"));

            var hojo = ExtractModProperty(modLines, "hojo").Split(",");

            gameInfo.HojoStartYear = int.Parse(hojo[0]);
            gameInfo.HojoEndYear   = int.Parse(hojo[1]);
            gameInfo.HojoAmount    = int.Parse(hojo[2]);

            gameInfo.warModeList = CreateWarModeList(ExtractModProperties(modLines, "warmode"));

            //バリデーションor値補正
            if (gameInfo.ScenerioVersion < 1)
            {
                _ = MessageBox.Show("シナリオバージョンの数値が異常です");
                ApplicationUtil.ForceExit();
            }
            if (gameInfo.BasicYear < 0)
            {
                _ = MessageBox.Show("基礎とする年の値が異常です");
                ApplicationUtil.ForceExit();
            }
            //kamotuはenum定義なので一旦見送り。他のenumもチェックを一旦見送り
            if (gameInfo.Rpm < 1)
            {
                gameInfo.Rpm = 100;
            }
            if (gameInfo.SteamYear < 1)
            {
                gameInfo.SteamYear = int.MaxValue;
            }
            if (gameInfo.LineMakeCost < 1)
            {
                gameInfo.LineMakeCost = 100;
            }
            if (gameInfo.TechCost < 1)
            {
                gameInfo.TechCost = 100;
            }

            //画像
            var bgImage = new BitmapImage(new Uri(Path.Combine(baseDir, "map.bmp"), UriKind.Relative));

            gameInfo.map = bgImage;

            //初期化

            //駅
            gameInfo.stations = CreateStationFromFile(baseDir);

            //路線
            gameInfo.lines = CreateLineFromFile(baseDir, gameInfo);
            BindLinesToStations(gameInfo);

            //乗り継ぎ
            gameInfo.longwayList = CreateLongwayFromFile(baseDir, gameInfo);

            //運転系統
            gameInfo.diagrams = CreateDiagramFromFile(baseDir, gameInfo);
            BindDiagramsToLines(gameInfo);

            //モード読み込み
            gameInfo.Modes = LoadModes(modLines);

            Console.WriteLine("ファイル読み込み完了");
            return(gameInfo);
        }
Esempio n. 2
0
        /// <summary>
        /// ファイル読み込み
        /// </summary>
        public void LoadFile()
        {
            var basePath = @"jnr\";

            //mod読み込み
            List <string> modLines = ApplicationUtil.LoadFileLines(basePath + "index.mod");

            ScenerioVersion = int.Parse(ExtractModProperty(modLines, "version"));
            BasicYear       = int.Parse(ExtractModProperty(modLines, "basicyear"));
            Season          = (SeasonEnum)int.Parse(ExtractModProperty(modLines, "season"));
            SteamYear       = int.Parse(ExtractModProperty(modLines, "steamyear"));
            Kamotu          = (KamotsuEnum)int.Parse(ExtractModProperty(modLines, "kamotu"));
            FarePerKm       = int.Parse(ExtractModProperty(modLines, "km"));
            Rpm             = int.Parse(ExtractModProperty(modLines, "rpm"));
            LineMakeCost    = int.Parse(ExtractModProperty(modLines, "linemc"));
            TechCost        = int.Parse(ExtractModProperty(modLines, "tecc"));
            //mapは省略
            InfoPosi = (InfoPosiEnum)int.Parse(ExtractModProperty(modLines, "infoh"));

            var hojo = ExtractModProperty(modLines, "hojo").Split(",");

            HojoStartYear = int.Parse(hojo[0]);
            HojoEndYear   = int.Parse(hojo[1]);
            HojoAmount    = int.Parse(hojo[2]);

            warModeList = WarMode.CreateWarModeList(ExtractModProperties(modLines, "warmode"));

            //バリデーションor値補正
            if (ScenerioVersion < 1)
            {
                _ = MessageBox.Show("シナリオバージョンの数値が異常です");
                ApplicationUtil.ForceExit();
            }
            if (BasicYear < 0)
            {
                _ = MessageBox.Show("基礎とする年の値が異常です");
                ApplicationUtil.ForceExit();
            }
            //kamotuはenum定義なので一旦見送り。他のenumもチェックを一旦見送り
            if (Rpm < 1)
            {
                Rpm = 100;
            }
            if (SteamYear < 1)
            {
                SteamYear = int.MaxValue;
            }
            if (LineMakeCost < 1)
            {
                LineMakeCost = 100;
            }
            if (TechCost < 1)
            {
                TechCost = 100;
            }

            //画像
            var bgImage = new BitmapImage(new Uri(basePath + "map.bmp", UriKind.Relative));

            map = bgImage;
            //gamePage.setBgImage(bgImage);

            //初期化


            //駅
            stations = CreateStationFromFile(basePath);

            //路線
            lines = CreateLineFromFile(basePath);
            BindLinesToStations();

            //乗り継ぎ
            longwayList = CreateLongwayFromFile(basePath);

            //運転系統
            diagrams = CreateDiagramFromFile(basePath);
            BindDiagramsToLines();

            //モード読み込み
            modes = LoadModes(modLines);
            //FIXME 仮で最初のモードの車輌などを注入しているので、ここを動的に
            compositions.AddRange(modes[0].DefautltCompositions);
            Money = modes[0].Money;
            Year  = modes[0].Year;
            MYear = modes[0].MYear;

            Console.WriteLine("ファイル読み込み完了");
        }