Пример #1
0
        // call when starting up game
        public static void LoadSettingsOptions()
        {
            string savePath = GetGameSettingsOptionsPath();

            if (!File.Exists(savePath))
            {
                return;
            }
            Debug.Log("Starting Settings Load");
            settingsSaveState.Reinitialize((Dictionary <string, object>)SystemTools.LoadFromFile(savePath));
            if (onSettingsOptionsLoaded != null)
            {
                onSettingsOptionsLoaded();
            }
        }
Пример #2
0
        public static void SaveGameState(int slot)
        {
            if (GameManager.isInMainMenuScene)
            {
                Debug.LogWarning("Cant save in main menu scene");
                return;
            }
            Debug.Log("Saving game");
            // keep track of the scene we were in when saving
            Scene currentScene = SceneLoading.currentScene;

            // let everyone know we're saving
            if (onSaveGame != null)
            {
                onSaveGame(currentScene);
            }

            SystemTools.SaveToFile(new GameSaveStateInfo(currentScene.name), GetGameSaveInfoPath(slot));
            SystemTools.SaveToFile(gameSaveState.saveState, GetGameSavePath(slot));
        }
        public static bool CallMethod(this GameObject g, string callMethod, object[] parameters, out float value)
        {
            int id = g.GetInstanceID();

            Component[] components;
            if (!componentsPerGameObject.TryGetValue(id, out components))
            {
                components = g.GetComponents <Component>();
                componentsPerGameObject[id] = components;
            }

            for (int i = 0; i < components.Length; i++)
            {
                if (SystemTools.TryAndCallMethod(components[i].GetType(), BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, callMethod, components[i], parameters, out value, i == components.Length - 1, "Run Target: " + g.name))
                {
                    return(true);
                }
            }

            value = 0;
            return(false);
        }
Пример #4
0
        static void BuildPlayer()
        {
            if (playerExists)
            {
                return;
            }

            // Debug.Log("Building Non Existant Player");
            GameObject.Instantiate(GameManagerSettings.instance.playerPrefab);
            _playerCamera = player.GetComponentInChildren <Camera>();

            Type[] camScripts = SystemTools.FindAllDerivedTypes(typeof(CameraScript));
            for (int i = 0; i < camScripts.Length; i++)
            {
                _playerCamera.gameObject.AddComponent(camScripts[i]);
            }

            // Debug.Log("On Player Create Event");
            if (onPlayerCreate != null)
            {
                onPlayerCreate();
            }
        }
Пример #5
0
        /*
         *  start and awake should only happen during the initial scene load
         */
        protected override void Awake()
        {
            base.Awake();
            if (!thisInstanceErrored)
            {
                SceneLoading.onSceneLoadStart += OnSceneLoadStart;
                SaveLoad.onSaveGame           += OnSaveGame;
                SceneManager.sceneLoaded      += OnSceneLoaded;

                if (GameManagerSettings.instance.actionsController != null)
                {
                    GameManagerSettings.instance.actionsController.InitializeActionsInterface();
                }

                // get all types of InitializationSingleTon's
                Type[] results = SystemTools.FindAllDerivedTypes(typeof(InitializationSingleTon <>));

                // add tehm to this gameObject
                for (int i = 0; i < results.Length; i++)
                {
                    gameObject.AddComponent(results[i]);
                }
            }
        }
Пример #6
0
        public static void LoadGameState(int slot)
        {
            string savePath = GetGameSavePath(slot);

            if (!File.Exists(savePath))
            {
                Debug.LogError("No Save File Found For Slot " + slot.ToString());
                return;
            }

            Debug.Log("Starting Load");

            isLoadingSaveSlot = true;

            GameSaveStateInfo savedStateInfo = GetSaveDescription(slot);

            string sceneFromSave = savedStateInfo.sceneName;

            // load the actual save state
            Action <LoadSceneMode> onSceneStartLoad = (mode) => gameSaveState.Reinitialize((Dictionary <string, object>)SystemTools.LoadFromFile(savePath));

            Action <string, LoadSceneMode> onSceneLoaded = (s, mode) => isLoadingSaveSlot = false;

            if (!SceneLoading.LoadSceneAsync(sceneFromSave, onSceneStartLoad, onSceneLoaded, LoadSceneMode.Single, false))
            {
                isLoadingSaveSlot = false;
            }
        }
Пример #7
0
 public static T ReadAsEnum <T> (XmlNode node, T defValue)
 {
     return(SystemTools.StringToEnum(node.InnerText, defValue));
 }