/// =========================================================================================================================
        /// =========================================================================================================================
        ///
        ///         Crushing!  ( Saving / Loading )
        ///
        /// =========================================================================================================================
        /// =========================================================================================================================


        /// <summary>
        /// Saves the Crushing game data inputted
        /// </summary>
        /// <param name="data">CrushingData to save</param>
        public static void SaveCrushing(CrushingData data)
        {
            BinaryFormatter Formatter = new BinaryFormatter();
            string          SavePath  = Application.persistentDataPath + "/crushing.masf";
            FileStream      Stream    = new FileStream(SavePath, FileMode.OpenOrCreate);

            CrushingData _data = data;

            Formatter.Serialize(Stream, _data);
            Stream.Close();
        }
Exemple #2
0
        /// <summary>
        /// Sets up the audio source reference and the playerID
        /// </summary>
        private void Setup()
        {
            musicPlayers = GameObject.FindGameObjectsWithTag(tagString);
            playerID     = musicPlayers.Length;
            audioSource  = GetComponent <AudioSource>();
            DontDestroyOnLoad(this);

            loadedData = SaveManager.LoadGame();

            gameAudioMixer.SetFloat("musicVolume", loadedData.musicVolume);
        }
    private void Start()
    {
        saveData = SaveManager.LoadGame();

        if (saveData.longestRoundTime > 0)
        {
            bestRoundElements[0].text = FormatTimer(saveData.longestRoundTime);
        }
        else
        {
            bestRoundElements[0].text = defaultTimerValue;
        }

        bestRoundElements[1].text = saveData.bestStarsCollected[1].ToString();
        bestRoundElements[2].text = saveData.bestNumberOfDodges.ToString();

        lifetimeElements[0].text = saveData.numberOfRoundsPlayedLifetime.ToString();
        lifetimeElements[2].text = saveData.starsCollectedLifetime[1].ToString();
        lifetimeElements[1].text = saveData.numberOfDodgesLifetime.ToString();
    }
Exemple #4
0
        private void Awake()
        {
            audioManager = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <AudioManager>();

            sceneChangerInterface = new SceneChanger();
            sceneChangerInterface.transitionsAnim = anim;

            menuSystem             = new MenuSystem();
            menuSystem.menuOptions = options;

            gameData = SaveManager.LoadGame();

            musicSlider.value = gameData.musicVolume;
            sfxSlider.value   = gameData.sfxVolume;

            audioMixer.SetFloat("musicVolume", gameData.musicVolume);
            audioMixer.SetFloat("sfxVolume", gameData.sfxVolume);

            buttonImages[0].color = buttonColours[1];
        }
Exemple #5
0
        /// <summary>
        /// Sets up the game data version for this round of the game...
        /// </summary>
        private void DataSetup()
        {
            saveData = SaveManager.LoadGame();
            saveData.numberOfDodges = 0;

            // changing crusher colours
            for (int i = 0; i < crusherController.crusherObjects.Length; i++)
            {
                crusherController.crusherObjects[i].GetComponentsInChildren <SpriteRenderer>()[1].color = Converters.ConvertFloatArrayToColor(saveData.crusherColour);
                crusherController.crusherObjects[i].GetComponentsInChildren <SpriteRenderer>()[5].color = Converters.ConvertFloatArrayToColor(saveData.crusherColour);
            }

            // editing the game BG to match the crusher BG
            gameBG.color = Converters.ConvertFloatArrayToColor(saveData.crusherColour);

            // change the player stuff xD
            playerScript.SetParticleColour(Converters.ConvertColourToParticleSystemGradient(Converters.ConvertFloatArrayToColor(saveData.playerColour)), saveData.playerShapeChoice - 1);

            saveData.starsCollected[0] = 0;
            saveData.starsCollected[1] = 0;
        }
        /// <summary>
        /// Loads the Crushing game data
        /// </summary>
        /// <returns>The Loaded CrushingData</returns>
        public static CrushingData LoadCrushing()
        {
            string SavePath = Application.persistentDataPath + "/crushing.masf";

            if (File.Exists(SavePath))
            {
                BinaryFormatter Formatter = new BinaryFormatter();
                FileStream      Stream    = new FileStream(SavePath, FileMode.Open);

                CrushingData _data = Formatter.Deserialize(Stream) as CrushingData;

                Stream.Close();

                return(_data);
            }
            else
            {
                Debug.LogError("Save file not found! (Crushing - Load)");
                return(null);
            }
        }
