示例#1
0
        SpellIconPack ReadMetadata(string path)
        {
            string json = File.ReadAllText(path);

            return(SaveLoadManager.Deserialize(typeof(SpellIconPack), json) as SpellIconPack);
        }
示例#2
0
 public void Init(SaveLoadManager saveLoadManager, InputManager inputManager)
 {
     _saveLoadManager = saveLoadManager;
     _inputManager    = inputManager;
     AddListeners();
 }
 public void LoadGame()
 {
     SaveLoadManager.LoadPlayer();
     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
 }
示例#4
0
 private void Awake()
 {
     instance = this;
     saveFile = Application.persistentDataPath + "/save.bin";
 }
示例#5
0
 public static void Save()
 {
     SaveLoadManager.SaveData();
 }
示例#6
0
    //MADNESS

    public string LoadShip(string _shipname)
    {
        return(SaveLoadManager.LoadShip(_shipname));
    }
        /// <summary>
        /// Checks a region for added location data. (i.e. new locations)
        /// </summary>
        /// <param name="regionIndex">Region index</param>
        /// <param name="locationIndex">Location index</param>
        /// <param name="dfRegion">DFRegion data output updated with any added locations found</param>
        /// <returns>True if added blocks had indices assigned, false otherwise</returns>
        public static bool GetDFRegionAdditionalLocationData(int regionIndex, ref DFRegion dfRegion)
        {
            if (DaggerfallUnity.Settings.AssetInjection && ModManager.Instance != null)
            {
                // If found, return a previously cached DFRegion
                if (regions.ContainsKey(regionIndex))
                {
                    if (regions[regionIndex].LocationCount != noReplacementRegion.LocationCount)
                    {
                        dfRegion = regions[regionIndex];
                        return(true);
                    }
                    return(false);
                }
                // Setup local lists for the region arrays and record the location count from data
                uint          dataLocationCount         = dfRegion.LocationCount;
                List <string> mapNames                  = new List <string>(dfRegion.MapNames);
                List <DFRegion.RegionMapTable> mapTable = new List <DFRegion.RegionMapTable>(dfRegion.MapTable);
                bool newBlocksAssigned                  = false;

                // Seek from loose files
                string   locationPattern = string.Format("locationnew-*-{0}.json", regionIndex);
                string[] fileNames       = Directory.GetFiles(worldDataPath, locationPattern);
                foreach (string fileName in fileNames)
                {
                    string     locationReplacementJson = File.ReadAllText(Path.Combine(worldDataPath, fileName));
                    DFLocation dfLocation = (DFLocation)SaveLoadManager.Deserialize(typeof(DFLocation), locationReplacementJson);
                    newBlocksAssigned = AddLocationToRegion(regionIndex, ref dfRegion, ref mapNames, ref mapTable, ref dfLocation);
                }
                // Seek from mods
                string           locationExtension = string.Format("-{0}.json", regionIndex);
                List <TextAsset> assets            = ModManager.Instance.FindAssets <TextAsset>(worldData, locationExtension);
                if (assets != null)
                {
                    foreach (TextAsset locationReplacementJsonAsset in assets)
                    {
                        DFLocation dfLocation = (DFLocation)SaveLoadManager.Deserialize(typeof(DFLocation), locationReplacementJsonAsset.text);
                        newBlocksAssigned &= AddLocationToRegion(regionIndex, ref dfRegion, ref mapNames, ref mapTable, ref dfLocation);
                    }
                }
                // If found any new locations for this region,
                if (dfRegion.LocationCount > dataLocationCount)
                {
                    // Update the region arrays from local lists
                    dfRegion.MapNames = mapNames.ToArray();
                    dfRegion.MapTable = mapTable.ToArray();

#if !UNITY_EDITOR  // Cache region data for added locations if new blocks have been assigned indices (unless running in editor)
                    if (newBlocksAssigned)
                    {
                        regions.Add(regionIndex, dfRegion);
                    }
#endif
                    Debug.LogFormat("Added {0} new DFLocation's to region {1}, indexes: {2} - {3}",
                                    dfRegion.LocationCount - dataLocationCount, regionIndex, dataLocationCount, dfRegion.LocationCount - 1);
                    return(true);
                }

#if !UNITY_EDITOR // Cache that there's no replacement region data, so only look for added locations once per region (unless running in editor)
                regions.Add(regionIndex, noReplacementRegion);
#endif
            }
            return(false);
        }
        // Start new character to location specified in INI
        void StartNewCharacter()
        {
            DaggerfallUnity.ResetUID();
            QuestMachine.Instance.ClearState();
            RaiseOnNewGameEvent();
            DaggerfallUI.Instance.PopToHUD();
            ResetWeaponManager();
            SaveLoadManager.ClearSceneCache(true);
            GameManager.Instance.GuildManager.ClearMembershipData();

            // Must have a character document
            if (characterDocument == null)
            {
                characterDocument = new CharacterDocument();
            }

            // Assign character sheet
            PlayerEntity playerEntity = FindPlayerEntity();

            playerEntity.AssignCharacter(characterDocument);

            // Set game time
            DaggerfallUnity.Instance.WorldTime.Now.SetClassicGameStartTime();

            // Set time tracked in playerEntity
            playerEntity.LastGameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();

            // Get start parameters
            DFPosition mapPixel       = new DFPosition(DaggerfallUnity.Settings.StartCellX, DaggerfallUnity.Settings.StartCellY);
            bool       startInDungeon = DaggerfallUnity.Settings.StartInDungeon;

            // Read location if any
            DFLocation location = new DFLocation();

            ContentReader.MapSummary mapSummary;
            bool hasLocation = DaggerfallUnity.Instance.ContentReader.HasLocation(mapPixel.X, mapPixel.Y, out mapSummary);

            if (hasLocation)
            {
                if (!DaggerfallUnity.Instance.ContentReader.GetLocation(mapSummary.RegionIndex, mapSummary.MapIndex, out location))
                {
                    hasLocation = false;
                }
            }

            if (NoWorld)
            {
                playerEnterExit.DisableAllParents();
            }
            else
            {
                // Start at specified location
                StreamingWorld streamingWorld = FindStreamingWorld();
                if (hasLocation && startInDungeon && location.HasDungeon)
                {
                    if (streamingWorld)
                    {
                        streamingWorld.TeleportToCoordinates(mapPixel.X, mapPixel.Y);
                        streamingWorld.suppressWorld = true;
                    }
                    playerEnterExit.EnableDungeonParent();
                    playerEnterExit.StartDungeonInterior(location);
                }
                else
                {
                    playerEnterExit.EnableExteriorParent();
                    if (streamingWorld)
                    {
                        streamingWorld.SetAutoReposition(StreamingWorld.RepositionMethods.Origin, Vector3.zero);
                        streamingWorld.suppressWorld = false;
                    }
                }
            }

            // Assign starting gear to player entity
            DaggerfallUnity.Instance.ItemHelper.AssignStartingGear(playerEntity);

            // Setup bank accounts and houses
            Banking.DaggerfallBankManager.SetupAccounts();
            Banking.DaggerfallBankManager.SetupHouses();

            // Initialize region data
            playerEntity.InitializeRegionData();

            // Randomize weathers
            GameManager.Instance.WeatherManager.SetClimateWeathers();

            // Start game
            GameManager.Instance.PauseGame(false);
            DaggerfallUI.Instance.FadeBehaviour.FadeHUDFromBlack();
            DaggerfallUI.PostMessage(PostStartMessage);

            lastStartMethod = StartMethods.NewCharacter;

            // Offer main quest during pre-alpha
            QuestMachine.Instance.InstantiateQuest("__MQSTAGE00");

            // Launch startup optional quest
            if (!string.IsNullOrEmpty(LaunchQuest))
            {
                QuestMachine.Instance.InstantiateQuest(LaunchQuest);
                LaunchQuest = string.Empty;
            }
            // Launch any InitAtGameStart quests
            GameManager.Instance.QuestListsManager.InitAtGameStartQuests();

            if (OnStartGame != null)
            {
                OnStartGame(this, null);
            }
        }
