Exemplo n.º 1
0
        public bool SetDifficulty(string difficultySettingName)
        {
            if (!HasCurrentProfile)
            {
                return(false);
            }

            if (mCurrentGame == null)
            {
                mCurrentGame = new PlayerGame();
            }

            if (mCurrentGame.Difficulty == null || mCurrentGame.DifficultyName != difficultySettingName)
            {
                if (Mods.Get.Runtime.LoadMod <DifficultySetting>(ref mCurrentGame.Difficulty, "DifficultySetting", difficultySettingName))
                {
                    CurrentGame.DifficultyName = difficultySettingName;
                }
            }
            if (CurrentGame.Difficulty != null)
            {
                CurrentGame.Difficulty.Apply();
                return(true);
            }
            else
            {
                Debug.Log("Couldn't set difficulty, none existed");
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool SetWorldAndGame(string worldName, string gameName, bool saveGame, bool loadGame)
        {
            Debug.Log("PROFILE: Setting world name to " + worldName);
            if (!HasSelectedProfile || !HasCurrentProfile)
            {
                return(false);
            }

            string errorMessage = string.Empty;

            Debug.Log("PROFILE: INITIALIZE DATA PATHS TO : " + Current.Name + ", " + worldName + ", " + gameName);
            if (!GameData.IO.InitializeLocalDataPaths(Current.Name, worldName, gameName, out errorMessage))
            {
                Frontiers.GUI.GUILoading.DisplayError(errorMessage);
                Debug.LogError(errorMessage);
                return(false);
            }
            GameData.IO.LogPaths();

            //if we haven't already created this game
            if (!HasCurrentGame || CurrentGame.WorldName != worldName || CurrentGame.Name != gameName)
            {
                //try to load the game
                //if it doesn't exist, create it
                if (!Mods.Get.Runtime.LoadGame(ref mCurrentGame, worldName, gameName))                                                  //if the game doesn't exist, create it, then save it immediately
                {
                    mCurrentGame               = new PlayerGame();
                    mCurrentGame.Version       = GameManager.VersionString;
                    mCurrentGame.LastTimeSaved = DateTime.Now;
                    mCurrentGame.GameTime      = 0;
                    mCurrentGame.WorldName     = worldName;
                    mCurrentGame.Name          = gameName;
                    mCurrentGame.HasStarted    = false;
                    //create a default character for this game
                    mCurrentGame.Character = PlayerCharacter.Default();
                    Debug.Log("PROFILE: Didn't find game " + gameName + ", saving now");
                }
            }

            if (saveGame)
            {
                Mods.Get.Runtime.SaveGame(mCurrentGame);
            }

            if (loadGame)
            {
                Mods.Get.LoadLiveGame(gameName);
            }

            HasSelectedGame = true;
            return(true);
        }
Exemplo n.º 3
0
        public bool SetDifficulty(DifficultySetting setting)
        {
            if (!HasCurrentProfile)
            {
                Debug.Log("Couldn't set difficulty, had no profile");
                return(false);
            }

            if (CurrentGame == null)
            {
                mCurrentGame = new PlayerGame();
            }

            CurrentGame.DifficultyName = setting.Name;
            CurrentGame.Difficulty     = setting;
            return(true);
        }