playMaker

Author Topic: Best way to store player's progress?  (Read 2094 times)

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Best way to store player's progress?
« on: January 09, 2017, 12:13:22 PM »
Hi there,

My app will have +1000 levels, maybe even 5000 someday. They are currently being stored in an XML file. I'd like to save player progress too. But with all the levels being in an xml file and not "physically" in scene, how can I reference on like which level excatly was completed etc? I know I can probably achieve that by writing this out in XML, and then reading at the start of the app but how do you actually save stuff in xml in datamaker, is there a documentation or a guide?


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Best way to store player's progress?
« Reply #1 on: January 10, 2017, 02:15:11 AM »
Hi,

Yes, you can do it all in Xml, I've done this in the past on large games with lots of levels and it works fine.

you need:

-- a referencing system for all your levels ( chapter 1, level 1, etc etc)
-- then as your player starts you create an empty xml that you save in PlayerPrefs as a string ( only during pauses or in menu, to avoid hickups during the game play).
-- create nodes representing the state of a particular level, for example how may stars got picked up ( you may want to have unique Id's for your stars too), how far did the player go, etc etc.

however, are you sure 5000 levels make sense? while it's totally possible, I would be careful with memory consumption, and I would likely cut down by chapters with 1000 levels per chapter and then you'll have 5 xml files, one for each chapter, this way you keep things affordable on mobile in terms of memory.


the great benefit of this is that you can easily debug your logic because everything is in plain english in the xml files, so as you create features or test level progression you can follow exactly what things are saved and when.


Bye,

 Jean

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: Best way to store player's progress?
« Reply #2 on: January 10, 2017, 05:04:15 AM »
Yep, well it's not really 5000 levels like all in one, it's got a structure, There are 3 difficulties, Beginner, intermediate, advance and then in each difficulty there is 12 categories, and then in each category there is 1-9 lessons and in each lessons you have like 5-15 "Levels". It's an educational app to learn english, it will have mini-games, quizes and voice recognition. So at the moment everything is in one scene and I have 3 views.. For difficulties and it's categories, for lessons and for actual gameplay. So when you go to screen for diffs and categories, it reads from XML all the difficulties and cats and puts them in ugui on a nice grid layout. Then when you click on a category it does the same thing but with lessons  and then when you click on lessons it will actually play all the levels within that lesson as specified in xml. So i got to a point where all this is working and I have 3 mini-games working so far but the progress doesn't save yet so i'm looking into that first. Also, i'm unsure on how to handle translations, some instructions will be native including the gui, providing that I arleady store content in xml, how could I handle the translations Jean? :P
« Last Edit: January 10, 2017, 05:16:11 AM by elusiven »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Best way to store player's progress?
« Reply #3 on: January 11, 2017, 04:42:52 AM »
Hi,

 Translation is totally ok to do with Xml too,

I would recommend creating Ids for every string you need to use in your game. Then you need a manager and for every places where you need a text you get the id within that text and query the manager for the translated version. Based on the current selected language, you'll have the right xml loaded ( the xml will be a list of node with ID and translated content).

I would recommend doing a custom action for this, or else what I would do is use ArrayMaker Hashtable or two FsmArray, where you put all Id's as keys and all translated content as values.

here's a possible way for your xml

FileName: Translation_fr_FR.xml
<Content id="Hello">Bonjour</Content>
<Content id="Surname">Prenom</Content>


Make sure to use "fr_FR" language ISO standard description: http://www.lingoes.net/en/translator/langcode.htm
 

you could also use https://crowdin.com/ ( we use this for PlayMaker, it's amazing!), it does the same thing: here's a sample:

<?xml version="1.0" encoding="utf-8"?>
<!--Generated by crowdin.com-->
<!--
Crowdin.net Sample Android XML resource file
Copyright (C) 2014
-->
<resources>
  <string name="welcome">Bienvenue !</string>
  <string name="save_as">Save as...</string>
  <string name="view">View</string>
  <string name="about">About...</string>
  <string name="about_me">About Me</string>
  <string name="current_password">Current Password</string>
  <string name="new_password">New Password</string>
  <string name="confirm_password">Confirm New Password</string>
  <string name="change_password">Change Password</string>
  <string name="password_recover">Password recover</string>
  <string name="password_reset_success">Your password reseted successully!</string>
  <string name="read_message">Read message</string>
  <string name="confirm_delete">Are you sure you want to delete this message?</string>
  <string name="search_in_messages">Search in messages</string>
  <string name="compose_messages">Compose Message</string>
  <string name="no_data">No date provided</string>
  <string name="quick_start">Quick Start</string>
</resources>


 Bye,

 Jean

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: Best way to store player's progress?
« Reply #4 on: January 11, 2017, 06:23:13 AM »
Last question on this topic Jean, sorry :D

I've had a go at saving and reading xml string using easy save 2 with encryption and it seems to work great, I can use maths on it to count things too which is also great but what's the most efficient way to access this string? Let's say it gets bigger to thousands of lines. Do I just open the xml string when the app launches and then while playing I can perform actions on it and then when the app quits or sleeps I just save the string again or is there a difference in performance when I just open and save the string everytime I want to perform an action on it, like let's say I create global events to count all completed levels out of that lesson, and let's say that player needs 80% completed to go to next lesson, do I need to open and save each time I do things like this... Or just on app start and quit/sleep? And are global events okay to do things like that or is there more efficient way? Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Best way to store player's progress?
« Reply #5 on: January 12, 2017, 01:18:03 AM »
Hi,

 You are on the right path.

 you must load and save xml only when the gameplay is paused, so it's during menus likely or when the player won, you show the winning screen, some animation, and just before transiting to the next menu, you save the xml back to the prefs.

 you can read and write during the gamePlay, that's fine.

 Cut your xml so that you control it's size, do one xml file per chapter for example. and so when your player is navigating to play a particular level, when the chapter is selected, load the related xml and then transit to the level menu for that chapter.

 in short, spread the loading/saving costs in between menu transitions, it's better and will be far less intrusive then a a progress bar or a freeze at the beginning of playing a level.

 Bye,

 Jean


Bye,

 Jean