Exemple #7
0
        private void Start()
        {
            fadeAnim.SetTrigger("isInScene");

            loadedData = SaveManager.LoadGame();

            // Round Stats
            if (loadedData.lastRoundTime > 0)
            {
                timerTxt.text = FormatTimer(loadedData.lastRoundTime);
            }

            if (loadedData.starsCollected[1] > 0)
            {
                starTxt.text = loadedData.starsCollected[1].ToString();
            }
            else
            {
                starTxt.text = 0.ToString();
            }

            if (loadedData.numberOfDodges > 0)
            {
                dodgeTxt.text = loadedData.numberOfDodges.ToString();
            }
            else
            {
                dodgeTxt.text = 0.ToString();
            }


            // PB Stats
            if (loadedData.longestRoundTime > 0)
            {
                pbTimeTxt.text = FormatTimer(loadedData.longestRoundTime);
            }

            if (loadedData.bestStarsCollected[1] > 0)
            {
                pbStarTxt.text = loadedData.bestStarsCollected[1].ToString();
            }
            else
            {
                pbStarTxt.text = 0.ToString();
            }

            if (loadedData.bestNumberOfDodges > 0)
            {
                pbDodgeTxt.text = loadedData.bestNumberOfDodges.ToString();
            }
            else
            {
                pbDodgeTxt.text = 0.ToString();
            }

            // Check for achievements earned in the last round played...
            //CheckForAchievements();

            // Update Tracking Info
            ++loadedData.numberOfRoundsPlayedLifetime;
            loadedData.numberOfDodgesLifetime += loadedData.numberOfDodges;

            sceneChanger = new SceneChanger();
            sceneChanger.transitionsAnim = crusherTransitionAnim;
        }
        /*
         * Format Types
         *
         * masf = Micro Arcade Save File
         * malf = Micro Arcade Leaderboard File
         *
         */
        /// <summary>
        /// Creates all the save files with default vlaues if they do not exist on the system (helps avoid errors later on)
        /// </summary>
        public static void InitialseFiles()
        {
            BinaryFormatter _formatter   = new BinaryFormatter();
            string          baseSavePath = Application.persistentDataPath;

            FileStream _stream;

            // Create Save Files
            // /settings.masf
            if (!File.Exists(baseSavePath + "/settings.masf"))
            {
                _stream = new FileStream(baseSavePath + "/settings.masf", FileMode.Create);
                ArcadeData _settingsData = new ArcadeData();
                _formatter.Serialize(_stream, _settingsData);
                _stream.Close();
            }

            // /controlconfig.masf -- is not made here as it works when you first run the project with a multi input
            //if (!File.Exists(baseSavePath + "/controlconfig.masf"))
            //{
            //    _stream = new FileStream(baseSavePath + "/controlconfig.masf", FileMode.Create);
            //    ArcadeData _controlData = new ArcadeData();
            //    _formatter.Serialize(_stream, _controlData);
            //    _stream.Close();
            //}

            // /arcadeonline.masf
            if (!File.Exists(baseSavePath + "/arcadeonline.masf"))
            {
                _stream = new FileStream(baseSavePath + "/arcadeonline.masf", FileMode.Create);
                ArcadeOnlinePaths _onlineData = new ArcadeOnlinePaths();
                _formatter.Serialize(_stream, _onlineData);
                _stream.Close();
            }



            // Pinball Save Files

            // /ultimatepinball.masf
            if (!File.Exists(baseSavePath + "/ultimatepinball.masf"))
            {
                _stream = new FileStream(baseSavePath + "/ultimatepinball.masf", FileMode.Create);
                UltimatePinballData _pinballData = new UltimatePinballData();
                _formatter.Serialize(_stream, _pinballData);
                _stream.Close();
            }

            // /ultimatepinballsession.masf
            if (!File.Exists(baseSavePath + "/ultimatepinballsession.masf"))
            {
                _stream = new FileStream(baseSavePath + "/ultimatepinballsession.masf", FileMode.Create);
                UltimatePinballSessionData _pinballSessionData = new UltimatePinballSessionData();
                _formatter.Serialize(_stream, _pinballSessionData);
                _stream.Close();
            }

            // /ultimatepinballsession.malf
            if (!File.Exists(baseSavePath + "/ultimatepinball.malf"))
            {
                _stream = new FileStream(baseSavePath + "/ultimatepinball.malf", FileMode.Create);
                _formatter.Serialize(_stream, null);
                _stream.Close();
            }



            // Operation Starshine Save Files

            // /operationstarshine.masf
            if (!File.Exists(baseSavePath + "/operationstarshine.masf"))
            {
                _stream = new FileStream(baseSavePath + "/operationstarshine.masf", FileMode.Create);
                OperationStarshineData _operationStarshineData = new OperationStarshineData();
                _formatter.Serialize(_stream, _operationStarshineData);
                _stream.Close();
            }

            // /operationstarshine.malf
            if (!File.Exists(baseSavePath + "/operationstarshine.malf"))
            {
                _stream = new FileStream(baseSavePath + "/operationstarshine.malf", FileMode.Create);
                StarshineLeaderboardData _operationStarshineLeaderboardData = new StarshineLeaderboardData();
                _formatter.Serialize(_stream, _operationStarshineLeaderboardData);
                _stream.Close();
            }



            // Quacking Time Save Files

            // /quackingtime.masf
            if (!File.Exists(baseSavePath + "/quackingtime.masf"))
            {
                _stream = new FileStream(baseSavePath + "/quackingtime.masf", FileMode.Create);
                QuackingTimeData _quackingTimeData = new QuackingTimeData();
                _formatter.Serialize(_stream, _quackingTimeData);
                _stream.Close();
            }



            // Crushing Save Files

            // /crushing.masf
            if (!File.Exists(baseSavePath + "/crushing.masf"))
            {
                _stream = new FileStream(baseSavePath + "/crushing.masf", FileMode.Create);
                CrushingData _crushingData = new CrushingData();
                _formatter.Serialize(_stream, _crushingData);
                _stream.Close();
            }
        }