Graphics Reference
In-Depth Information
through the main differences rather than repeat everything. If the reasoning or workings of
anything in this script are unclear, take a look back at Chapter 12 to the global race manager.
GlobalBattleManager derives from ScriptableObject:
using UnityEngine;
using System.Collections;
public class GlobalBattleManager : ScriptableObject
{
The global battle manager starts with the code to make sure that only one instance of
it exists:
public static GlobalBattleManager Instance
{
get
{
if (instance == null)
{
instance = ScriptableObject.CreateInstance
<GlobalBattleManager>();
}
return instance;
}
}
InitNewBattle() initializes the Hashtables (and a couple of other variables) ready for
the game. These are almost the same Hashtables as those found in the global race manager
from Chapter 12, except that the word race has been replaced with battle. They do serve the
same function: battlePositions refers to positions on the score board, the battleFinished
table holds each player's game state, battleControllers is used to store the player's battle
controller components and a new Hashtable, sortedPositions, is used to provide a format-
ted and sorted score board for the UI:
public void InitNewBattle()
{
// initialize our hashtables ready for putting objects into
battlePositions= new Hashtable();
battleFinished= new Hashtable();
battleControllers= new Hashtable();
sortedPositions= new Hashtable();
currentID=0;
numberOfBattlers=0;
}
Skipping down past a few functions in the original script now, we can see that the
function GetPositionListString() provides the formatted, sorted list of players in order of
their race positions, for the game controller to display as a text object.
GetPositionListString() will return a string:
public string GetPositionListString()
{
Search WWH ::




Custom Search