playMaker

Author Topic: Dissapear "buy" button for the selected cars  (Read 1623 times)

Ayman

  • Playmaker Newbie
  • *
  • Posts: 24
Dissapear "buy" button for the selected cars
« on: October 02, 2018, 11:33:40 PM »
Hi guys . I made a cars selection fo my game wich contains the cars and 2 arrows to switch between cars and a buy button .what i want is when a car is buyed , the dissapear button set disable for only that car or for all the cars i buyed . Any ideas ? THANKS FIIIRST
« Last Edit: October 03, 2018, 02:53:07 AM by Ayman »

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Dissapear "buy" button for the selected cars
« Reply #1 on: October 03, 2018, 03:37:58 AM »
Make a "bought cars" array, and add bought cars to it. Depending on your setup, when you enter the shop, you can grayout the sprite, skip it when going through the shop etc.
Available for Playmaker work

Farwest

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 63
Re: Dissapear "buy" button for the selected cars
« Reply #2 on: October 03, 2018, 10:30:47 AM »
Ayman, maybe you can use this remedy. I give you the actions to use:
Set PlayerPrefs Int: (Key: CarName (you can write Name of the Car or use it as variable) ; Value: 1)
This action will save that "that car" is purchased. (Consider and make a note, if PlayerPrefs is 1, car is purchased. If it is 0, it is not purchased.)

Then you can make a "Get PlayerPrefs Int" action to each Button or Car (If you know how to make a desired amount of loop, you can also use the Car Screen Panel as Manager object. If not, just use Get PlayerPrefs Int action at the Start action of Buttons or Cars that you want it to disappear)

Get PlayerPrefs Int (Key: Name of the Car/CarName; Value: variable(int))
Then add Int Compare action after.
Int Compare: variable =? 1 (comparison)
Here, adjust this Int Compare action to make it like, if variable is 1 (equal or greater), make transition to disappear the car (use Set Property or Activate Game Object actions). If variable is 0 (less), make transition to keep the car (an empty state to do nothing).

I hope this will be useful.

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Dissapear "buy" button for the selected cars
« Reply #3 on: October 03, 2018, 06:09:00 PM »
It’s not quite clear what exactly isn’t working, and depends on your setup. Do you struggle with UI? Or how to populate a list of cars and update them accordingly? Do you intent to use microtransactions (I would discourage you, because it must be done rock solid, and isn‘t something you can quickly slap together.)

To me, this this a case for enum flags (see this nifty asset for under 2$, which gives you examples (else, you can also piece together your own by reading documentation).

Another (easy) way, and assuming the cars differ in some way and have properties or stats, add a bool variable, like “purchased”. It’s false by default, and set true on purchase. Then, when the shop is opened, and the list is populated, it would skip the ones where purchased = true. I recommend keeping the cars’ stats and game object(s) etc in a scriptable object.

Ayman

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Dissapear "buy" button for the selected cars
« Reply #4 on: October 03, 2018, 09:57:43 PM »
Thanks guys for your replys but i didnt fix it yet . I think i didnt clear to much for you . So what i need exactly the ui button "buy" when i click it the selected car  is buyed  but the "buy" button still appearing . I want that button to not show up on the buyed cars . I wish its clear to you now

Thore

  • Sr. Member
  • ****
  • Posts: 480
Re: Dissapear "buy" button for the selected cars
« Reply #5 on: October 03, 2018, 11:31:12 PM »
First, you need to store which cars are bought yet. Then, when you click and select one car, check if that car was bought. So far depends totally on how your system is set up.

Keep UI and mechanics apart. The UI FSM can check whether the car was bought, and depending on that either show or not show the button. Actions you problable need is Get FSM variable, or get property etc. Once the UI “knows”  you could use “activate game object” on the button, if it should display. You could also change the text with set property, or probably better, have two buttons at the same place, and you either show one (to buy), or the other (already bought).

Ayman

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Dissapear "buy" button for the selected cars
« Reply #6 on: October 04, 2018, 09:40:27 PM »
Okey thank you i will try it