Пример #1
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="gsData"></param>
 public GeneralSaveData(GeneralSaveData gsData)
 {
     this.version              = gsData.version;
     this.hsds                 = gsData.hsds;
     this.tutorialTriggers     = gsData.tutorialTriggers;
     this.achievementsUnlocked = gsData.achievementsUnlocked;
     this.aromas               = new bool[gsData.aromas.Length];
     for (int i = 0; i < this.aromas.Length; i++)
     {
         this.aromas[i] = gsData.aromas[i];
     }
     this.partyCombos        = gsData.partyCombos;
     this.pastItemData       = gsData.pastItemData;
     this.isTimer            = gsData.isTimer;
     this.isFullscreen       = gsData.isFullscreen;
     this.animationSpeed     = gsData.animationSpeed;
     this.bgmVolume          = gsData.bgmVolume;
     this.sfxVolume          = gsData.sfxVolume;
     this.resolutionWidth    = gsData.resolutionWidth;
     this.resolutionHeight   = gsData.resolutionHeight;
     this.difficultyModifier = gsData.difficultyModifier;
     this.scoreModifier      = gsData.scoreModifier;
     this.mostMonsters       = gsData.mostMonsters;
     this.mostWAX            = gsData.mostWAX;
     this.mostEvents         = gsData.mostEvents;
     this.fastestTime        = gsData.fastestTime;
 }
Пример #2
0
        /// <summary>
        /// Saves data that isn't meant to be cleared
        /// </summary>
        /// <param name="data"></param>
        public void SaveGeneralData(GeneralSaveData gsDataToSave)
        {
            ItemData pastItemData = null;

            if (pastItem != null)
            {
                if (pastItem.type == ItemConstants.CANDLE)
                {
                    pastItemData = ((Candle)pastItem).GetItemData();
                }
                else
                {
                    pastItemData = pastItem.GetItemData();
                }
            }
            gsDataToSave.pastItemData = pastItemData;

            if (gsDataToSave.mostMonsters < monstersKilled)
            {
                gsDataToSave.mostMonsters = monstersKilled;
            }
            else
            {
                gsDataToSave.mostMonsters = gsData.mostMonsters;
            }
            if (gsDataToSave.mostEvents < totalEvents)
            {
                gsDataToSave.mostEvents = totalEvents;
            }
            else
            {
                gsDataToSave.mostEvents = gsData.mostEvents;
            }
            if (gsDataToSave.mostWAX < WAXobtained)
            {
                gsDataToSave.mostWAX = WAXobtained;
            }
            else
            {
                gsDataToSave.mostWAX = gsData.mostWAX;
            }
            if (timeTaken != -1 && (timeTaken < gsData.fastestTime || gsData.fastestTime == -1))      // only update time if it was faster and the player won
            {
                gsDataToSave.fastestTime = timeTaken;
            }
            else
            {
                gsDataToSave.fastestTime = gsData.fastestTime;;
            }
            gsData = gsDataToSave;

            BinaryFormatter formatter = new BinaryFormatter();
            string          path      = Application.persistentDataPath + "/generalSave.cndl";
            FileStream      s         = new FileStream(path, FileMode.Create);

            formatter.Serialize(s, gsData);
            s.Close();
        }
Пример #3
0
        public void SaveGeneralData()
        {
            if (rData != null)      // do not update these properties if a run is currently in progress
            {
                gsDataCurrent.aromas             = gsData.aromas;
                gsDataCurrent.difficultyModifier = gsData.difficultyModifier;
                gsDataCurrent.mostMonsters       = gsData.mostMonsters;
                gsDataCurrent.mostEvents         = gsData.mostEvents;
                gsDataCurrent.mostWAX            = gsData.mostWAX;
                gsDataCurrent.fastestTime        = gsData.fastestTime;
            }

            gsData = new GeneralSaveData(gsDataCurrent);
            GameManager.instance.SaveGeneralData(gsData);
        }
