コード例 #1
0
        public void AutoSave()
        {
            // Save scene
            SaveSystem.SetString(SaveUtils.GetKey(SaveUtils.GAME_MAN_PREFIX, SaveUtils.GAMEMAN_SCENE_NAME_KEY), SceneManager.GetActiveScene().name);
            //print("Scene saved");

            // Save player pos/rot
            Vector3 playerPos = PlayerT.position;
            float   playerRot = PlayerT.rotation.eulerAngles.y;

            SaveSystem.SetFloat(SaveUtils.GetKey(SaveUtils.PLAYER_TRANS_PREFIX, SaveUtils.PLAYER_X_KEY), playerPos.x);
            SaveSystem.SetFloat(SaveUtils.GetKey(SaveUtils.PLAYER_TRANS_PREFIX, SaveUtils.PLAYER_Y_KEY), playerPos.y);
            SaveSystem.SetFloat(SaveUtils.GetKey(SaveUtils.PLAYER_TRANS_PREFIX, SaveUtils.PLAYER_Z_KEY), playerPos.z);
            SaveSystem.SetFloat(SaveUtils.GetKey(SaveUtils.PLAYER_TRANS_PREFIX, SaveUtils.PLAYER_ROT_KEY), playerRot);
            //print("Player pos/rot saved");

            // Save player health and camera rotation
            CharController.Save(SaveSystem, SaveUtils.CHAR_CONTROLLER_PREFIX);
            //print("Health and cam rot saved");

            // Save player progress
            PlayerManager.Save(SaveSystem, SaveUtils.PLAYER_MAN_PREFIX);
            //print("Player progress saved");

            // Save AI manager
            AIManager.Save(SaveSystem, SaveUtils.AI_MAN_PREFIX);
            //print("AI manager saved");

            // TODO: better way to save levelmanagers.
            // Save GraveyardMan
            if (GraveyardManager != null)
            {
                //print("GraveyardMan not null, saving");
                GraveyardManager.Save(SaveSystem, SaveUtils.GRAVEYARD_MAN_PREFIX);
                //print("GraveyardMan saved");
            }

            // Save CastelMan
            if (CastleManager != null)
            {
                //print("CastleMan not null, saving");
                CastleManager.Save(SaveSystem, SaveUtils.CASTLE_MAN_PREFIX);
                //print("CastleMan saved");
            }

            //print("Calling savesystem to actually save shit");
            SaveSystem.Save(SaveUtils.AUTOSAVE_SAVE_SLOT);
            //print("game saved");
        }
コード例 #2
0
        private void InitializeGameMan(Scene scene, LoadSceneMode mode)
        {
            // TODO: load player unlocks from savefile and pass them to PlayerManager and other player progress and stuff.
            string scneneName = scene.name;

            switch (scneneName)
            {
            case GlobalVariables.MAIN_MENU:
                //print("mainmenu init");
                MainMenuInit();
                break;

            case GlobalVariables.GRAVEYARD:
                //print("graveyard init");

                //#if (UNITY_EDITOR)
                // Load PlayerMan, move to GraveyardInit?
                if (PlayerManager == null)
                {
                    PlayerManager = GetComponent <PlayerManager>();
                }

                PlayerManager.Initialize(SaveSystem, SaveUtils.PLAYER_MAN_PREFIX);

                // Load GraveyardMan
                if (GraveyardManager == null)
                {
                    GraveyardManager = FindObjectOfType <GraveyardManager>();
                }

                GraveyardManager.Initialize(SaveSystem, SaveUtils.GRAVEYARD_MAN_PREFIX);

                // Load AIman, move to GraveyardInit?
                if (AIManager == null)
                {
                    AIManager = GetComponent <AIManager>();
                }

                AIManager.Initialize(SaveSystem, SaveUtils.AI_MAN_PREFIX);
                //#endif

                StartCoroutine(GraveyardInit());
                break;

            case GlobalVariables.CASTLE:
                if (PlayerManager == null)
                {
                    PlayerManager = GetComponent <PlayerManager>();
                }

                PlayerManager.Initialize(SaveSystem, SaveUtils.PLAYER_MAN_PREFIX);

                // Load GraveyardMan
                if (CastleManager == null)
                {
                    CastleManager = FindObjectOfType <CastleManager>();
                }

                CastleManager.Initialize(SaveSystem, SaveUtils.CASTLE_MAN_PREFIX);

                // Load AIman, move to GraveyardInit?
                if (AIManager == null)
                {
                    AIManager = GetComponent <AIManager>();
                }

                AIManager.Initialize(SaveSystem, SaveUtils.AI_MAN_PREFIX);

                StartCoroutine(CastleInit());
                break;

#if (UNITY_EDITOR)
            case "SampleScene 1":
                // Load PlayerMan, move to GraveyardInit?
                if (PlayerManager == null)
                {
                    PlayerManager = GetComponent <PlayerManager>();
                }

                PlayerManager.Initialize(SaveSystem, SaveUtils.PLAYER_MAN_PREFIX);

                // Load GraveyardMan
                if (GraveyardManager == null)
                {
                    GraveyardManager = FindObjectOfType <GraveyardManager>();
                }

                GraveyardManager.Initialize(SaveSystem, SaveUtils.GRAVEYARD_MAN_PREFIX);

                // Load AIman, move to GraveyardInit?
                if (AIManager == null)
                {
                    AIManager = GetComponent <AIManager>();
                }

                AIManager.Initialize(SaveSystem, SaveUtils.AI_MAN_PREFIX);

                StartCoroutine(GraveyardInit());
                break;
#endif
            case GlobalVariables.OUTRO:
                Settings.Instance.Audio.ChangeMusic(AudioContainer.Music.Menu);
                break;
            }
        }