Use this guide to add a new region with the minimum required setup: region ground prefab, region icon, RegionConfig asset, and GameConfig registration.
How Region Loading Works
- Current region index is stored in GameModel as "Region".
- On level load, GameLoadLevelState reads GameConfig "_regionConfigs", loads the config for model "Region", and instantiates RegionConfig "Prefab" under the loaded LevelView.
- RegionConfig contains only:
- "Icon"
- "Prefab"
Important Region Limit Behavior
- If model "Region" is outside GameConfig "_regionConfigs", GameConfig "LoadRegionConfig" falls back to index 0.
- The model is then overwritten with that fallback index and saved.
- Result: region 0 is the safety fallback, so keep it valid.
Main Procedure
Step 1: Create Region Ground Prefab
- Duplicate an existing region prefab from: Assets/GorodiskiGames/TowerClash/ResourcesStatic/Prefabs/Regions/
- Rename it using project style, for example Region3.prefab.
- Edit the visuals of that prefab.
Step 2: Create Region Icon
- Add a new icon texture in: Assets/GorodiskiGames/TowerClash/ResourcesStatic/Textures/RegionIcons/
- Follow the current naming pattern, for example RegionIcon03.png.
Step 3: Create RegionConfig Asset
- Create a new RegionConfig asset in: Assets/GorodiskiGames/TowerClash/Resources/RegionConfigs/
- Follow the current naming pattern, for example Region3Config.asset.
- Assign:
- "Icon" = your new region icon
- "Prefab" = your new region ground prefab
Step 4: Register Region in GameConfig
- Open: Assets/GorodiskiGames/TowerClash/Resources/GameConfig.asset
- Find "_regionConfigs".
- Increase array size by 1.
- Add your new RegionConfig at the end.
Step 5: Decide How Player Reaches It
- Region switching on win is driven by GameConfig "RegionProgressStep".
- When progress reaches 100%, WinHudMediator resets "RegionProgress" to 0 and increments model "Region" by 1.
- If you want new profiles to start in this region, also change GameConfig "DefaultRegion".
Quick Validation
- Start the game on a profile that can reach the new region index.
- Verify the correct region ground prefab appears under the level.
- Verify the win HUD shows the correct next-region icon.
Troubleshooting
- Wrong region loads:
- Check RegionConfig was added to GameConfig "_regionConfigs" at the intended index
- Check the player profile "Region" value
- Game falls back to region 0:
- Current region index is outside "_regionConfigs"
- Add the missing RegionConfig entry
- Wrong icon on win HUD:
- Check RegionConfig "Icon"
- Check the order of "_regionConfigs"