// Use this for initialization void Start() { GameObject gameUtils = GameObject.Find("GameUtils"); m_saveLoadHandler = gameUtils.GetComponent <SaveLoadHandler>(); m_unitBuilder = gameUtils.GetComponent <UnitBuilder>(); List <ModuleTypeMap> modulePrefabs = new List <ModuleTypeMap>(m_unitBuilder.m_modulePrefabs); List <Dropdown.OptionData> options = new List <Dropdown.OptionData>(); // Add all hulls to menu (this seems possibly silly) options.Add(new Dropdown.OptionData()); foreach (ModuleTypeMap modulePair in modulePrefabs) { string moduleName = modulePair.prefab.name; if (moduleName.ToLower().Contains("hull")) { options.Add(new Dropdown.OptionData(moduleName)); } } m_hullDropDown.ClearOptions(); m_hullDropDown.AddOptions(options); m_hullDropDown.onValueChanged.AddListener(delegate { HullSelected(m_hullDropDown); }); m_moduleDropdown.ClearOptions(); m_moduleDropdown.onValueChanged.AddListener(delegate { ModuleSelected(m_moduleDropdown); }); m_saveButton.onClick.AddListener(delegate { SaveToFile(); }); //m_loadButton.onClick.AddListener(delegate { LoadFromFile(); }); }
AsyncOperation op; // Holds the async operation. Used to 'allowSceneActivation'. void OnTriggerEnter2D(Collider2D other) { if (other == switch_point.GetComponent <Collider2D>()) { if (setGravity != null) { GravityWarp.gravity = setGravity; } Info.gameTime += Camera.main.GetComponent <GravityWarp>().leveltmr; Info.checkpoint = new Vector3(0, 0, 0); SaveLoadHandler.playerScene = nextLevel; SaveLoadHandler.Save(); op.allowSceneActivation = true; } else if (other == exit_point.GetComponent <Collider2D>()) { if (asyncLoad && !loadOnce) { loadOnce = true; Debug.Log("Loading " + nextLevel); op = SceneManager.LoadSceneAsync(nextLevel); op.allowSceneActivation = false; if (exitDoor != null) { exitDoor.GetComponent <Door>().ActivateLink(1); } } } }
public override void OnInteractEvent() { base.OnInteractEvent(); Debug.Log("Interact to save"); uiHandler.showSave = true; GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerControllerScript>().HealPlayer(-1); SaveLoadHandler.SaveGame(thisSavePoint); StartCoroutine(Save()); }
void Awake() { s_schedule = w_schedule.GetComponent <ScheduleHandler>(); s_playerStatus = w_playerStatus.GetComponent <StatusHandler>(); s_characterInfo = w_characterInfo.GetComponent <CharacterInfoHandler>(); s_saveload = w_saveload.GetComponent <SaveLoadHandler>(); //debugData(); /*uncoment to make new file*/ loadData(SaveLoadManager.loadData(1)); }
public void LoadGameButton() { //diskten okunan bilginin tekrardan kayit objesine donusturulmesi loadedString = SaveLoadHandler.LoadString(); SaveObject loadObject = JsonUtility.FromJson <SaveObject>(loadedString); //kayit objesinin icindeki bilgilerin gerekli yerlere atanmasi movementControl.transform.position = loadObject.playerPosition; playerStats.Health = loadObject.playerHealth; playerStats.Score = float.Parse(loadObject.score); Debug.Log("Game Loaded"); }
// Use this for initialization void Start() { GameObject gameUtils = GameObject.Find("GameUtils"); m_saveLoadHandler = gameUtils.GetComponent <SaveLoadHandler>(); m_unitBuilder = gameUtils.GetComponent <UnitBuilder>(); string unitToLoad = m_thisUnit.ToString(); SavedModule savedUnit = m_saveLoadHandler.M_LoadUnitFromFile(unitToLoad); GameObject spawnedUnit = m_unitBuilder.M_BuildUnit(savedUnit, transform); spawnedUnit.GetComponent <BaseUnit>().m_alignment = m_alignment; }
void Awake() { // Basically makes this a singleton, in case we ever instantiate. if (master == null) { DontDestroyOnLoad(gameObject); master = this; } else if (master != this) { Destroy(gameObject); } }
/************************ ** Public methods *************************/ /// <summary>The mod entry point, called after the mod is first loaded.</summary> /// <param name="helper">Provides simplified APIs for writing mods.</param> public override void Entry(IModHelper helper) { // SMAPI helpers ModEntry.SHelper = helper; ModEntry.SMonitor = this.Monitor; // Config settings Config = this.Helper.ReadConfig <ModConfig>(); // SMAPI console command handler Commander = new CommandHandler(this); // Pet and Horse creation handler Creator = new CreationHandler(this); // Save/Load logic handler SaverLoader = new SaveLoadHandler(this); // Event Listeners helper.Events.GameLoop.SaveLoaded += SaveLoadHandler.Setup; helper.Events.GameLoop.SaveLoaded += SaveLoadHandler.LoadData; helper.Events.GameLoop.Saving += SaveLoadHandler.SaveData; helper.Events.GameLoop.Saved += SaveLoadHandler.LoadData; helper.Events.GameLoop.ReturnedToTitle += SaveLoadHandler.StopUpdateChecks; helper.Events.GameLoop.DayStarted += Creator.ProcessNewDay; helper.Events.GameLoop.DayEnding += Creator.ProcessEndDay; helper.Events.Display.RenderingHud += RenderHoverTooltip; // SMAPI Commands helper.ConsoleCommands.Add("list_creatures", $"Lists the creature IDs and skin IDs of the given type.\n(Options: '{string.Join("', '", CommandHandler.CreatureGroups)}', or a specific animal type (such as bluechicken))", Commander.OnCommandReceived); helper.ConsoleCommands.Add("randomize_all_skins", "Randomizes the skins for every farm animal, pet, and horse on the farm.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("randomize_skin", "Randomizes the skin for the given creature. Call `randomize_skin <animal/pet/horse> <creature ID>`. To find a creature's ID, call `list_creatures`.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("set_skin", "Sets the skin of the given creature to the given skin ID. Call `set_skin <skin ID> <animal/pet/horse> <creature ID>`. To find a creature's ID, call `list_creatures`.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("corral_horses", "Warp all horses to the farm's stable, giving you the honor of being a clown car chauffeur.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("horse_whistle", "Summons one of the player's horses to them. Can be called with a horse's ID to call a specific horse. To find a horse's ID, call `list_creatures horse`.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("sell", "Used to give away one of your pets or horses. Call `sell <pet/horse> <creature ID>`. To find a creature's ID, call `list_creatures`.", Commander.OnCommandReceived); // DEBUG if (Config.DebuggingMode) { helper.ConsoleCommands.Add("debug_reset", "DEBUG: ** WARNING ** Resets all skins and creature IDs, but ensures that all creatures are properly in the Adopt & Skin system.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("debug_skinmaps", "DEBUG: Prints all info in current skin maps", Commander.OnCommandReceived); helper.ConsoleCommands.Add("debug_idmaps", "DEBUG: Prints AnimalLongToShortIDs", Commander.OnCommandReceived); helper.ConsoleCommands.Add("debug_pets", "DEBUG: Print the information for every Pet instance on the map", Commander.OnCommandReceived); helper.ConsoleCommands.Add("debug_horses", "DEBUG: Print the information for every Horse instance on the map", Commander.OnCommandReceived); helper.ConsoleCommands.Add("debug_find", "DEBUG: Locate the creature with the given ID. Call `debug_find <horse/pet/animal> <creature ID>`.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("summon_stray", "DEBUG: Summons a new stray at Marnie's.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("summon_horse", "DEBUG: Summons a wild horse. Somewhere.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("debug_clearunowned", "DEBUG: Removes any wild horses or strays that exist, to clear out glitched extras", Commander.OnCommandReceived); } }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(transform.gameObject); }
// Start is called before the first frame update void Start() { questHandler = this.GetComponent <QuestHandler>(); saveLoadHandler = this.GetComponent <SaveLoadHandler>(); if (locationParent != null) { for (int i = 0; i < locationParent.childCount; i++) { GameObject location = locationParent.GetChild(i).gameObject; locations.Add(location); } } //Debug.Log("Locations: " + locations.Count); }
public void Init() { Scene.Init(); SaveLoadHandler.LoadDefault(); //Call changed scenegraph MessageHub.Publish <ScenegraphChanged>(new ScenegraphChanged(Scene, this)); if (!Engine.IsStarted) { Engine.Start(); } //Init the scenegraph }
public void SaveGameButton() { //kayit icin gerekli kayit nesnesinin olusturulmasi ve degerlerin atanmasi SaveObject saveObject = new SaveObject { playerPosition = playerCurrentPosition, score = transform.Find("ScoreText").gameObject.GetComponent <Text>().text, playerHealth = playerCurrentHealth }; //nesnenin json formatina cevirilmesi ve kayit icin static kayit sinifina yollanmasi json = JsonUtility.ToJson(saveObject); SaveLoadHandler.SaveString(json); //YAPILACAK: Oyunun kaydedildigine dair bilgiyi ekranda gostermek icin ui eklemesi yap Debug.Log("Game Saved"); }
void Start() { warpTextTimer = warpTextDelay; GravityWarp.gravity = "D"; button.GetComponent <UnityEngine.UI.Button>().onClick.AddListener(() => { Load(); }); if (name == "button_resume") { SaveLoadHandler.Load(); if (SaveLoadHandler.playerScene != null && SaveLoadHandler.playerScene != "credits") { scene = SaveLoadHandler.playerScene; } else { scene = "Story"; Info.gameTime = 0; } } }
// Start is called before the first frame update void Start() { foreach (Button b in gameButtons) { PlayerSave ps = SaveLoadHandler.LoadGame(gameButtons.IndexOf(b)); if (ps != null) { b.interactable = true; b.GetComponentInChildren <Text>().text = "Start Game " + ps.saveIndex; playerSaves.Add(ps); //get button from serialized list //hide button //Add to list //Set text to be save data ex: % time and last save local } else { b.GetComponentInChildren <Text>().text = "New Game"; } b.gameObject.SetActive(false); } if (playerSaves.Count <= 0) { system.firstSelectedGameObject = newGameButton.gameObject; continueButton.gameObject.SetActive(false); newGameButton.gameObject.SetActive(true); } else { system.firstSelectedGameObject = continueButton.gameObject; continueButton.gameObject.SetActive(true); newGameButton.gameObject.SetActive(false); } backButton.gameObject.SetActive(false); //if() button list isbigger than max save dont show new game button //also for continue, dont show for continue if more than one game popUp.SetActive(false); }
public void Load(int index) { gameIndex = index; if (SceneManager.GetSceneByName(mainMenu).isLoaded) { SceneManager.UnloadSceneAsync(mainMenu); } SceneManager.LoadScene(testPauseUI, LoadSceneMode.Additive); SceneManager.LoadScene(playerScene, LoadSceneMode.Additive); PlayerSave thisSave = SaveLoadHandler.LoadGame(gameIndex); if (thisSave == null) { Debug.Log("Room Not or First Save"); SceneManager.LoadScene(testLoadScene, LoadSceneMode.Additive); occuredEvents = new List <string>(); playerStartPos = Vector2.zero; currentMaxHealth = 6; keyItemStates = new List <KeyItemState>(); foreach (string s in keyItems) { keyItemStates.Add(new KeyItemState(s, false)); } } else { Debug.Log("Loading at room " + thisSave.lastSavePoint.roomName); SceneManager.LoadScene(thisSave.lastSavePoint.roomName, LoadSceneMode.Additive); playerStartPos = thisSave.lastSavePoint.location; occuredEvents = thisSave.eventsTriggered; currentMaxHealth = thisSave.currentMaxHealth; keyItemStates = new List <KeyItemState>(); foreach (KeyItemState s in thisSave.keyItems) { keyItemStates.Add(s); } } }
public void Load() { ClearInventory(); PlayerData loadedPlayer = SaveLoadHandler.LoadPlayer(); _LevelHandler.LoadLevel(loadedPlayer.currentlevel, loadedPlayer.currentleveldata); Name = loadedPlayer.stringstats [0]; Gender = loadedPlayer.stringstats [1]; Health = loadedPlayer.intstats [0]; Physical = loadedPlayer.intstats [1]; Combat = loadedPlayer.intstats [2]; Engineering = loadedPlayer.intstats [3]; Science = loadedPlayer.intstats [4]; Subtle = loadedPlayer.intstats [5]; Charisma = loadedPlayer.intstats [6]; Vector3 vectortemp = new Vector3(loadedPlayer.playerx, loadedPlayer.playery, loadedPlayer.playerz); transform.position = vectortemp; SpecialDialogueMarkers.AddRange(loadedPlayer.stringmarkers); PickedUpItems.AddRange(loadedPlayer.pickedupitems); Inventory.itemList.AddRange(_GlobalItemHandler.LoadItems(loadedPlayer.inventorystring)); EquipedHeadItem = _GlobalItemHandler.ConvertStringToItem(loadedPlayer.headitem); _GlobalItemHandler.tempitemlist.itemList.Clear(); foreach (Race race in RaceList) { if (loadedPlayer.race == race.RaceName) { PlayerRace = race; break; } } Debug.Log("Character Loaded!"); //Inventory = loadedPlayer.inventory; }
/// <summary> /// Loads a level selected by the user in a dialogue /// </summary> /// <param name="sender">Sender of the "click" event</param> /// <param name="e">Mouse Args from "click" event</param> private void HandleLoad(object sender, RoutedEventArgs e) { //Select File to Load OpenFileDialog loadFileDialogue = new OpenFileDialog() { Filter = "Image Files (*.png)|*.png" }; //If we have clicked ok after selecting a folder to load our level from, then start to attempt to load the level if (loadFileDialogue.ShowDialog() == DialogResult.OK) { //Breakup File name (without extentsion) and path string fileName = System.IO.Path.GetFileNameWithoutExtension(loadFileDialogue.FileName); string fileDirectory = System.IO.Path.GetDirectoryName(loadFileDialogue.FileName); //Load files SaveLoadHandler loadHandler = new SaveLoadHandler(); loadHandler.LoadLevel(levelGrid, fileName, fileDirectory); //Update Level Name in Info bar infoBar.UpdateLevelNameUI(fileName); } }
/// <summary> /// Saves the current level along with metadata /// </summary> /// <param name="sender">Sender of the "click" event</param> /// <param name="e">Mouse Args from "click" event</param> private void HandleSave(object sender, RoutedEventArgs e) { //Do not try and save an empty grid if (levelGrid.GridBoxSize == 0) { return; } //Hide the grid lines while we save the image, so that they are not saved in the image itself levelGrid.TileGrid.ShowGridLines = false; //Create a folder browser so that the user can choose a folder to save in SaveFileDialog saveFolderDialogue = new SaveFileDialog() { Filter = "Image Files (*.png)|*.png" }; //If we have clicked ok after selecting a folder to save our level to then save the level if (saveFolderDialogue.ShowDialog() == DialogResult.OK) { //Breakup File name and path string fileName = System.IO.Path.GetFileNameWithoutExtension(saveFolderDialogue.FileName); string fileDirectory = System.IO.Path.GetDirectoryName(saveFolderDialogue.FileName); //Save files SaveLoadHandler saveHandler = new SaveLoadHandler(); saveHandler.SaveLevel(levelGrid, fileName, fileDirectory); //Update Level Name in Info bar infoBar.UpdateLevelNameUI(fileName); } //Re-show grid lines levelGrid.TileGrid.ShowGridLines = true; }
void Awake() { w_saveload = GameObject.FindGameObjectWithTag("SaveLoad"); s_saveload = w_saveload.GetComponent <SaveLoadHandler>(); if (this.gameObject.name.Contains("Save")) { this.gameObject.GetComponent <Button>().interactable = true; } if (this.gameObject.name.Contains("Load")) { this.gameObject.GetComponent <Button>().interactable = false; } if (s_saveload.IsSave) { if (this.gameObject.name.Contains("Save")) { this.gameObject.GetComponent <Button>().interactable = false; } if (this.gameObject.name.Contains("Load")) { this.gameObject.GetComponent <Button>().interactable = true; } } }
/************************ ** Public methods *************************/ /// <summary>The mod entry point, called after the mod is first loaded.</summary> /// <param name="helper">Provides simplified APIs for writing mods.</param> public override void Entry(IModHelper helper) { // SMAPI helpers ModEntry.SHelper = helper; ModEntry.SMonitor = this.Monitor; // Config settings Config = this.Helper.ReadConfig <ModConfig>(); // Internal helpers Commander = new CommandHandler(this); Creator = new CreationHandler(this); SaverLoader = new SaveLoadHandler(this); var loaders = Helper.Content.AssetLoaders; loaders.Add(this); WildHorse.PlayerSpecifiedSpawnMaps = new List <string>(Config.WildHorseSpawnLocations); // Check that Wild Horse spawn maps set in the Config file are all valid foreach (string loc in Config.WildHorseSpawnLocations) { if (!WildHorse.SpawningMaps.Contains(Sanitize(loc))) { SMonitor.Log($"Invalid map \"{loc}\" is listed in Wild Horse spawning locations and will be ignored.\nMaps must all be one of: Forest, BusStop, Mountain, Town, Railroad, or Beach.", LogLevel.Warn); WildHorse.PlayerSpecifiedSpawnMaps.Remove(loc); } } // Event Listeners helper.Events.GameLoop.SaveLoaded += SaveLoadHandler.Setup; helper.Events.GameLoop.SaveLoaded += SaveLoadHandler.LoadData; helper.Events.GameLoop.Saving += SaveLoadHandler.SaveData; helper.Events.GameLoop.Saved += SaveLoadHandler.LoadData; helper.Events.GameLoop.ReturnedToTitle += SaveLoadHandler.StopUpdateChecks; helper.Events.GameLoop.DayStarted += Creator.ProcessNewDay; helper.Events.GameLoop.DayEnding += Creator.ProcessEndDay; // SMAPI Commands helper.ConsoleCommands.Add("list_creatures", $"Lists the creature IDs and skin IDs of the given type.\n(Options: '{string.Join("', '", CommandHandler.CreatureGroups)}', or a specific animal type (such as bluechicken))", Commander.OnCommandReceived); helper.ConsoleCommands.Add("randomize_skin", $"Randomizes the skin for the given group of creatures or the creature with the given ID. Call `randomize_skin <creature group or creature ID>`.\nCallable creature groups: {string.Join(",", CommandHandler.CreatureGroups)}, or an adult creature type\nTo find a creature's ID, call `list_creatures`.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("set_skin", "Sets the skin of the given creature to the given skin ID. Call `set_skin <skin ID> <creature ID>`. To find a creature's ID, call `list_creatures`.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("corral_horses", "Warp all horses to the farm's stable, giving you the honor of being a professional clown car chauffeur.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("horse_whistle", "Summons one of the player's horses to them. Can be called with a horse's ID to call a specific horse. To find a horse's ID, call `list_creatures horse`.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("rename", "Renames the pet or horse of the given ID to the given name. Call `rename <creature ID> \"new name\"`.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("sell", "Used to give away one of your pets or horses. Call `sell <creature ID>`. To find a creature's ID, call `list_creatures`.", Commander.OnCommandReceived); // DEBUG if (Config.DebuggingMode) { helper.ConsoleCommands.Add("debug_asreset", "DEBUG: ** WARNING ** Resets all skins and creature IDs, but ensures that all creatures are properly in the Adopt & Skin system.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("debug_skinmaps", "DEBUG: Prints all info in current skin maps", Commander.OnCommandReceived); helper.ConsoleCommands.Add("debug_idmaps", "DEBUG: Prints AnimalLongToShortIDs", Commander.OnCommandReceived); helper.ConsoleCommands.Add("debug_pets", "DEBUG: Print the information for every Pet instance on the map", Commander.OnCommandReceived); helper.ConsoleCommands.Add("debug_horses", "DEBUG: Print the information for every Horse instance on the map", Commander.OnCommandReceived); helper.ConsoleCommands.Add("debug_find", "DEBUG: Locate the creature with the given ID. Call `debug_find <creature ID>`.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("summon_stray", "DEBUG: Summons a new stray at Marnie's.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("summon_horse", "DEBUG: Summons a wild horse. Somewhere.", Commander.OnCommandReceived); helper.ConsoleCommands.Add("debug_clearunowned", "DEBUG: Removes any wild horses or strays that exist, to clear out glitched extras", Commander.OnCommandReceived); } }
void Awake() { w_saveload = GameObject.FindGameObjectWithTag("SaveLoad"); Debug.Log(w_saveload); s_saveload = w_saveload.GetComponent <SaveLoadHandler>(); }
public void Save() { SaveLoadHandler.SavePlayer(this); Debug.Log("Character Saved!"); }
void Start() { if (slHandler == null) { slHandler = this; } else if (slHandler != this) { Destroy (gameObject); } for(int i = 0; i < MAX_SLOTS; ++i) { String newFileName = Application.persistentDataPath + "/ComaPlayerData" + i.ToString() + ".dat"; if(!File.Exists(newFileName)) File.Create(newFileName); } }