Once I was finished with the Kamikaze & Zone AI implementations, I already knew there was only one thing left to do: Get some basic (and I mean basic!) combat logic in so that this new AI and I could actually fight against each other. Turns out, I was able to get more than I expected in. Either way, the end result is that you can now fight it out with the CPU from beginning to end.


As I sat down to start planning out the combat system, I immediately started to think about displaying health bars, and how difficult it would be. I didn’t originally plan to include them, but the more I thought about it, from a usability standpoint, it’s better to be able to get a quick idea of the HP of your allies/enemies, versus having to highlight them to see it in their character sheet.

I gotta say, of all of the things I have done with Unity so far, this was… really easy…

Below each unit (which I may switch to above them at some point), I just added a UI canvas, and under that, an image. What does this image consist of? Just a damn background color. Green for allies, red for enemies.

The most intriguing part of creating this was how I would end up being able to show the health bar going down, as you can see in today’s GIF. Turns out, each UI element has a scale that goes from 0 to 1 for each coordinate (x, y, x). If I modify the x coordinate to something less than 1, the image gets shorter in length. If I left align the image to the canvas it sits in, when I lower the scale, it looks like the health has decreased from the right to the left.

So I just had to hook this into existing systems to check the current HP of the unit, get the % of their total HP, and then apply that value to the scale, and voila, I have prototyped health bars that decrease in length as the unit takes more damage.

Implemented in like an hour, which is how I wish all things would go 🙂


Nothing too special going on here. It’s pretty hard coded, as of now, the damage a unit can apply is equal to their level times 2. Yep, that’s it. I’ll worry about weapons, armor stats, etc. later.

Death was pretty easy as well. Whenever current HP <= 0, destroy the unit, and also remove references to it from everywhere else, like the Turn Order GUI, tile data, etc.


I was definitely going for something quick and dirty. Some sort of way of showing people that the attack happened, but nothing I wanted to spend too much time on. I ended up move the unit toward the target half a tile, then half a tile back. Like I said, quick and dirty.


I added this more so because I was on a roll, so I figured, why the hell not? This is really something that would be used for abilities, but decided to show the used “weapon” in each attack. Yes, those weapons are hard coded. And when I say hard coded, I mean, it’s just a string set on each unit via their inspector. As with everything else in this prototype, I can just hook in the real logic later.


So yeah, with all of the above done, I was able to get the game in a great working state. I didn’t talk about the selection menu, because I’d like to leave that for its own blog entry. But just know that it was a *shock* quick and dirty implementation.

Next, I’ll be working on… Well, for once, I actually need to keep this a secret!

Till tomorrow…