playMaker

Author Topic: Resetting values  (Read 2231 times)

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Resetting values
« on: November 02, 2016, 12:06:59 PM »
Hi there,

I have a once scene approach in my project. I am having issues with thinking of a good way to handle all the level switching, value resetting and stuff like that...

Pretty much all my level data is in XML, so to get data for a level I would have path like this: /root/difficulty[1]/category[1]/lesson[1]/challenge[1]


There are 3 difficulties in total, in each difficulty there is 10 categories and in each category there is about 3-5 lessons. And each lesson has 10 challenges (different types of mini-game)


To start a level I would have to pick a difficulty, then category, and then lesson. Then based on which type of mini-game lesson have I would have to activate that mini-game and it's interface and then it would load the XML values. After the mini-game finishes though, how would i reset all it's values so that it may be launched again later on? Do I literally have to go and reset each variable and delete gameobjects? Or is there an easy way like, creating fsm from template, and then just deleting the fsm, and then creating again from template and so on? Maybe Store the different mini-games as prefabs and instantiate and delete or store the mini-games in different scenes, and the rest of the stuff like game logic and interface in one?
« Last Edit: November 02, 2016, 12:37:21 PM by elusiven »

cwmanley

  • Full Member
  • ***
  • Posts: 107
Re: Resetting values
« Reply #1 on: November 02, 2016, 10:21:57 PM »
You could create a reset State that receives a Global Event in each FSM that needs resetting; then after the level finishes broadcast that Event.

or use multiple scenes.

Thanks

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: Resetting values
« Reply #2 on: November 07, 2016, 07:20:45 AM »
So one event on each mini-game, and then trigger it when level finishes... Seems okay solution, still have to manually setup all the variables on each mini game to reset though which will be painful.. Thanks though.

Also, knowing that my level data is loaded from XML, is there a way to query XML with things like currentlevel, nextlevel, count all levels etc? Is there a way to count and perform actions on a xml file to find out next level, or next category etc.. or do I have to load up all the values from XML file, add them to arrays or list and then do it? Thanks :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Resetting values
« Reply #3 on: November 07, 2016, 01:26:43 PM »
Hi,
Maybe you should look into datamaker.

There are some tutorials on the User Tutorials Wiki you can check look in the category for 'xml'