Hi peeps, can anyone help with the following?
Each player has a similar toolbar, in the middle are the weapons and 4 upgrades (hull, speed, boosters & magnets):
RT01.png
The red areas are upgrades/weapons you already have purchased, and the light green are upgrades which you can afford based on your current coins and current upgrade level of that item/weapon.
Each of the upgrades and levels costs a different amount, and nothing is on a linear scale - so in order to code this I'm having to perform loads of counter comparing which is eating up resources on the XNA exporter.
The actual item/weapon purchasing isn't too bad as the code is nested in a deactivated group until you visit your garage - plus I'm only having to check whether a player is on a particular item in the garage, test if they press a button, test resources, then make the changes - which is all contained in one event per upgrade.
The problem is the upgrade notifications, which show what you can afford - and is a feature I'd like to keep because it really helps keep players in the main game, rather than wasting time in the garage (which otherwise leaves them at a disadvantage). This feature currently works out what you can afford on each single item/weapon all the way to fully upgraded, but it's coded in a very crude fashion just to test it - but I now need a far more efficient method than constantly testing counters (which is smashing the frame rate as it costs around 250 events per player - i.e. 1,000 bad events!) I tried grouping bits, but it's still a really poor method.
RT02.png
So basically:
If you have no hull upgrade, the counter will test the 4 counters for the cost of level 1 upgrade, and highlight it green if you have enough - it will also test the cost Tlevel 1 + 2 upgrade and if you have enough for both, highlight level 2 upgrade as available; and so on.
If you have one hull upgrade, the same applies, but it is now comparing the counters to different values, taking into account you've bought the first one.
Each level of upgrade you purchase activates an appropriate group which constantly checks your coins to see how many upgrades of that item you can afford.
So... very bad, I know
I assume this can be done better by testing the value of your upgrade and taking certain costs off based on that, but I'm finding it hard to get something coded efficiently. Is there a better way of doing this (within the limitations of XNA objects) such as using an array to check values?
Thanks







Reply With Quote





Also you may end up using nested fastloops for this, but it should still be okay as long as you make sure they don't get stuck in infinite loops (you'll know right away since the game will just freeze :p) If anything, you could look up more info about fastloops and nested fastloops on the forum. It has all the info you could need on the subject.