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 > Anchor Center: MissionCompletePanel 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, locate the center anchor and enable the mission complete panel to make your changes.

216

Select MissionComplete

280

Unhide the mission complete panel menu to edit

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()
{
	for (int i = 0; i < InterfaceElements.Length; i++) 
	{
		InterfaceElements [i].SetActive (false);
	}

 
	HeliosUI.transform.position += new Vector3 (450, 60, 0);//move the Chimera Helios UI to the middle of the screen

  // Open the mission complete panel
	MissionCompletePanel.SetActive (true);

	NavigationButtons.SetActive (false);//normally these buttons are never off; the mission complete panel has its own navig buttons

	// Update the gained loot in the mission complete panel
	goldNoLb.text = ((StatsBattle)statsBattle).gold.ToString();
	manaNoLb.text = ((StatsBattle)statsBattle).mana.ToString();
	buildingsDestroyedNoLb.text = ((StatsBattle)statsBattle).buildingsDestroyed.ToString();
	// Update the Mission Complete lost units number
	unitsLostNoLb.text = ((StatsBattle)statsBattle).unitsLost.ToString();

  // The kit supports returning units from battle
  // Here, we update the remaining units
  // And bring them back from battle
	int remainingUnits = 0;

	for (int i = 0; i < ((StatsBattle)statsBattle).availableUnits.Length; i++) 
	{
		remainingUnits += ((StatsBattle)statsBattle).availableUnits[i];
		((TransData)transData).returnedFromBattleUnits[i] = ((TransData)transData).goingToBattleUnits[i];
	}
	// Update the Mission Complete remaining units number
	unitsRecoveredNoLb.text = remainingUnits.ToString();

  // Save the attack file
	((SaveLoadBattle)saveLoadBattle).SaveAttack();

  // Save other variables for the user
	((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;

}