MainScene
https://assetstore.unity.com/packages/slug/186884
Last updated
Was this helpful?
https://assetstore.unity.com/packages/slug/186884
Last updated
Was this helpful?
The MainScene is where the actual game is played by the user.
The most important thing here is to understand what is the purpose of UpdateManager script and how the whole map is generated.
The idea behind the UpdateManager script is to combine all Update calls into one script. Here is a link to blog post from Unity about this technique: BLOG .
So basically we have a BaseBehaviour class which is used by all other dynamically created objects which overrides Update method for some calculations. And instead of calling Update in every class, this is done by UpdateManager and every created objects is added to a list which the manager is using to update all items. Simple as that! : )
Map (or level) is generated using Tile objects. Every tile object has GameObjects as children (trees, rocks and etc) and a Tile script attached to it. The Tile scripts has a few serialized fields: coin positions & abilities.
As you probably guess Transform[] coinPositions are used to load coins at given transform.
Abilities[] abilities array is used to show randomly an available ability based on some random calculations. Let's say you want some tiles to show only MAGNET abilities and others only FUEL_TANK. You can achieve this by updating this array.
The Map is generated using this order:
Once the GameManager initialize it's variables and state inside InitVariables()
calls -> MapManager.Instance.LoadSelectedMap();
which finds which is the latest selected map by the user and pass that value to the TilesSpawnManager
-> TileSpawnManager.Instance.InitMap(selectedMap);
and this is where the all Tiles objects are created and loaded. And once this process is done every tile object loads and initialize it's coins and abilities. And that's it.