Пример #4
0
        /// <summary>
        /// Load general data (highscores, settings, etc.)
        /// </summary>
        public void LoadGeneralData()
        {
            string path = Application.persistentDataPath + "/generalSave.cndl";

            if (File.Exists(path))
            {
                BinaryFormatter formatter = new BinaryFormatter();
                FileStream      s         = new FileStream(path, FileMode.Open);

                gsData = formatter.Deserialize(s) as GeneralSaveData;
                s.Close();

                if (gsData.version != 0.2f)    // TEMPORARY
                {
                    SetInitialGeneralData();
                }
                else
                {
                    UIManager.instance.isTimer      = gsData.isTimer;
                    AudioManager.instance.bgmVolume = gsData.bgmVolume;
                    AudioManager.instance.sfxVolume = gsData.sfxVolume;
                    Screen.fullScreen = gsData.isFullscreen;
                    Screen.SetResolution(gsData.resolutionWidth, gsData.resolutionHeight, Screen.fullScreen);

                    if (gsData.pastItemData != null)
                    {
                        if (gsData.pastItemData.type == ItemConstants.GEAR)
                        {
                            pastItem = new Gear(gsData.pastItemData);
                        }
                        else if (gsData.pastItemData.type == ItemConstants.CANDLE)
                        {
                            pastItem = new Candle(gsData.pastItemData);
                        }
                        else
                        {
                            pastItem = new Special(gsData.pastItemData);
                        }
                    }
                    gsDataCurrent = new GeneralSaveData(gsData);
                }
            }
            else    // default settings on first load, or if generalSaveData non existance
            {
                SetInitialGeneralData();
            }
        }
Пример #5
0
        /// <summary>
        /// Set the initial general save data for the run
        /// </summary>
        public void SetInitialGeneralData()
        {
            gsData = new GeneralSaveData(
                0.2f,   // version
                null,   // past item data
                new HighScoreData[4],
                Enumerable.Repeat <bool>(true, System.Enum.GetNames(typeof(TutorialConstants.tutorialTriggers)).Length).ToArray(),
                Enumerable.Repeat <bool>(false, System.Enum.GetNames(typeof(AchievementConstants.achievementConstants)).Length).ToArray(),
                Enumerable.Repeat <bool>(false, System.Enum.GetNames(typeof(AromaConstants.aromaConstants)).Length).ToArray(),
                null,   // partycombos
                false,  // isTimer
                1f,     // scoremodifier
                1f,     // animationspeed
                0.35f,  // bgmvolume
                1f,     // sfxvolume
                false,  // isfullscreen
                1,      // resolution width
                1,      // resolution height
                0.75f,  // difficulty modifier
                0,      // most monsters
                0,      // most wax
                0,      // most events
                -1      // fastest clear time
                );

            gsData.partyCombos = new string[, ] {
                { ClassConstants.ARCHER, ClassConstants.ARCHER },
                { ClassConstants.ARCHER, ClassConstants.MAGE },
                { ClassConstants.ARCHER, ClassConstants.ROGUE },
                { ClassConstants.ARCHER, ClassConstants.WARRIOR },
                { ClassConstants.MAGE, ClassConstants.MAGE },
                { ClassConstants.MAGE, ClassConstants.ROGUE },
                { ClassConstants.MAGE, ClassConstants.WARRIOR },
                { ClassConstants.ROGUE, ClassConstants.ROGUE },
                { ClassConstants.ROGUE, ClassConstants.WARRIOR },
                { ClassConstants.WARRIOR, ClassConstants.WARRIOR },
            };
            UIManager.instance.isTimer      = gsData.isTimer;
            AudioManager.instance.bgmVolume = gsData.bgmVolume;
            AudioManager.instance.sfxVolume = gsData.sfxVolume;

            // get and save the initial resolution the app will play at, being full screen by defaultt
            int[ , ] resolutions = new int[, ] {
                { 960, 540 },
                { 1024, 576 },
                { 1152, 648 },
                { 1280, 720 },
                { 1366, 768 },
                { 1600, 900 },
                { 1920, 1080 },
                { 2560, 1440 },
                { 3840, 2160 },
            };
            for (int i = 1; i < resolutions.GetLength(0); i++)
            {
                if (Screen.resolutions[Screen.resolutions.Length - 1].width <= resolutions[i, 0] && Screen.resolutions[Screen.resolutions.Length - 1].height <= resolutions[i, 1])
                {
                    gsData.resolutionWidth  = resolutions[i - 1, 0];
                    gsData.resolutionHeight = resolutions[i - 1, 1];
                    break;
                }
                else if (i == resolutions.GetLength(0) - 1)
                {
                    gsData.resolutionWidth  = resolutions[resolutions.Length - 1, 0];
                    gsData.resolutionHeight = resolutions[resolutions.Length - 1, 1];
                }
            }
            Screen.fullScreen = false;
            Screen.SetResolution(gsData.resolutionWidth, gsData.resolutionHeight, Screen.fullScreen);

            SaveGeneralData(gsData);
            gsDataCurrent = new GeneralSaveData(gsData);
        }