Concept
As an usual game, SuperTiles uses a bunch of Data and the Logic which handles its Data.
For every important part of Data and Logic there is an individual section which contains more detailed description. Here it will be explained only the basis of SuperTiles:
On the bottom of our Data concept there is a well-known unity scene which contains visual information about the level. Map representation is located under MapView gameobject (in our example it is the Village prefab).
Also, scene contains some unit data. It is located inside spawnpoint gameobjects. UnitSpawnPoint class defines which Team the unit will belong to and what kind of unit (Data field) will be spawned at the corresponding position and what UnitAiData asset will be used if this unit will be controlled by Ai player
Further, the reference to this scene is stored inside LevelData, which is another key point of the concept.
Apart from the scene reference (as Scene Name field), LevelData keeps MapSettings link which defines what grid settings will be used at this scene (which tiles are movable and which are not).
Also, LevelData defines the way the turn is moving from one unit to another, by specifying Turn field.
Actions field is neccesary for counting how many move and item actions can be done by a single unit and describes the valid order of these actions.
Besides, we need to know who will controll every team. This information is also a part of LevelData and can be found at the Players field.
After doing a brief Data overview, let’s move on to the Logic description.
Based on the information above it is known that Menu scene is the initial scene to be loaded, but there is no direct reference to any LevelData asset inside scenefile. So where is it?
It is worth mentioning that we have something like a root Data object called GameSettings. It is located inside the Resource folder and has lazy initialization.
Exactly such a reference is used inside the LevelSelectionUI script which is attached to the UI gameobject of the Menu Scene.
Click on any level button invokes LoadLevel method
Level loading is performed by a transitioning to an almost empty scene (Loading) to prevent ugly render stuck when a fat scene file should be loaded. It was said “almost”, because there are several objects representing loading process
After the level will be loaded, it is needed to add common stuff (UI, Main camera etc.) And another helper scene (called Game) will be loaded.
Game scene contains the starter script called GameStart where essential classes are created. Usually essential classes will contain Entity suffixes (GameEntity, UnitEntity, ItemEntity etc.). It indicates that these classes are plain c# classes and could be easily serialized. The main essential class is the GameEntity class. It stores the full state of the current level and also is used to recreate game from the savefile.
Before the process of essential entity creation will start, it should be defined as whether the game will be created from scratch or will be loaded from an existing state. To understand what path is right, we check if the GameEntity contains something in Battle field.
When the creation process is finished, the Loading scene will be unloaded and you can start playing the game. Playing the game means that you start a Battle, and the description of this process is declared here
Created with the Personal Edition of HelpNDoc: Upgrade your help files and your workflow with HelpNDoc's WinHelp HLP to CHM conversion