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.

What are decorations?

When playing city-building games or battle strategy games you'll always be able to build some sort of structure that doesn't have any economic role or even defensive role but just looks pretty and gives players a way to personalize their base and also spend extra currency. In this case we've added a category in the store for you to place these objects like flagpoles, statues, or flowers.

The demo includes an assortment of these objects for you to play around with when designing your own game.

677

Purchased decorations. Click to view larger.

Shop Menu

Here's a screenshot of the shop menu for the decorations which we call ambient objects in the kit. (since they have no defense, offense, or HP and cannot be attacked)

636

Click to view larger.

The examples here are general ambient objects that do not affect the player's stats except awarding XP for completion and costing resources to build. You can adjust any of these settings. (Details below on how to do this in the ScriptableObject file.)

746

Click to view larger.

Where to find the decoration store items 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.

Store Item UI

All of the store details seen in the below screenshot are taken from the AmbientCategory.asset file (Assets/CityBuildingKit/Resources/Assets/AmbientCategory.asset) and loaded by Scripts/Creators/BaseCreator.cs (details below on what part of the script does this)

Although the screenshot below is for another building type in the store, the details apply to all buildings including ambient objects since the store uses centralized BaseCreator.cs script.

483

Breakdown of the information shown to players in the store.

From Image AboveDescription
Item NameThis is the Name variable
Time to Build (in minutes)The TimeToBuild variable (in minutes). How long the structure will take to to be created.
# Build / Level LimitThe number of this structure already created versus the number limited by their level.
Currency CostThe Price variable.
Currency TypeThe Currency variable (Either Gold, Mana, or Gems) You could change this to whatever currency you will have in your game and also add additional currencies.
View DescriptionShows the Description text variable.
Prefab ImageThe prefab image which you can edit from the UIAnchor: Center shop main menu. More details on how to change this under the Buildings > Part 2: Customize Menus page of the documentation

Item Example

Here's an item example from the AmbientCategory.asset for the Flag seen in the store.

464

A closer look at ScriptableObject(SO) AmbientCategory.asset

If you look closely in the above SO, you'll see the building costs 100 of of the Gold currency. You could use whatever currency you want in your game, in the demo we have two placeholders called Gold and Mana. (Plus one rare currency called Crystal Gems).

185

Further down in the SO you'll notice it will take 10 minutes to build (TimeToBuild is measured in minutes) and awards 100 XP to the player when the item is constructed.

185

If you don't want to award XP and also want the decoration to be built instantly, change both of these values to 0.

Another SO item Example

459

BaseCreator.cs - Where the SO data is loaded into

In Scripts/Creators/BaseCreator.cs the building data from your SO file (seen above) is loaded using a common system for all the buildings like resource buildings, defense buildings, walls, decorations, and other buildings. Here's an excerpt from BaseCreator.cs of the SO (AmbientCategory.asset) data load:

protected void GetAmbientXML()//reads buildings XML
	{
		List<AmbientCategoryLevels> ambientCategoryLevels = ShopData.Instance.AmbientCategoryData.category;
		List<AmbientCategory> ambientCategoryData = ambientCategoryLevels.SelectMany(level => level.levels).Where(c => c.level == _structuressWithLevel).ToList();
		
		foreach (AmbientCategory structureItem in ambientCategoryData)
		{
			dictionary = new Dictionary<string, string>();
			dictionary.Add("Name", structureItem.GetName()); // put this in the dictionary.
			dictionary.Add("Description", structureItem.Description); // put this in the dictionary.
			dictionary.Add("Currency", structureItem.Currency.ToString());
			dictionary.Add("Price", structureItem.Price.ToString());
			dictionary.Add("TimeToBuild", structureItem.TimeToBuild.ToString());
			dictionary.Add("XpAward", structureItem.XpAward.ToString());
			structures.Add(dictionary);
		}

When the data is loaded, the store panels are updated with the appropriate information.

Construction limits with XP levels

Read the Gameplay > XP and Levels documentation page for more details. Game players could have a maximum of two gold mines at level one until the player reaches level two, in which the maximum increases to five (or whatever value you choose -- read XP and Levels documentation for more details)

Although the following example is not an ambient object, it's a good example to show since the store elements all act the same in the store menus.

158

1/2 gold mines built. Maximum not reached.

161

2/2 maximum reached, can't build more

This is relevant to mention now because the menu items are greyed out for objects that the player can no longer build until they increase their XP level through other ways of gaining XP.
The function UpdateLabelStats() does this checking in Scripts/Creators/BaseCreator.cs DEPRECATED FUNCTION / UNUSED

What happens when the buy button is clicked?

When the player clicks one of the buttons to build an ambient item in the store, first one of the BaseCreator functions is triggered. ( Look at Shop Menu > Resource Generators: What happens when the buy button is clicked for a building? section ), since it is exactly the same process. )

VerifyConditions()

Can the player build this structure? In Scripts/Creators/BaseCreator.cs the VerifyConditions() script takes over once the store button has been pushed to determine if the following conditions are met and canBuild is set to true. ( Look at Shop Menu > Resource Generators: VerifyConditions() section, since it is exactly the same process. )