playMaker

Author Topic: In game shop weapon manager  (Read 2092 times)

QueenM56

  • Junior Playmaker
  • **
  • Posts: 55
In game shop weapon manager
« on: May 24, 2018, 02:06:24 AM »
Hi,

I want to create an in game shop for players to select their prefered weapon.
I want to list at least 10 weapons in the shop. When player has enough in game currency, they will be able to unlock the weapons and select to use one of the weapons in the game scene.
I have tried array maker. What I did is to put all the weapons in the scene, and use array manager to selectively activate one of the weapons.
However, I don't know how to connect the array to the shop UI, to archive
1. unlock the weapon with coins so it's selectable
2. select the weapon in from shop and then activate it in game scene.

Please, anyone can help with it?

Thanks
M

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: In game shop weapon manager
« Reply #1 on: May 24, 2018, 05:35:18 AM »
You will use the array to simply cycle through your weapons with shop logic. You get next through the array, and every weapon will check if there is enough coins to activate the logic for buying that weapon (simple enable/disable FSM that handles the clickable logic, maybe darken the icon or whatever). After every purchase, run through array again to disable possibility of buying the ones that are not in the price range anymore. Add bought weapons to another array ("bought weapons array", for example) and equip them in game from that array.
Available for Playmaker work

QueenM56

  • Junior Playmaker
  • **
  • Posts: 55
Re: In game shop weapon manager
« Reply #2 on: May 24, 2018, 06:52:12 AM »
Hi Krmko,
Thank you so much for your advise.
I understand the logic you described, but since I'm a newbie here, I have no idea how to execute. Could you please suggest some suitable actions that I could use to achieve this?
Also, I have some problem equipping the weapon from a store.
Currently the array list is in the game scene, but what I'm hoping is for the player to select the weapon from the store scene.
Do I need to copy the array system to the store scene to achieve it?
I feel my questions might seem dumb, but this is where I am right now T_T
Please help.
Cheers,
M

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: In game shop weapon manager
« Reply #3 on: May 24, 2018, 08:31:48 AM »
You don't need to copy the array list, you can store your arrays which will hold all necessary data in the object that will be persistent across all scenes (don't destroy on load).

I recommend using hashtables for this problem (like array list, but it has pair+value fields), since you can use the weapon name as a key, and as a value the number of coins needed to show it as buyable.

I can't really go action by action how to do it, but here's a rough diagram





Available for Playmaker work

QueenM56

  • Junior Playmaker
  • **
  • Posts: 55
Re: In game shop weapon manager
« Reply #4 on: May 24, 2018, 09:41:30 PM »
Hi Krmko,

Thank you so much for the chart! it helps a lot, really appreciate!
I will research more and figure out the rest.
A following up question, what's the best way to make data persistent? Should I save them as global, or should I use any add-on, for instance 'easy save 2'?

Many Thanks!
M

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: In game shop weapon manager
« Reply #5 on: May 25, 2018, 02:55:01 AM »
Well, everyone says avoid global variables, but if you're not going to have a lot of them, go for it. I use easy save, it's quite convenient, but you don't need to use it, you can simply have an object in the scene that will hold the arrays, hash tables and so on with FSM that has don't destroy on load action.
Available for Playmaker work

QueenM56

  • Junior Playmaker
  • **
  • Posts: 55
Re: In game shop weapon manager
« Reply #6 on: May 25, 2018, 07:38:19 AM »
Thanks Krmko!

Sorry to bother you the last time (hopefully :b)...the chart you suggested, should I put the logic in one array manager in the shop?

Cheers
M

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: In game shop weapon manager
« Reply #7 on: May 25, 2018, 10:56:36 AM »
No problem. You can do it however you wish, my practice is to have all the arrays and hashtables under one object that will be always in the scene (singleton, not destroyed on load) and save it as a global variable so you can access the data from any FSM anytime. If that's what you meant by your question.

If you meant should you keep all the weapon in game, and weapon in shop logic in the same FSM, i don't recommend it, let each object have it's own FSM that will communicate with each other (coin tracker, weapons on ship, weapons in shop etc.) and get data from the data manager singleton.
Available for Playmaker work