예제 #1
0
        public static void SaveGame(GameManager_Master gameManagerMaster, Player_Inventory playerInventory)
        {
            BinaryFormatter formatter = new BinaryFormatter();
            string          filePath  = string.Concat(Application.persistentDataPath, "/", savedFileName);
            FileStream      file      = new FileStream(filePath, FileMode.Create);

            TorchBehavior torch = playerInventory.gameObject.GetComponent <TorchBehavior>();

            GameSavedData data = new GameSavedData(gameManagerMaster, playerInventory, torch);

            formatter.Serialize(file, data);

            file.Close();
        }
예제 #2
0
        void SetInitialReferences()
        {
            if (player != null)
            {
                playerMaster = player.GetComponent <Player_Master>();
                torch        = player.GetComponent <TorchBehavior>();
            }
            else
            {
                Debug.LogWarning("Player is not assigned on Hud_EnergyBar");
            }


            energyTransform = GetComponent <RectTransform>();
            image           = GetComponent <Image>();
        }
예제 #3
0
        void SetInitialReferences()
        {
            if (audioObject != null)
            {
                audioManager = audioObject.GetComponent <AudioManager>();
            }
            else
            {
                Debug.LogWarning("Please attach audioManager Gameobject");
            }

            if (game != null)
            {
                gameManagerMaster = game.GetComponent <GameManager_Master>();
            }
            else
            {
                Debug.LogWarning("Please attach GameManager Gameobject");
            }

            playerMaster = GetComponent <Player_Master>();
            torchMaster  = GetComponent <TorchBehavior>();
            soundOn      = true;
        }
예제 #4
0
        public GameSavedData(GameManager_Master gameManagerMaster, Player_Inventory playerInventory, TorchBehavior torch)
        {
            //---Save current scene index---//
            savedSceneIndex = gameManagerMaster.currentBuildIndex;

            playerPosition    = new float[3];
            playerPosition[0] = playerInventory.transform.position.x;
            playerPosition[1] = playerInventory.transform.position.y;
            playerPosition[2] = playerInventory.transform.position.z;

            playerY_Rotation = playerInventory.transform.rotation.y;

            torchEnergy = torch.energy;

            if (playerInventory.items.Count > 0)
            {
                itemsName = new string[playerInventory.items.Count];
            }
            else
            {
                itemsName = new string[1];
            }

            int currentIndex = 0;

            foreach (Item item in playerInventory.items)
            {
                itemsName[currentIndex] = item.itemName;
                currentIndex++;
            }
        }