Army Size
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 is army housing size?
Free-to-play strategy games usually will limit the size of player armies for better strategic gameplay, and give some players the opportunity to increase their maximum army size. These features are available in the City Building Kit, read more in the details below.
Item in the Image Above | Description |
---|---|
Max Army Capacity | This is the maximum capacity of the player army. The default is 100 set in the GameManager Stats Inspector. The only way it can be increased is if your have buildings with StoreType = Soldiers. Reach the Shop Menu > Military Buildings section for more details or see the Tatami item included in the City Building Kit Demo. |
Actual Total of Units | This is the total number of units. If your game has units that take more than one population space per unit, this number will be different (e.g. 19) than the total population (e.g. 49 as seen in the image above) |
Total Army Size | Some units like the archer take 1 population space. Heavy units like the viking take 3 population space. That's why the total for 19 units can be 49/100 of your army capacity. More details about unit weights below |
Where is the max housing variable used?
The script Scripts/Menus/Units/MenuUnit.cs BuyStoreItem() excerpt checks if the player has enough resources and army housing space remaining to build the unit they want to build.
// Scripts/Menus/Units/MenuUnit.cs
// BuyStoreItem() Excerpt
//
// When building units in the units menu, we check
// if they have enough resources and space. Here's the line excerpt
// for checking if the unit Size value (from UnitCategory.asset exceeds max housing)
if(Stats.Instance.occupiedHousing + itemData.size>(Stats.Instance.maxHousing))
{
canBuild = false;
MessageController.Instance.DisplayMessage("Increase your soldier housing capacity.");
}
How is population increased?
Look at the Tatami sample military building to learn more about how special attribute: increase max army size
Further down in the SO for the Tatami item you'll see the type of storage increases the player's army size - by 25 total. (Distributed means Player stats - meanwhile StoreType = Internal is used for resource generators - see the documentation page Shop Menu > Resource Generators for details)
The SO item for a normal building without any army capacity would look like this:
You'll notice the only major change is that StoreType is set to None, StoreResource is set to None, and StoreCap is set to 0. This means no resources (army or in-game currency) are stored.
What happens when I create a building that increase the army size?
The following screenshot shows before and after unit army storage addition in the Stats UI. The storage cap is shown just above the progress bars for the total army size. In the below example, we start with 100 unit cap and after building a Tatami structure the player army cap increases by 25 for a new total of 125.
Setting custom population weights for different units
When training units, not all units have the same population weight. For example 10 archers in the City Building Kit each have a population weight of 1 per archer, meanwhile the viking has a population weight of 3 per viking. This is to help developers who want to have stronger units, with different life and attack values. (As of now - read the Buildings > Defense Structures documentation page to learn about how we hardcode the life for all units)
ScriptableObject (SO) Example from UnitCategory.asset file
Here's an example of one of the unit SO items included in the City Building Kit Assets/CityBuildingKit/Resources/Assets/UnitCategory.asset The most important item in this list to observe is that the StoreType is Distributed, and StoreResource is set to Soldiers.
A closer look at unit population
Units also get a population size. In the example above it's 1.
Size could be any integer value as long as it's less than your army max capacity. For example, you could have 15 archers with a population weight of 1 each or 5 vikings who each have a population weight of 3 for a total army size of 15 (Total unit count is less in the latter, and larger in the former army size).
This is incredibly useful for building games with heavy units like tanks, horses, or heros who may have a huge HP value of 1,000 but take an incredible 10 or 15 population space per unit. Population space is one way that adds extra strategy to your gameplay.
The Viking unit in the Units.xml file on the other hand has a population size of 4 which would make sense with a higher health and damage values (both of these settings are not currently used. Life and damage are hardwired the same for all units in the battle scripts, view the PvP documentation for details)
Updated less than a minute ago