示例#9
0
 void Awake()
 {
     saveLoadPlayer = new SaveLoadManager <PlayerData>();
     saveLoadMap    = new SaveLoadManager <MapData>("map_data");
 }
示例#10
0
 public void LoadData()
 {
     SaveLoadManager.Load <CharacterData>(this, this.name);
 }
示例#11
0
 public void SaveScores()
 {
     SaveLoadManager.SaveScore(this);
 }
示例#12
0
 public void SaveData()
 {
     SaveLoadManager.Save <CharacterData>(this, this.name);
 }
 /// <summary>
 /// A method used to remove all save files associated to progress
 /// </summary>
 public virtual void ResetProgress()
 {
     SaveLoadManager.DeleteSaveFolder("MMRetroAdventureProgress");
 }
示例#14
0
 public void Save()
 {
     SaveLoadManager.SaveTilemap(terrainMap, filename);
 }
示例#15
0
	void Awake(){
		SLManager = this;
	}
示例#16
0
 public void CloseSettingPanel()
 {
     SaveLoadManager.Save_SettingData();
     AudioManager.Instance.playSound(AudioType.BUTTON_SOUND);
     settingPanel.SetActive(false);
 }
示例#17
0
 private void OnEnable()
 {
     _manager = target as SaveLoadManager;
 }
