Ambient Decorations

👍

Reminder - Keep Daily Backups

When working on a strategy game with a kit as big as the Complete Kit - always keep a working daily backup! Save yourself the trouble of rolling-back changes and losing work.

All types of structures in the City Building Kit documentation pages are actually controlled by a single multi-functional StructureCreator. It builds anything, different prefabs and SO (ScriptableObject) descriptors; this includes array-builds, for walls and fences, instant builds (without construction sequence) and whatever you can dream up for your game.

What are decorations?

The City Building Kit includes decorations which are called ambient objects. These are objects the player can construct which offer no value other than aesthetically pleasing images - like a flag or a tree. These objects you can place around your city or village to decorate your base.

Most free-to-play strategy games include them as they not only provide players with a way to spend excess resources but also customize their base (increasing return value for recurring players)

The following screenshot shows 3 different examples, a flag, a flower, and a tree - that are included in the City Building Kit. You can customize these objects with your own or remove the ambient menu all together if you would not like to have decorations in your game.

The following page talks about how ambient objects are done.

677

Decorations examples. Click to view larger

Decoration Store

In the UIAnchor - center main store item, you'll find the walls element which contains everything you see in the below screenshot.

464

Ambient object store. Click to view closer.

Where to find the decoration store menu in Unity?

Open the game scene hierarchy and locate the ScrollView in Canvas > ModalsWindows > ShopWindows > ShopGroup > StorePanel > BottomGroup > Content > Content. Look at the below screenshot.

403

UIAnchor. Click to view larger.

Where are the prefabs?

All of the game object prefabs are set in the ScriptableObjects at the path Assets/CityBuildingKit/Resources/Assets/
For example take a look at the AmbientCategory.asset file below :

511

Game scene Game Manager > SaveLoadMap

In addition, you will want to look at GameManager > Creators > AmbientCreator (prefabs are also there) This is discussed in the Buildings > Part 2: Customize Menus section of the documentation. Prefabs are used by the creator for construction and by SaveLoadBattle for loading during battle.

GameManager > Creators > AmbientCreator

The Game scene GameManager > Creators > AmbientCreator has all of the prefabs and their corresponding settings.

273

Game scene Game Manager

358

Ambient prefabs in the AmbientCreator Inspector

In the Inspector you'll notice a few arrays, here's a description of each one. It's the same for every type of game object you can build in the game except for the RemovableCreator (removables are not for players to construct but rather remove -- see Player Removable Objects doc for details)

Array TitleDescription
Structure PfThe structure prefab.
Grass Pf1x1 to 5x5 dark green grass collider grid prefabs list. These you don't have to edit, they are shared by all structures in the game based on their grid size.
Construction PfUnder construction prefab list. There's 3 different sizes of this for 1x1 to 3x3 grid size construction projects.
Grass TypesSize of this array matches the the Structure Pf array size. We tell which Grass Pf element to use with each structure. Depends on structure size whether they take 1x1 (Grass Pf element 0) like a wall segment or 3x3 (Grass Pf element 2) like the large gold vault. Tatami is the only object that takes grass collider 5x5 ( Grass Pf Element 4).
Construction TypesArray size matches Structure Pf. Like grass types, we match the construction prefab grid size too. Since there's 3 different sizes of construction prefabs, this ranges from values 0 to 2. By default, we set most structures to use the 3x size.
Pivot CorrectionsArray size matches Structure Pf. Odd size grid structures (1x1 and 3x3) need a pivot correction so they don't appear accidentally off-center, taking more grid space than necessary. Pivot Correction does this.
Is ArrayArray size matches Structure Pf. If set to 1, uses the row making field builder for construction instead of the usual construction. The only objects that use this are the wall segments that let you pick a start and end point and automatically constructs a repeating row of the structure between the points.
Is InstantArray size matches Structure Pf. For items you set TimeToBuild to 0 (instant build) in the SO, you also want to set the elements Is Instant boolean to 1 in this array. The only objects that use this in the demo are the wall segments.

SO Example (Flag Decoration Object)

Here's an example of one of the ambient decoration elements from Assets/CityBuildingKit/Resources/Assets/AmbientCategory.asset used by the centralized creator script Scripts/Creators/BaseCreator.cs

464

If you add new structures, please don't forget to update GameUnitsSettings.asset file. Read more info at Documentation > XML files VS ScriptableObjects

Why aren't decorations attacked in battle?

In the Scripts/Helios/Helios.cs FindNearestBuilding() function we define which type of structures can be attacked as Building and Weapon game objects only. See the excerpt below:

// Scripts/Helios/Helios.cs
// Excerpt from FindNearestBuilding() function which 
// locates structures to attack during battle

// ......

			// Limit attackable structures to game objects with structureClass 
			// of Building or Weapon only
			if (allGrassPatches [i].GetComponent<GrassSelector> ().structureClass == "Building" ||
				allGrassPatches [i].GetComponent<GrassSelector> ().structureClass == "Weapon") 
			{
				selectedGrassPatches.Add (allGrassPatches [i]);
			}
		}

// ......