コード例 #1
0
        void LoadLastSavedProgress()
        {
            GameSavedData data = SystemSaveAndLoad.LoadGame(SystemSaveAndLoad.savedFileName);

            //---If save file exist---//
            if (data != null)
            {
                gameManagerMaster.currentBuildIndex = data.savedSceneIndex;

                Vector3 position;
                position.x = data.playerPosition[0];
                position.y = data.playerPosition[1];
                position.z = data.playerPosition[2];
                Player_Master.instance.transform.position = position;

                //Debug.Log(position);
                //Player_Master.instance.transform.SetPositionAndRotation(position, Quaternion.EulerAngles(0, data.playerY_Rotation, 0));

                Player_Master.instance.gameObject.GetComponent <TorchBehavior>().energy = data.torchEnergy;

                for (int i = 0; i < data.itemsName.Length; i++)
                {
                    itemInThisScene = false;
                    foreach (GameObject gameObject in itemsInScene)
                    {
                        pickupScriptOnItem = gameObject.GetComponent <Pickup>();
                        if (pickupScriptOnItem != null)
                        {
                            if (pickupScriptOnItem.item.itemName == data.itemsName[i])
                            {
                                itemInThisScene = true;
                                Player_Inventory.instance.AddItem(pickupScriptOnItem.item);
                                gameObject.SetActive(false);
                                break;
                            }
                        }
                    }

                    if (!itemInThisScene)
                    {
                        foreach (Item item in itemsInGame)
                        {
                            if (item.itemName == data.itemsName[i])
                            {
                                Player_Inventory.instance.AddItem(item);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void RestartFromSavedPoint()
        {
            GameSavedData data = SystemSaveAndLoad.LoadGame(SystemSaveAndLoad.savedFileName);

            if (data != null)
            {
                SystemSaveAndLoad.sceneLoadType = SystemSaveAndLoad.LoadType.loadSaved;
                SceneManager.LoadScene(GameManager_GlobalVariables.instance.scenesName[data.savedSceneIndex]);
            }
            else
            {
                SystemSaveAndLoad.sceneLoadType = SystemSaveAndLoad.LoadType.newGame;
                SceneManager.LoadScene(GameManager_GlobalVariables.instance.scenesName[1]);
            }
        }
コード例 #3
0
        void CheckLoadFile()
        {
            GameSavedData data = SystemSaveAndLoad.LoadGame(SystemSaveAndLoad.savedFileName);

            if (data != null)
            {
                loadableSceneIndex      = data.savedSceneIndex;
                loadable                = true;
                loadButton.interactable = true;
            }
            else
            {
                loadableSceneIndex      = 1;
                loadable                = false;
                loadButton.interactable = false;
            }
        }
コード例 #4
0
        void LoadSceneChangedProgress()
        {
            GameSavedData data = SystemSaveAndLoad.LoadGame(SystemSaveAndLoad.savedFileName);

            if (data != null)
            {
                Player_Master.instance.gameObject.GetComponent <TorchBehavior>().energy = data.torchEnergy;

                for (int i = 0; i < data.itemsName.Length; i++)
                {
                    itemInThisScene = false;
                    foreach (GameObject gameObject in itemsInScene)
                    {
                        pickupScriptOnItem = gameObject.GetComponent <Pickup>();
                        if (pickupScriptOnItem != null)
                        {
                            if (pickupScriptOnItem.item.itemName == data.itemsName[i])
                            {
                                itemInThisScene = true;
                                Player_Inventory.instance.AddItem(pickupScriptOnItem.item);
                                gameObject.SetActive(false);
                                break;
                            }
                        }
                    }

                    if (!itemInThisScene)
                    {
                        foreach (Item item in itemsInGame)
                        {
                            if (item.itemName == data.itemsName[i])
                            {
                                Player_Inventory.instance.AddItem(item);
                            }
                        }
                    }
                }
            }
        }