示例#18
0
 static void Postfix(SaveLoadManager __instance, ref IEnumerator __result)
 {
     __result = PostfixAsync(__instance, __result);
 }
        // perform fast travel actions
        private void performFastTravel()
        {
            RaiseOnPreFastTravelEvent();

            // Cache scene first, if fast travelling while on ship.
            if (GameManager.Instance.TransportManager.IsOnShip())
            {
                SaveLoadManager.CacheScene(GameManager.Instance.StreamingWorld.SceneName);
            }
            GameManager.Instance.StreamingWorld.RestoreWorldCompensationHeight(0);
            GameManager.Instance.StreamingWorld.TeleportToCoordinates((int)endPos.X, (int)endPos.Y, StreamingWorld.RepositionMethods.DirectionFromStartMarker);

            if (speedCautious)
            {
                GameManager.Instance.PlayerEntity.CurrentHealth  = GameManager.Instance.PlayerEntity.MaxHealth;
                GameManager.Instance.PlayerEntity.CurrentFatigue = GameManager.Instance.PlayerEntity.MaxFatigue;
                if (!GameManager.Instance.PlayerEntity.Career.NoRegenSpellPoints)
                {
                    GameManager.Instance.PlayerEntity.CurrentMagicka = GameManager.Instance.PlayerEntity.MaxMagicka;
                }
            }

            DaggerfallUnity.WorldTime.DaggerfallDateTime.RaiseTime(travelTimeTotalMins * 60);

            // Halt random enemy spawns for next playerEntity update so player isn't bombarded by spawned enemies at the end of a long trip
            GameManager.Instance.PlayerEntity.PreventEnemySpawns = true;

            // Vampires and characters with Damage from Sunlight disadvantage never arrive between 6am and 6pm regardless of travel type
            // Otherwise raise arrival time to just after 7am if cautious travel would arrive at night
            if (GameManager.Instance.PlayerEffectManager.HasVampirism() || GameManager.Instance.PlayerEntity.Career.DamageFromSunlight)
            {
                if (DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.IsDay)
                {
                    DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.RaiseTime(
                        (DaggerfallDateTime.DuskHour - DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.Hour) * 3600);
                }
            }
            else if (speedCautious)
            {
                if ((DaggerfallUnity.WorldTime.DaggerfallDateTime.Hour < 7) ||
                    ((DaggerfallUnity.WorldTime.DaggerfallDateTime.Hour == 7) && (DaggerfallUnity.WorldTime.DaggerfallDateTime.Minute < 10)))
                {
                    float raiseTime = (((7 - DaggerfallUnity.WorldTime.DaggerfallDateTime.Hour) * 3600)
                                       + ((10 - DaggerfallUnity.WorldTime.DaggerfallDateTime.Minute) * 60)
                                       - DaggerfallUnity.WorldTime.DaggerfallDateTime.Second);
                    DaggerfallUnity.WorldTime.DaggerfallDateTime.RaiseTime(raiseTime);
                }
                else if (DaggerfallUnity.WorldTime.DaggerfallDateTime.Hour > 17)
                {
                    float raiseTime = (((31 - DaggerfallUnity.WorldTime.DaggerfallDateTime.Hour) * 3600)
                                       + ((10 - DaggerfallUnity.WorldTime.DaggerfallDateTime.Minute) * 60)
                                       - DaggerfallUnity.WorldTime.DaggerfallDateTime.Second);
                    DaggerfallUnity.WorldTime.DaggerfallDateTime.RaiseTime(raiseTime);
                }
            }

            DaggerfallUI.Instance.UserInterfaceManager.PopWindow();
            travelWindow.CloseTravelWindows(true);
            GameManager.Instance.PlayerEntity.RaiseSkills();
            DaggerfallUI.Instance.FadeBehaviour.FadeHUDFromBlack();

            RaiseOnPostFastTravelEvent();
        }
