Angus-Fan / TurnBasedStrategyGame

My Unity project for a turn-based strategy game. This is an 'open-source' version which has the basic code for the game's core functions.
MIT License
203 stars 54 forks source link
game unity unity3d

Unity Turn Based Strategy Game

This was a project that I made in order to understand how one would approach making a turn based strategy game. This project is a stripped down version of the completed game named Skeletons! skeletonsGameplayReduced If you would like to hear how I programmed and designed certain aspects you can follow this video here. If you would like to download the Unity Project please download the projectFiles.Zip file and open it in Unity (you may need an older version).

Requirements 💻

tiles

The tileMap script includes most if not all of the code required to generate the map. You can change the map size and other variables in the inspector. In terms of map generation, you will need to open the script in your IDE of choice to modify the information. Look for the generatMapInfo() function within the tileMap script, here you will see that the map is by default generated with dirtBlocks which is element 0 of tileTypes. Afterwards change whichever tile[x,y] co-ordinate to your preferred tile.

generation

Units ♟️

If you would like to make your own units, you can look at how units are setup in the prefabs folder. To modify a unit select it and modify the unitScript in the hierarchy. Team number is used to denote what team the unit is part of (we'll get into this a bit more later). There are also other properties which you can change, the name, attack damage, movement speed, etc can all be found in the inspector.

modify

Adding Units to the game

If you take a look back at the scene you may notice that the units are stored under the unitsOnBoard gameObject. Under this section there are two gameObjects called Team1 & Team2, the units are placed under these gameObjects. If you want to add a new unit to the map, add them to their respective team and change the following in the inspector. Under the Team Num variable place their team number as 0 for Team1 or 1 for Team2. The unit's X and Y values are actually set on runtime from their transform properties. If we take toonSkeleSoldier from Team1 and change it's transform values you can see it update at runTime. Please try to ensure that units spawn on their own unique tile which they can move on, you may get unwanted results otherwise.

setupPosition