示例#1
0
        private static void LoadGameFile()
        {
            try
            {
                var parser = new FileIniDataParser();
                var data   = parser.ReadFile(StorageBase.GameIniFilePath);

                //state
                var state = data["State"];
                MapBase.OpenMap(state["Map"]);
                NpcManager.Load(state["Npc"]);
                ObjManager.Load(state["Obj"]);
                BackgroundMusic.Play(state["Bgm"]);
                Globals.PlayerIndex = int.Parse(state["Chr"]);

                //option
                var option = data["Option"];
                MapBase.MapTime = int.Parse(option["MapTime"]);
                WeatherManager.ShowSnow(int.Parse(option["SnowShow"]) != 0);
                if (!string.IsNullOrEmpty(option["RainFile"]))
                {
                    WeatherManager.BeginRain(option["RainFile"]);
                }
                if (string.IsNullOrEmpty(option["Water"]))
                {
                    Globals.IsWaterEffectEnabled = false;
                }
                else
                {
                    Globals.IsWaterEffectEnabled = int.Parse(option["Water"]) != 0;
                }
                if (string.IsNullOrEmpty(option["MpcStyle"]))
                {
                    MapBase.DrawColor = Color.White;
                }
                else
                {
                    MapBase.DrawColor = StorageBase.GetColorFromString(option["MpcStyle"]);
                }
                if (string.IsNullOrEmpty(option["AsfStyle"]))
                {
                    Sprite.DrawColor = Color.White;
                }
                else
                {
                    Sprite.DrawColor = StorageBase.GetColorFromString(option["AsfStyle"]);
                }
                if (string.IsNullOrEmpty(option["SaveDisabled"]))
                {
                    Globals.IsSaveDisabled = false;
                }
                else
                {
                    Globals.IsSaveDisabled = int.Parse(option["SaveDisabled"]) > 0;
                }
                if (string.IsNullOrEmpty(option["IsDropGoodWhenDefeatEnemyDisabled"]))
                {
                    Globals.IsDropGoodWhenDefeatEnemyDisabled = false;
                }
                else
                {
                    Globals.IsDropGoodWhenDefeatEnemyDisabled = int.Parse(option["IsDropGoodWhenDefeatEnemyDisabled"]) > 0;
                }
                //Timer
                var timer = data["Timer"];
                if (timer != null)
                {
                    var isOn = timer["IsOn"] != "0";
                    if (isOn)
                    {
                        ScriptExecuter.OpenTimeLimit(int.Parse(timer["TotalSecond"]));
                        var isHide = timer["IsTimerWindowShow"] != "1";
                        if (isHide)
                        {
                            ScriptExecuter.HideTimerWnd();
                        }
                        if (timer["IsScriptSet"] != "0")
                        {
                            ScriptExecuter.SetTimeScript(int.Parse(timer["TriggerTime"]),
                                                         timer["TimerScript"]);
                        }
                    }
                }

                //Variables
                ScriptExecuter.LoadVariables(data["Var"]);

                //ParallelScript
                ScriptManager.LoadParallelScript(data["ParallelScript"]);
            }
            catch (Exception exception)
            {
                Log.LogFileLoadError("Game.ini", StorageBase.GameIniFilePath, exception);
            }
        }