示例#20
0
 private void Awake()
 {
     Instance = this;
     StartCoroutine(InitLoad());
 }
        /// <summary>
        /// Checks for replacement location data.
        /// </summary>
        /// <param name="regionIndex">Region index</param>
        /// <param name="locationIndex">Location index</param>
        /// <param name="dfLocation">DFLocation data output</param>
        /// <returns>True if replacement data found, false otherwise</returns>
        public static bool GetDFLocationReplacementData(int regionIndex, int locationIndex, out DFLocation dfLocation)
        {
            if (DaggerfallUnity.Settings.AssetInjection)
            {
                int    locationKey = MakeLocationKey(regionIndex, locationIndex);
                bool   newLocation;
                string variant            = WorldDataVariants.GetLocationVariant(locationKey, out newLocation);
                string locationVariantKey = locationKey.ToString() + variant;

                // If it's a new location variant, pre-load it into cache
                if (newLocation && !locations.ContainsKey(locationVariantKey))
                {
                    if (!LoadNewDFLocationVariant(regionIndex, locationIndex, variant))
                    {
                        locationVariantKey = locationKey.ToString();    // Fall back to non-variant if load fails
                    }
                }
                // If found, return a previously cached DFLocation
                if (locations.ContainsKey(locationVariantKey))
                {
                    dfLocation = locations[locationVariantKey];
                    return(dfLocation.LocationIndex != noReplacementLocation.LocationIndex);
                }

                string fileName = GetDFLocationReplacementFilename(regionIndex, locationIndex, variant);
                TextAsset locationReplacementJsonAsset;

                // Seek from loose files
                if (File.Exists(Path.Combine(worldDataPath, fileName)))
                {
                    string locationReplacementJson = File.ReadAllText(Path.Combine(worldDataPath, fileName));
                    dfLocation = (DFLocation)SaveLoadManager.Deserialize(typeof(DFLocation), locationReplacementJson);
                }
                // Seek from mods
                else if (ModManager.Instance != null && ModManager.Instance.TryGetAsset(fileName, false, out locationReplacementJsonAsset))
                {
                    dfLocation = (DFLocation)SaveLoadManager.Deserialize(typeof(DFLocation), locationReplacementJsonAsset.text);
                }
                else
                {
#if !UNITY_EDITOR // Cache that there's no replacement location data, for non-variant. So only look for replaced locations once (unless running in editor)
                    if (variant == WorldDataVariants.NoVariant)
                    {
                        locations.Add(locationVariantKey, noReplacementLocation);
                    }
#endif
                    dfLocation = noReplacementLocation;
                    return(false);
                }
                // Assign any new blocks in this location a block index if they haven't already been assigned
                if (AssignBlockIndices(ref dfLocation))
                {
#if !UNITY_EDITOR   // Cache location data for replaced locations if new blocks have been assigned indices (unless running in editor)
                    locations.Add(locationVariantKey, dfLocation);
#endif
                }
                Debug.LogFormat("Found DFLocation override, region:{0}, index:{1} variant:{2}", regionIndex, locationIndex, variant);
                return(true);
            }
            dfLocation = noReplacementLocation;
            return(false);
        }
