Graphics Reference
In-Depth Information
{
// drop out if instance exists, to avoid generating
// duplicates
Debug.LogWarning("Tried to generate more than one
instance of singleton SpawnController.");
return;
}
// as no instance already exists, we can safely set instance
// to this one
instance = this;
}
public static SpawnController Instance
{
// to every other script, this getter setter is the way they
// get access to the singleton instance of this script
get
{
// the other script is trying to access an instance
// of this script, so we need to see if an instance
// already exists
if (instance == null)
{
// no instance exists yet, so we go ahead and
// create one
ScriptableObject.CreateInstance<SpawnController>(); // new SpawnController ();
}
// now we pass the reference to this instance back
// to the other script so it can communicate with it
return instance;
}
}
}
After the setup functions, the script moves on to a simple Restart() function that
clears out all of the ArrayLists used later on by the script.
public void Restart ()
{
playerTransforms=new ArrayList();
playerGameObjects=new ArrayList();
objectList=new ArrayList();
}
The SetUpPlayers function is a very specific function designed for a specific purpose.
That is, it functions to pass in information about the players in the game represented
by a series of arrays and an integer to say how many players are in the game in total.
This information is not used immediately and will be used later on in the script by the
CreatePlayers() function.
public void SetUpPlayers (GameObject[] playerPrefabs, Vector3[]
playerStartPositions, Quaternion[] playerStartRotations, Transform
theParentObj, int totalPlayers)
{
Search WWH ::




Custom Search