Resume Game

Announcements, support questions, and discussion for the Dialogue System.
davidsibya08
Posts: 57
Joined: Sun Feb 12, 2017 2:11 pm

Resume Game

Post by davidsibya08 »

Good day! How can my button check if there are already saved game? Like it will have a different function if the game is saved.

For example, I play the game where there is no saved data yet, so the button is 'New Game'. While playing, I will save the game. But, I didn't completed any quest yet. I just save the game so when I return to the main menu, I am expecting to see a 'Resume' button rather than having a 'New Game' button.

It is something like that. :)
User avatar
Tony Li
Posts: 20838
Joined: Thu Jul 18, 2013 1:27 pm

Re: Resume Game

Post by Tony Li »

You may be interested in the Menu Framework on the Dialogue System Extras page. It's the first download button in the EXTRAS section. The Menu Framework gives you a main menu and gameplay pause menu with options to save, load, and continue games. You can save to PlayerPrefs or encrypted disk files. It also has an options menu to adjust video, audio, and subtitle settings.

If you decide not to use the Menu Framework, and if you're using GameSaver, you can check PlayerPrefs for the saved game:

Code: Select all

int slot = 0;
var gameSaver = FindObjectOfType<GameSaver>();
var hasSavedGame = PlayerPrefs.HasKey(gameSaver.playerPrefsKey + slot); 
davidsibya08
Posts: 57
Joined: Sun Feb 12, 2017 2:11 pm

Re: Resume Game

Post by davidsibya08 »

Woah! I did not expect that is already in here! Amazing. I was just about to ask that later, then boom! It's already here. Hahaha. Thank you sir!

I have another question sir Tony. Is it possible to rename the slot names to the last quest I accomplished under "main quest" group?
Last edited by davidsibya08 on Tue Apr 11, 2017 10:51 pm, edited 2 times in total.
User avatar
Tony Li
Posts: 20838
Joined: Thu Jul 18, 2013 1:27 pm

Re: Resume Game

Post by Tony Li »

davidsibya08 wrote:Is it possible to rename the slot names to the last quest I accomplished under "main quest" group?
Yes. Set a variable named "CurrentStage" to the name of the quest.

For example, let's say the player completes a quest by entering a trigger collider. You can set up a Dialogue System Trigger like this:

Image

This component:
  • Sets the quest to success.
  • Sets the variable "CurrentStage" to the name of the quest.
  • Shows an alert message to tell the player that the quest is complete.
The Menu Framework's SaveHelper will save the value of "CurrentStage" with the saved game. It will also save the current system time. If you don't want to save the current system time, untick the Save Helper's Include Time In Summary checkbox.

When you browse saved games, it will look like this:

Image

You can of course customize the layout and images of the Menu Framework. There are other ways you can customize the appearance of the Load Game panel, too. For example, you can inspect the Load Game Panel component and assign your own method to the On Set Details event.
davidsibya08
Posts: 57
Joined: Sun Feb 12, 2017 2:11 pm

Re: Resume Game

Post by davidsibya08 »

In addition, can I have different loading screens? I am still working on this. Like in some instances, If I am to go in a certain village I want a modified loading screen that will provided information about the village, and not sticking to the original one which is index 1 in the build settings.

Lastly, why is that in the example. All things are functioning while when i applied it on my game the load and save are malfunctioning. In the gameplay, when
I save the game and load it all data are gone and empty. When I save it, and go back to main menu there is the continue and load button functioning but when I load/continue all data are gone and empty again. But, in the example given nothing is wrong. Is it because of the NPC Persistence or what?
User avatar
Tony Li
Posts: 20838
Joined: Thu Jul 18, 2013 1:27 pm

Re: Resume Game

Post by Tony Li »

Hi,
davidsibya08 wrote:In addition, can I have different loading screens? I am still working on this. Like in some instances, If I am to go in a certain village I want a modified loading screen that will provided information about the village, and not sticking to the original one which is index 1 in the build settings.
Set SaveHelper's loadingSceneIndex before loading.
davidsibya08 wrote:Lastly, why is that in the example. All things are functioning while when i applied it on my game the load and save are malfunctioning. In the gameplay, when I save the game and load it all data are gone and empty. When I save it, and go back to main menu there is the continue and load button functioning but when I load/continue all data are gone and empty again. But, in the example given nothing is wrong. Is it because of the NPC Persistence or what?
This relies on the Dialogue System's Save System. The Save System only saves the data that you specify. For example, to save an NPC's position, add a Persistent Position Data component to it.
davidsibya08
Posts: 57
Joined: Sun Feb 12, 2017 2:11 pm

Re: Resume Game

Post by davidsibya08 »

I already got the Load and Save sir! I think that it has a conflict with the script that I am using because when i removed the scripts it worked perfectly fine. It conflicts with my achievement script and I don't really know why. But since I removed the script it already work as expected.

I get the index of the loading screen sir. What I'm trying is to load other loading screens that when the player will load a scene (that is the main village) it will load different loading screen. Is that possible?

Thank you sir Tony! :)
User avatar
Tony Li
Posts: 20838
Joined: Thu Jul 18, 2013 1:27 pm

Re: Resume Game

Post by Tony Li »

At what point are you loading the main village scene? When loading a saved game, or when changing scenes during gameplay?

If it's when changing scenes during gameplay, use the SaveHelper.LoadLevel() method, or the LoadingSceneTo() sequencer command added by the Menu Framework.

For example, you can create a Sequence Trigger set to OnTriggerEnter that will move the player to the Main Village when the player enters the trigger collider. Set up the Sequence Trigger with these values:
  • Trigger: OnTriggerEnter
  • Condition > Accepted Tags > Element 0: Player
  • Sequence: LoadingSceneTo(Main Village,5,Village Entrance)
This assumes that you've set up an empty GameObject (named "Village Entrance") where you want the player to appear in the Main Village scene.

The LoadingSceneTo() sequencer command is documented on the last page of the Menu Framework manual.
davidsibya08
Posts: 57
Joined: Sun Feb 12, 2017 2:11 pm

Re: Resume Game

Post by davidsibya08 »

Oh! I got it! I'm sorry for not finishing to read the document. Thank you sir Tony! :)
User avatar
Tony Li
Posts: 20838
Joined: Thu Jul 18, 2013 1:27 pm

Re: Resume Game

Post by Tony Li »

No worries! If you need me to clarify anything, just let me know.
Post Reply