Posted December 01, 2025 by ChadEmm
Here's what I got accomplished this past week!
I started the week working with Gemini to design a "river" map, which I then used to template a 20 x 20 grid. This is much larger than the 10x10 grids I had been testing with before, but it gave me a good excuse to work on the Move action.
Along with the map came different terrain types: path, grass, bush, river, bank, rock, and forest. I adjusted the "ap cost" of each terrain type and coded a pathfinding algorithm, changing the behaviour of the Move action. Before, it was simply finding tiles in a set range (3); now, finding tiles in range goes through a pathfinding exercise where a list of "path nodes" are returned, each of which is a linked list of the tiles it takes to get there and the total cost to reach that specific tile. Calculating this once up front when the move action is selected allows us to re-use the calculated data for the action preview (shown every time a new tile is selected), the pathfinding arrow, the animation path (which reuses the existing MoveUnitViewAction to each tile in the path), and the final AP deduction.
I had to also update the enemy AI to take these new costs into account, but luckily since the enemy units and player units have the same actions, once the enemy decided where it wanted to move based on player units in range it didn't take any extra code; we call the exact same MoveAction.Execute the player units use when a player uses the game UI to move their units.
I'm really enjoying the benefits of separating the core & UI actions; I was able to quickly change the move render behaviour from a single tween between current and destination tile to transition between each tile in the path with minimal code changes, and it was simple to modify the existing enemy AI to take pathfinding into account due to the structure of the code.
Also added a quick "turn order UI" on the side as a feature I had in the first version of the game, but with a bit more style; player units show up with a blue background and enemies as red (on the active & target panels as well) .
One tip I picked up while developing with the "event-based system" is that sending an event with a reference object doesn't work; I had a few bugs where the UI was showing the end state of the enemy turn before it had even happened, and that was because I was passing the reference unit objects, which already had the actions performed on them! I had a make a "deeo clone" method to send a snapshot of the target's stats with events so that they UI didn't show the changes until they actually happened.
Some items I didn't get around to that will carry forward into next week:
- make the "highlight" not completely change the map tile color
- need a "cursor" for when tile selection goes outside of movement range
- weird bug where action panel and direction selector doesn't go away if enemy is about to kill player uni
- update active unit panel between actions to show spent / leftover AP