QoL Update Multi Buy Button
Maybe not the most important feature for a game.
But I like "Multi Buy Buttons" and it was one of my open tasks for "Feed the Bunny".
My solution
Cycle through the different options and set the button text:
Function for calculation of the upgrade costs for a 'bulk' upgrade
I use a struct so I can return the values for the costs and the number of levels:
Calculate the current Basecost:
Finding out how many levels are needed to reach the multi buy goal:
a) for a set number of upgrade levels:
b) for fill level to 10 or 100
c) for MAX levels
Now that I know the number of upgrade levels I can calculate the sum of the upgrade costs for a 'bulk' upgrade:
Return the values (remember I used a struct to return 2 values):
The advantage of the struct for me is that I only have to call the function once for each upgradable item and then can use both needed values as often I want to in my processing.
Example:
And that's it. :-)
I look forward to comments on how other developers have solved this and hope I can help one or the other beginner with my solution.
Thank you for reading so far and apologizes for my English. I hope you understand anyway.
Feed the bunny
Become the richest bunny ever - Idle
More posts
- Final Release of 'Feed the bunny'Jan 25, 2022
- Major Update introducing: ChallengesJan 15, 2022
- QoL Offline Gain and Minor TweaksJan 08, 2022
- QoL Auto Buy and Auto ClickJan 03, 2022
- Unity3d PlayerPrefs problem on Itch.IO (and my solution)Dec 30, 2021
- Fixed Save on Game UpgradesDec 29, 2021
- Release and first updateDec 28, 2021
Leave a comment
Log in with itch.io to leave a comment.