Looks like I’m going to have to do a massive rewrite. By trying to do things in a simple way, I screwed myself. I have a mix of GameObjects and Vector3s (Position) for moving to locations and detecting if objects exist. However, now that I’m trying to do a less targeted approach, the mix of Vector3s and GameObjects is making it confusing and stupid.
So – I have to refigure all the code in a way that my brain just doesn’t feel like doing right now. It’s kind of a bummer. I was on such a roll. Oh well.
It doesn’t help that I’ve been playing the hell out of Heroes of the Storm.
So – I’m trying to get the “Wild” honey drops powerup (which allows you to move to any hex on the board), and am having issues with the callback triggered by clicking on the honey icon in the UI detecting the click of the honey icon (not the click AFTER the honey icon). I kept trying to think about how to resolve this issue. Somehow ignore that click and then accept the click after that, but it felt hacky.
But on my way to work today I realized that what I need to do is revamp my entire code for how legitimate targets are detected. The problem being that I coded a very specific method of detecting valid targets based upon the non-powered up valid moves. What I need to do is genericize it, make the hexagons have a “valid_target” flag. Then all I need to do is check whether the hex is a valid target. I don’t need to do all these complicated math.
Once I do that, I can set the method that determines whether a hex is a valid target or not as the callback method, then proceed to detect clicks like normal.
This means that when the callback is fired, it has nothing to do with detecting input (and thus, the click that started it), but will process the hexes and make them all valid targets.
This will actually clean up the logic of the code in the process and do a better job of compartmentalizing things, I think.
I knew this “working from the particular to the general” would come back to bite me in the ass.
The scoring system now can save to disk, and each level has its own save file. I have only tested on my Windows PC, need to try on my android device next. In theory it should work. We’ll see.
The one issue I have with it is that if you have a new score that equals another older score (but can push down an even lesser score), it will push down the lesser score, but it appends itself AFTER the 1st score that is equal to it:
(Pretending I have a max of 3 on the table – I really have 10, but for simplicity’s sake):
Jim just got 30.
The list should be :
But it actually renders as:
Joe is pushed off as he should be, but the older high score remains above the newer one. Perhaps that’s as it should be. But I feel like the newer one should take precedence. I suppose I could also try to sort by name as a secondary sort after score. But since people type in their name, then they can just choose to be AAA or whatever.
I’ll have to look into score sorting and see how other games do it – I don’t think I really paid much attention to that detail before.