Graphics Reference
In-Depth Information
public void Explode ( Vector3 aPosition )
{
// instantiate an explosion at the position passed into this
// function
Instantiate( explosionPrefab,aPosition, Quaternion.identity );
}
}
13.4.1 Script Breakdown
GameController_TB.cs is very similar to the game controller used in the example game
Metal Vehicle Doom . It derives from the BaseGameController class and uses a lot of the
same logic, so rather than repeat everything here I will highlight the main differences and
go through those, instead.
As per the other game control scripts in this topic, it derives from BaseGameController:
using UnityEngine;
using System.Collections;
public class GameController_TB : BaseGameController
{
There are a few differences in the Init() function worth mentioning:
void Init ()
{
SpawnController.Instance.Restart();
// in case we need to change the timescale, it gets set here
Time.timeScale = gameSpeed;
Unlike Metal Vehicle Doom , there is no lap counting in this script—the player's posi-
tion, in a leaderboard-style scoring system, is tracked by the battle controller and battle
manager scripts. Here in the Init() function is where GlobalBattleManager gets its call to
initialize:
// tell battle manager to prepare for the battle
GlobalBattleManager.Instance.InitNewBattle ();
Just like Metal Vehicle Doom , all of the players' start positions and rotations are copied
into new arrays ready to be fed to the SpawnController to set up:
// initialize some temporary arrays we can use to set up the players
Vector3 [] playerStarts = new Vector3 [numberOfBattlers];
Quaternion [] playerRotations = new Quaternion [numberOfBattlers];
// we are going to use the array full of start positions that must
// be set in the editor, which means we always need to make sure
// that there are enough start positions for the number of players
for ( int i = 0; i < numberOfBattlers; i++ )
{
// grab position and rotation values from start position
// transforms set in the inspector
Search WWH ::




Custom Search