How to toggle upgrades on and off when player is out of coins...
Hello Fellow Forumers
I have an upgrade system where the player has to chose which upgrade to use before a level. These upgrades cost one coin each to use. The player can toggle the upgrades on and off before the round starts. (the logic is as follows: as long as coins > zero, toggle is turned on, turn upgrade on, coins = coins minus 1. If the toggle is turned off, turn upgrade off, coins = coins + 1) The player earns more coins by playing well.
Sounds simple, right? My problem is this: I can imagine a situation where the player has toggled upgrade 1 on only to realize that he just used his last coin. Now he wants to toggle off upgrade 1 to get one coin back so that he can toggle on upgrade 2 instead, but he can't because the toggle does not work when coins = zero. This is where I am stumped. Any suggestions as to how I can make this work?
Best Answer
-
KevinCross London, UKPosts: 1,894
Don't have a coins > 0 to toggle off a upgrade. And when they do toggle off the upgrade give them the coin back so...
To toggle on they need coins > 0 and you take a coin away
coins = coins - 1To toggle it off they don't need to have coins but they get the coin back
coins = coins + 1
Answers
Cool! That might work. I will try it. Thanks!