示例#22
0
 public EnergyController(SaveLoadManager _saveLoadManager)
 {
     saveLoadManager = _saveLoadManager;
 }
        private void UpdateMode(TransportModes transportMode)
        {
            // Update the transport mode and stop any riding sounds playing.
            mode = transportMode;
            if (ridingAudioSource.isPlaying)
            {
                ridingAudioSource.Stop();
            }

            if (mode == TransportModes.Horse || mode == TransportModes.Cart)
            {
                // Tell player motor we're riding.
                playerMotor.IsRiding = true;

                // Setup appropriate riding sounds.
                SoundClips sound = (mode == TransportModes.Horse) ? horseRidingSound2 : cartRidingSound;
                ridingAudioSource.clip = dfAudioSource.GetAudioClip((int)sound);

                // Setup appropriate riding textures.
                string textureName = (mode == TransportModes.Horse) ? horseTextureName : cartTextureName;
                for (int i = 0; i < 4; i++)
                {
                    ridingTexures[i] = ImageReader.GetImageData(textureName, 0, i, true, true);
                }
                ridingTexture = ridingTexures[0];

                // Initialise neighing timer.
                neighTime = Time.time + Random.Range(1, 5);
            }
            else
            {
                // Tell player motor we're not riding.
                playerMotor.IsRiding = false;
            }

            if (mode == TransportModes.Ship)
            {
                GameManager.Instance.PlayerMotor.CancelMovement = true;
                SerializablePlayer serializablePlayer = GetComponent <SerializablePlayer>();
                DaggerfallUI.Instance.FadeBehaviour.SmashHUDToBlack();
                StreamingWorld world      = GameManager.Instance.StreamingWorld;
                DFPosition     shipCoords = DaggerfallBankManager.GetShipCoords();

                // Is there recorded position before boarding and is player on the ship?
                if (IsOnShip())
                {
                    // Check for terrain sampler changes. (so don't fall through floor)
                    StreamingWorld.RepositionMethods reposition = StreamingWorld.RepositionMethods.None;
                    if (boardShipPosition.terrainSamplerName != DaggerfallUnity.Instance.TerrainSampler.ToString() ||
                        boardShipPosition.terrainSamplerVersion != DaggerfallUnity.Instance.TerrainSampler.Version)
                    {
                        reposition = StreamingWorld.RepositionMethods.RandomStartMarker;
                        if (DaggerfallUI.Instance.DaggerfallHUD != null)
                        {
                            DaggerfallUI.Instance.DaggerfallHUD.PopupText.AddText("Terrain sampler changed. Repositioning player.");
                        }
                    }
                    // Restore player position from before boarding ship, caching ship scene first.
                    SaveLoadManager.CacheScene(world.SceneName);    // TODO: Should this should move into teleport to support other teleports? Issue only if inside. (e.g. recall)
                    DFPosition mapPixel = MapsFile.WorldCoordToMapPixel(boardShipPosition.worldPosX, boardShipPosition.worldPosZ);
                    world.TeleportToCoordinates(mapPixel.X, mapPixel.Y, reposition);
                    serializablePlayer.RestorePosition(boardShipPosition);
                    boardShipPosition = null;
                    // Restore cached scene (ship is special case, cache will not be cleared)
                    SaveLoadManager.RestoreCachedScene(world.SceneName);
                }
                else
                {
                    // Record current player position before boarding ship, and cache scene. (ship is special case, cache will not be cleared)
                    boardShipPosition = serializablePlayer.GetPlayerPositionData();
                    SaveLoadManager.CacheScene(world.SceneName);
                    // Teleport to the players ship, restoring cached scene.
                    world.TeleportToCoordinates(shipCoords.X, shipCoords.Y, StreamingWorld.RepositionMethods.RandomStartMarker);
                    SaveLoadManager.RestoreCachedScene(world.SceneName);
                }
                DaggerfallUI.Instance.FadeBehaviour.FadeHUDFromBlack();
                mode = TransportModes.Foot;
            }
        }
示例#24
0
 void DoLoadGame()
 {
     SaveLoadManager.LoadData();
     List <string> scenes = SaveLoadManager.Instance.gameData.loadedScenes;
 }
示例#25
0
 public static PlayerData Load()
 {
     return(SaveLoadManager.LoadData());
 }
