Turn Based Challenge


I've always felt a love for turn based tactical games ever since I played Final Fantasy Tactics. That love for turn based tactical games came back after playing XCOM: Enemy Unknown.  I wanted to see what it was like to create a turn based game. This alpha state is the third iteration of the game. 

My first iteration just had the path finding but only for one character. When I tried to add a second, it was through the Update function. The GameManager sent which player turn it was to each playable character and that number would go through the Update function. So if the current turn was player 1, the GameManager would send int 1 to both player 1 and player 2 clones.  The update function would check if the GameManager's playerNumber matches the playerNumber in the clone then proceed or wait if it does or not, respectively.  Both tanking firing and tankingmoving script did this number check in the updates. This was changed by placing tankmanager into an array in the GameManager, adding a Play function that changes the wait state in each tankManagers Update  function. 

Another issue was moving the tank between each square. Initially, the update function in tankMovement was used but the tank would stop as soon as it went over the collider of the movement node. The Update functions were getting too messy, so most of the code was moved into coroutines, also the code for movement was done on it's on iteration. The new code fixed the issue of the tank stopping on the edge because the old code had it as soon as it hit the collider of the node the tank would stop.  To fix the problem is not to use colliders but use the transform of the node since the transform has the position in the middle of the object. 

A good IDE is important and thankfully, VS had a good debugger that was able to find an error in the pathfinding code after crashing multiple times.  Another interesting error is I placed invisible walls, so the shell collides and the turn finishes. The tank moves based on mouse click on that node, but the invisible walls was blocking the raycast. So remember to have the invisible walls on the layer "Ignore RayCasts."

I feel a bit burnt on on this project, but I feel I still want to make changes such as adding WASD and highlight the movements instead of using a mouse click, and adding another layer on top of tankManager called playerManager that allows teams for players. Lastly, I want to add an AI, maybe A* with some heuristics when deciding to fire such as getting as close to the firing range and staying as far away.

This may use the tanks as a placeholder but the code can be reused for other games I am thinking of. 

Files

AlphaBuild1-2.zip Play in browser
Jun 21, 2019