playMaker

Author Topic: Best method to "pay" cards with different items.  (Read 1677 times)

Loque

  • Playmaker Newbie
  • *
  • Posts: 8
Best method to "pay" cards with different items.
« on: April 10, 2017, 04:15:29 AM »
Hi,

I just got Playmaker a week ago and I already learned a lot and achieved to do little things quite easily so I'm having a lot of fun.
I never wrote code nor used any visual script plugs/software before, but I have to admit that I like it a lot :D

Because I'm new to this world, I'm coming here today to have your thoughts on the easiest/best way to do something.
Let's say you have a card like this :

http://imgur.com/a/8emWY

For thus who never played the board game 7 wonders, cards have a "price" on the top left. For this one for example you need to be able to produce 3 bricks, one parchment and one fabric.

My question is this one, how would you tackle the thing of paying the different "items"? For example each turn you get an item and you can put it on one of your many card (let's say you have four different ones "in your hand"). Once you put an item on a card this item will then become paid (let's say from black and white (unpaid state) to colored (paid state)) and once all of the items of one card are paid, the card is done and you get the resources/victory points produced by the card.

Would it be good to have the game object of the card containing everything (the paid and unpaid meshes on top of each other) and hide/unhide these meshes ? or having all the unpaid items as separate gameobjects (but it'd be very hard to know exactly where to put them in space) and replacing them during run time by the paid ones ? Or a totally different way of doing it =)

I'm kind of lost picturing the best approach for that, in term of performance and simplicity ; that's why I'm asking you guys =)

Thanks a lot

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: Best method to "pay" cards with different items.
« Reply #1 on: April 10, 2017, 06:12:21 AM »
Personally, I would create a card prefab, with everything that is needed and enable/disable things on the go at run-time.

Loque

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Best method to "pay" cards with different items.
« Reply #2 on: April 11, 2017, 01:49:22 AM »
Thanks a lot.

So I guess I'll have to do that with "Activate game object" and have to be careful with the order (if there are 3 bricks, activating in order the first one, then the second one if we get an other brick later etc).

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
Re: Best method to "pay" cards with different items.
« Reply #3 on: April 11, 2017, 06:01:57 AM »
Yep that's correct action.

Order in terms of sorting layer, so only one is visible at the time?

Unity added some time ago a function called Transform.SetAsLastSibling, which basically moves the game object to last position in the hierarchy and makes it visible on top of anything else in the same directory. There should be an action for it, and if not have look on the ecosystem.

Is that what you meant?

Loque

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Best method to "pay" cards with different items.
« Reply #4 on: April 11, 2017, 12:30:27 PM »
What I meant by "in order" was the fact to activate the elements one after each other.

Let's say a card cost 2 bricks for example. Whenever you get your first brick, you can put it on this card and it'll replace the first brick (which is disable for now) on the card ; so the first brick will now be enabled.
Then, later in the game, once you got a second brick, it'll replace the second brick (that is still disabled) on the card. Does that make more sense ?

But I guess that for this, I just have to do a bool on the actions and check if they are true or false. If it's true (element enabled), go to the next one if there is an other one of the same type and check if it's true or false.

Anyway thanks a lot for your answers. That helped a lot and I'll dive into that tonight =)