示例#26
0
 private void OnDisable()
 {
     //Saving the highscore
     SaveLoadManager.SaveObject(scoreSavestate);
 }
        /// <summary>
        /// Assigns starting spells to the spellbook item for a new character.
        /// </summary>
        void SetStartingSpells(PlayerEntity playerEntity, CharacterDocument characterDocument)
        {
            if (characterDocument.classIndex > 6 && !characterDocument.isCustom) // Class does not have starting spells
            {
                return;
            }

            // Get starting set based on class
            int spellSetIndex = -1;

            if (characterDocument.isCustom)
            {
                DFCareer dfc = characterDocument.career;

                // Custom class uses Spellsword starting spells if it has at least 1 primary or major magic skill
                if (Enum.IsDefined(typeof(DFCareer.MagicSkills), (int)dfc.PrimarySkill1) ||
                    Enum.IsDefined(typeof(DFCareer.MagicSkills), (int)dfc.PrimarySkill2) ||
                    Enum.IsDefined(typeof(DFCareer.MagicSkills), (int)dfc.PrimarySkill3) ||
                    Enum.IsDefined(typeof(DFCareer.MagicSkills), (int)dfc.MajorSkill1) ||
                    Enum.IsDefined(typeof(DFCareer.MagicSkills), (int)dfc.MajorSkill2) ||
                    Enum.IsDefined(typeof(DFCareer.MagicSkills), (int)dfc.MajorSkill3))
                {
                    spellSetIndex = 1;
                }
            }
            else
            {
                spellSetIndex = characterDocument.classIndex;
            }

            if (spellSetIndex == -1)
            {
                return;
            }

            // Get the set's spell indices
            TextAsset spells = Resources.Load <TextAsset>("StartingSpells") as TextAsset;
            List <CareerStartingSpells> startingSpells = SaveLoadManager.Deserialize(typeof(List <CareerStartingSpells>), spells.text) as List <CareerStartingSpells>;
            List <StartingSpell>        spellsToAdd    = new List <StartingSpell>();

            for (int i = 0; i < startingSpells[spellSetIndex].SpellsList.Length; i++)
            {
                spellsToAdd.Add(startingSpells[spellSetIndex].SpellsList[i]);
            }

            // Add spells to player from standard list
            foreach (StartingSpell spell in spellsToAdd)
            {
                SpellRecord.SpellRecordData spellData;
                GameManager.Instance.EntityEffectBroker.GetClassicSpellRecord(spell.SpellID, out spellData);
                if (spellData.index == -1)
                {
                    Debug.LogError("Failed to locate starting spell in standard spells list.");
                    continue;
                }

                EffectBundleSettings bundle;
                if (!GameManager.Instance.EntityEffectBroker.ClassicSpellRecordDataToEffectBundleSettings(spellData, BundleTypes.Spell, out bundle))
                {
                    Debug.LogError("Failed to create effect bundle for starting spell.");
                    continue;
                }
                playerEntity.AddSpell(bundle);
            }
        }
示例#28
0
 private void Awake()
 {
     //Trying to load the scoreSavestate if one was already saved
     SaveLoadManager.LoadObject(scoreSavestate);
 }
示例#29
0
        void WriteMetadata(SpellIconPack pack, string path)
        {
            string json = SaveLoadManager.Serialize(pack.GetType(), pack);

            File.WriteAllText(path, json);
        }
示例#30
0
 public void Save()
 {
     SaveLoadManager.SavePlayer(this, saveFileName);
 }
 void Awake()
 {
     m_instance = this;
 }
