Use this guide to add a new playable level and configure its reward/progression behavior.
How Level Loading Works
- Current level index is stored in GameModel as "Level".
- On load, the game picks prefab from GameConfig "LevelPrefabs" by index = model "Level".
- Source: GameLoadLevelState.
Important Level Limit Behavior
- If model "Level" is greater than or equal to "LevelPrefabs".Length, the game does not crash.
- It clamps level index to last available prefab:
- level = "LevelPrefabs".Length - 1
- model "Level" is overwritten with that clamped value and saved
- Result: the game keeps loading the last configured level index until you add more level prefabs.
How Win Progression and Reward Work
- Reward is configured per level in LevelView field "_reward".
- On win, WinHudMediator does:
- Reads reward from LevelView "Reward" ("_reward")
- Adds reward to model cash via "PlusResource"
- Increments model "Level" by 1
- Updates region progress using GameConfig "RegionProgressStep"
- Saves model
- Win screen shows this reward amount.
Mandatory Team Setup for Every Level
- You must have at least:
- Building with TeamIDType.Player
- Building with TeamIDType that is not Player (Neutral or enemy team)
- Why:
- Win is triggered when all buildings become Player team
- Lose is triggered when there are no Player-team buildings left
- If your level has only Player buildings or no Player building, level-end behavior can be invalid for normal gameplay flow.
Config Fields You Must Know
- GameConfig:
- "LevelPrefabs" - ordered list of all level prefabs
- "LevelEndHudDelay" - delay before win/lose HUD
- "RegionProgressStep" - percent progress added per completed level
- "DefaultLevel" - used for new/reset game model
- Level prefab (LevelView):
- "_reward" - cash reward for completing that level
Main Procedure: Add a New Level
Step 1: Create Level Prefab
-
Duplicate an existing level prefab from: Assets/GorodiskiGames/TowerClash/ResourcesStatic/Prefabs/Levels/
-
Rename it using project style, for example Level14.prefab.
-
Open prefab and edit layout, buildings, and props (trees, wooden box) to block path creation.
-
With Scene Gizmos enabled, each building uses BuildingView gizmos: a wire sphere at the building transform with radius "_radius" and wire color from "_teamID" (helps spacing and footprint checks).
-
Ensure root object has LevelView component.
-
Ensure level contains at least one Player building and at least one non-Player building.
Step 2: Set Reward on the Level Prefab
- Select the root LevelView component.
- Set "_reward" to desired cash amount.
- Save prefab.
Step 3: Register Level in GameConfig
- Open GameConfig asset: Assets/GorodiskiGames/TowerClash/Resources/GameConfig.asset
- Find "LevelPrefabs".
- Increase array size by 1.
- Add your new level prefab at the end.