Holding database values in scene

Hi all,

Appologise if this has been asked before - I have done lots of research but cant seem to find much info on this.

I currently have a turn based card game which connects to a mysql database. I have php pages running the sql queries on the server for security measures.

My question is that when I pull out data from the db of the cards e.g. its id/value/name/type etc I want to use these on the fly e.g. if a card has a value of 100 then i need to subtract 20 from it where would these be stored in the scene?

I have read up on player prefs but not sure if this is the way to go?
To try to further explain my problem picture scenario below:

Player 1 has card A (currently i have this as a gameObject - not sure if this is best way?)

Player 2 has card B

Player 2 has multiple actions/spells that card B can use - these spells are held in the db and upon clicking a button (another gameobject?) it looks up in the db the spell/damage type then negates the health value of Player 1’s Card A.

QUESTION: how do you hold all this info that comes two and throw the database?
I have been racking my brains over the best way to achieve this but end up banging my head against a brick wall! Any help would be grately appreciated!

Also fantastic piece of software guys been hooked on unity for a good few weeks now!

Regards,

Chris192

Well are you retrieving the values on to your client now? if so why dont you just have a persistent object that talks to the server a sort of GameManager or MatchManager that would handle the input from the user, send it to the server which would relay it to the second client. Or am I completely reading into the problem wrong.

1 Answer

1

Heya,

Thank you for the reply,

After doing more research it seems i’ll need to create classes with an array that can hold this data, which i can then reuse in the game without having to keep reconnecting to the database and pulling the data out.

The values are in the client correct, it was a case of storing them in the client so that i didnt have to keep connecting to the database on every event. As stated above i didnt realise that i could create an array in an object which would store the data in variables.

Although im much stronger at javascript than c# im starting to think i may need to jump boat :stuck_out_tongue: