playMaker

Author Topic: Datamaker (xml) setup  (Read 9217 times)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Datamaker (xml) setup
« on: July 08, 2015, 05:07:22 PM »
Hi,

I am trying to figure out how to do this.

i got my xml setup like this :
Code: [Select]
<?xml version="1.0" encoding="ISO-8859-1"?>
<upgrades>
<prefab>
<category>Cat1</category>
<prefabName>Prefab 1</prefabName>
<status>Locked</status>
<required>1</required>
<price>20</price>
</prefab>

<prefab>
<category>Cat1</category>
<prefabName>Prefab 2</prefabName>
<status>Locked</status>
<required>5</required>
<price>50</price>
</prefab>

<prefab>
<category>Cat1</category>
<prefabName>Prefab 3</prefabName>
<status>Locked</status>
<required>10</required>
<price>30</price>
</prefab>

<prefab>
<category>Cat1</category>
<prefabName>Prefab 3</prefabName>
<status>Unlocked</status>
<required>10</required>
<price>25</price>
</prefab>
</upgrades>


and i use the action xml Select Nodes to get the Locked items with this xpath query :
Code: [Select]
//prefab[status="Unlocked"]/prefabName
after this i want to get the prefab names sorted by price.
but i can't figure it out yet.

DarkSoul

  • Playmaker Newbie
  • *
  • Posts: 37
Re: Datamaker (xml) setup
« Reply #1 on: July 08, 2015, 06:29:30 PM »
Hello,

I have a solution if this was a Ui prefab in ngui using uiGird.cs sort alphabetically

If you have figured how to get the info from inside xml to your game and assigned each prefab there atturbites [ name , price ,...]

If so you can make a sort manger that have a int variable [how to sort] ( 1 Name 2 Price .. )

The prefab get this int and compares it [ it should already have string variables name , price ]
If sort manger int is 1 Then set owner(theprefab) name to the variable string name
If it was 2 Set owner name to variable string price

In sort manger wait a short while then invoke or call UiGrid.cs to sort accordingly to there gameobjects names .

This will work I have tried it own other thing similar.

I hope it helps.  :)


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Datamaker (xml) setup
« Reply #2 on: July 09, 2015, 03:41:00 AM »
Hi,
isn't it possible with xpath Functions?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Datamaker (xml) setup
« Reply #3 on: July 09, 2015, 09:14:49 AM »
Hi,

yep, xpath has comparision operators:

http://www.w3schools.com/xpath/xpath_operators.asp

Bye,

 Jean

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Datamaker (xml) setup
« Reply #4 on: July 09, 2015, 06:49:46 PM »
i am a bit lost on how to set this up to get the prefab name (unlocked) sorted by price

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Datamaker (xml) setup
« Reply #5 on: July 10, 2015, 11:14:18 AM »
bump

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Datamaker (xml) setup
« Reply #6 on: July 10, 2015, 11:29:52 AM »
Hi,

 yeah, please let me go trhough monday and tuesday, else, bump me on tuesday, ok? I'll come up with a working sample.

Bye,

 Jean

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Datamaker (xml) setup
« Reply #7 on: July 10, 2015, 12:04:06 PM »
thx jean,

if i get the hang of it i will try if i can make some tutorials for datamaker.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Datamaker (xml) setup
« Reply #8 on: July 13, 2015, 06:51:39 PM »
Bump, just a reminder :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Datamaker (xml) setup
« Reply #9 on: July 15, 2015, 04:14:15 AM »
another bump :)

i am kinda stuck in my project until i can get this made :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Datamaker (xml) setup
« Reply #10 on: July 15, 2015, 08:07:44 AM »
Hi,

 Sorry for the wait, trying to keep up :)

 Please find attached a working sample working on Unity 4.

-- you have a book list with prices
-- the PlayMaker inspector shows min and max price and a search button, click on search
-- the fsm deselect all books ( all children, and send the event "DESELECT")
-- the fsm filters the books given that price range
-- then it goes trhough each filtered book and select them ( send event "SELECT)

so with this you have everything to start building a listing that you can enable or disable.

IF you plan on disabling gameobject, make sure you keep them into an Array ( using ArrayMaker), cause disabled gameobject can't be searched withint he hierarchy.

one possible improvment here is to populate the books using xml, here I went to the point and created them by hand with just their id, but really they should be popluated with an fsm that feature all the xml data as fsm variables.

Let me know if this helps.

I don't put this on the ecosystem, I want PlayMaker 1.8 to be out first and clean up the existing samples.


 Bye,

 Jean

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Datamaker (xml) setup
« Reply #11 on: July 15, 2015, 02:34:08 PM »
Hi,
no problem, i understand.

thank you for the sample.

i understand more now how it works,

but is it possible to loop trough from lowest price to highest price?

because i have a canvas with a panel and a vertical layout group where i will set my buttons as child inside. (they come from a different off screen object)
they will be shown from top to bottom depending on what position they are as a child.

i got everything working as i want to, only not yet sorted.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Datamaker (xml) setup
« Reply #12 on: July 16, 2015, 05:00:36 AM »
Hi,

 sorting is not possible with xpath, you would have to do the sorting yourself. Typically, one way if you don't want to script would be using arrayMaker.

have two arrays, where indexes matches, that is the book id at index x has it's price also at index x
first array lists book id
second array lists prices

make a third array as a copy of prices but you sort it.
then you can take the prices from the sorted array, find the index from the price list, and with that index, you get the book id from the first array.

that's how you can do it with arrayMaker.

another way would be to rearrange childs if you are on the latests version of Unity, you can set the child index, so all your books would be iterated, and based on price of the sibling would be moved up or down the child stack. It's tricky to get this done right but that's another solution.

Bye,

 Jean

then

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Datamaker (xml) setup
« Reply #13 on: July 16, 2015, 03:09:43 PM »
hi,
I went for a HashTable and use hashtable add to add the gameobject name to a key and price as value.
hashtable seems sorts them automatically by value.
and this works for me :)

but having issues on beta,

i made a video so you can see whats going on.
please check beta forum.

greetings,
Dino

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Datamaker (xml) setup
« Reply #14 on: July 16, 2015, 07:31:12 PM »
Hi,
one more question to change properties in the xml file @ runtime,

i need to use xml set node properties right?

and then use xml save in proxy?

lets say for example i want to change the genre "Computer" to "Mac" from bk101,
and save it so the next time i play it, it has the Genre Mac.