示例#32
0
    public string LoadShipType(string _shipName)
    {
        shipType = SaveLoadManager.LoadShipType(_shipName);

        return(shipType);
    }
	public void SetUpMenu()
	{
		//Clean up menu and then recreate all the buttons again
		foreach (Transform child in transform)
		{
			GameObject.Destroy (child.gameObject);
		}

		//Update Menu Rect Transform
		top = 0.5f;
		bottom = 200f;

		//Count the amount of save files there are
		string _FileLocation= Application.dataPath; 
		DirectoryInfo  di = new DirectoryInfo (_FileLocation);		
		int numXML = di.GetFiles("*.xml", SearchOption.TopDirectoryOnly).Length;

		//Find autosave xml and quick save files and take that number away from numXML so it can instantiate correct number of save games
		int autosaveXML = di.GetFiles ("Autosave.xml", SearchOption.TopDirectoryOnly).Length;
		int quicksaveXML = di.GetFiles ("Quicksave.xml", SearchOption.TopDirectoryOnly).Length;

		SaveLoadManager[] saveLoadManager = new SaveLoadManager[numXML];
		long[] latestTime = new long[numXML];

		numXML = numXML - autosaveXML - quicksaveXML;

		GameObject[] loadButtons = new GameObject[numXML];

		//This is not a save menu then show Autosave and quick save buttons
		if(!isSaveMenu)
		{
			if(autosaveXML > 0)
			{
				GameObject autosave = Instantiate (autosaveButton, Vector3.zero, Quaternion.identity) as GameObject;
				SaveLoadManager autosaveManager = autosave.GetComponent<SaveLoadManager>();
				autosave.transform.SetParent (this.transform, false);
				autosaveManager.LoadButtonUpdate (0);	//int doesn't matter
				saveLoadManager[numXML + autosaveXML - 1] = autosave.gameObject.GetComponent<SaveLoadManager>();
			}
			if(quicksaveXML >0)
			{
				GameObject quicksave = Instantiate (quicksaveButton, Vector3.zero, Quaternion.identity) as GameObject;
				SaveLoadManager quicksaveManager = quicksave.GetComponent<SaveLoadManager>();
				quicksave.transform.SetParent (this.transform, false);
				quicksaveManager.LoadButtonUpdate (0);	//int doesn't matter
				saveLoadManager[numXML + autosaveXML + quicksaveXML - 1] = quicksave.gameObject.GetComponent<SaveLoadManager>();
			}
		}

		//If there is an xml file
		if(numXML > 0)
		{
			//Instantiate Buttons into arrays
			for (int i = 0; i < numXML; i++)
			{
				loadButtons[i] = Instantiate (button, Vector3.zero, Quaternion.identity) as GameObject;
				//Get Components
				saveLoadManager[i] = loadButtons[i].gameObject.GetComponent<SaveLoadManager>();
				
				//Parent the arrays into this object
				loadButtons[i].transform.SetParent(this.transform, false);
				//loadButtons[i].transform.parent = this.transform;
				
				//Send Save Numbers according to their array 
				saveLoadManager[i].LoadButtonUpdate (i + 1);
				
				bottom -= 100f;	//Make the window size according to the amound of buttons. -200 per button
			}

			int latest = 0;
			if(!isSaveMenu)
			{
				//Find the most recent save 
				for (int l = 0; l < saveLoadManager.Length; l++)
				{
					latestTime[l] = saveLoadManager[l].saveLatestTime;
					//print ("File "+l+"= "+latestTime[l]);
				}
			}
			else
			{
				//Find the most recent save 
				for (int l = 0; l < numXML; l++)
				{
					latestTime[l] = saveLoadManager[l].saveLatestTime;
					//print ("File "+l+"= "+latestTime[l]);
				}
			}

			//print (saveLoadManager.Length + " " + latestTime.Length);
			latest = (int)MaxValue(latestTime);
			saveLoadManager[latest].MarkLatest ();
			//print (latest);

			//Check for the latest save file whether quick save, auto save or normal and mark the latest
			if(!isSaveMenu)
			{
				if(latest == numXML + autosaveXML + quicksaveXML - 1)
				{
					SaveLoadManager.latestQuicksave = true;
					SaveLoadManager.latestAutosave = false;
				}
				else if (latest == numXML + autosaveXML - 1)
				{
					SaveLoadManager.latestAutosave = true;
					SaveLoadManager.latestQuicksave = false;
				}
				else
				{
					SaveLoadManager.latestSave = latest + 1; 
					SaveLoadManager.latestAutosave = false;
					SaveLoadManager.latestQuicksave = false;
				}
			}
		}
		
		//Set Transform of the Scrollview so that each button will fit
		rectTransform = (RectTransform)transform; 
		rectTransform.offsetMin = new Vector2(rectTransform.offsetMin.x, bottom);
		rectTransform.offsetMax = new Vector2(rectTransform.offsetMax.x, top);
	}
示例#34
0
 void Awake()
 {
     instance = this;
     ResetUndoMoves();
     TempSavePath = Application.dataPath + "/tempSystemSave.wok";
     //init for saveLoadMediaFolder is done in SendToPaletteButton.cs
 }