Battle Results Screen

👍

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 the battle results screen?

After a battle is complete, the MissionCompletePanel menu is activated by Scripts/Helios/Helios.cs ActivateEndGame() function which shows the total battle results.

For the game kit, we've just setup a basic screen for developers as seen in the below mockup but you can change these settings in the Unity Map01 scene > Canvas/ModalWindows/WinWindow and the ActivateEndGame() Helios.cs function.

834

MissionCompletePanel()

How to edit the battle results menu?

The Game scene is used for the player's base and base building. You'll need to open the Map01 scene to edit anything battle related, such as the battle results menu.

Why a separate scene? The Map01 scene is where enemy bases are loaded and where battle menu and battle scripting is held. We've designed the City Building Kit like this to make it easier to remove the battle component entirely for game developers who just want to build city building games without strategy battle gameplay.

512

Open the Map01 scene

Inside the Map01 scene, in the hierarchy, go to Canvas/ModalWindows/WinWindow and enable the game object to make your changes.

1132

Select MissionComplete

Also, to change what values you show - for example if you have additional variables you want edited, change these settings in the ActivateEndGame() function as shown below.

What function is involved?

The Scripts/Helios/Helios.cs that is the main engine component for all things battle related is also where you'll find the ActivateEndGame() function which is what triggers the MissionCompletePanel seen at the end of the battle.

// Excerpt from Helios.cs
// ActivateEndGame() runs when the battle is complete
// This displays the MissionCompletePanels, saves the battle results

private void ActivateEndGame()
{
		MissionCompletePanel.SetActive (true);
		
		goldNoLb.text = ((StatsBattle)statsBattle).gold.ToString();
		manaNoLb.text = ((StatsBattle)statsBattle).mana.ToString();
		buildingsDestroyedNoLb.text = ((StatsBattle)statsBattle).buildingsDestroyed.ToString();
		unitsLostNoLb.text = ((StatsBattle)statsBattle).unitsLost.ToString();

		int remainingUnits = 0;

		for (int i = 0; i < ((StatsBattle)statsBattle).AvailableUnits.Count; i++) 
		{
			remainingUnits += ((StatsBattle)statsBattle).AvailableUnits[i].count;
			((TransData)transData).ReturnedFromBattleUnits[i] = ((TransData)transData).GoingToBattleUnits[i];
		}

		unitsRecoveredNoLb.text = remainingUnits.ToString();

		((SaveLoadBattle)saveLoadBattle).SaveAttack();

		((TransData)transData).goldGained = (int)((StatsBattle)statsBattle).gold;
		((TransData)transData).manaGained = (int)((StatsBattle)statsBattle).mana;
		((TransData)transData).battleOver = true;//this variable is checked at game.unity load to see if the user is returning from battle or just started the game
		((TransData)transData).tutorialBattleSeen = ((StatsBattle)statsBattle).tutorialBattleSeen;

}