Graphics Reference
In-Depth Information
TimerClass.GetTime() returns an integer, which is compared to the variable game-
Time here. gameTime is an integer representing the game length in seconds. When the
timer hits gameTime, the BattleComplete() function shuts down the game:
// check the timer to see how much time we've been playing.
// If it's more than gameTime, the game is over
if( theTimer.GetTime() > gameTime )
{
// end the game
BattleComplete();
}
}
The BattleComplete() function of the Tank Battle is game controller is the equivalent to
Metal Vehicle Doom 's RaceComplete(). It tells the GlobalBattleManager to stop the battle,
stops the timer, and composes a message to display via the GUIText component referenced
in the variable finalPositionText:
public void BattleComplete ()
{
// tell battle manager we're done
GlobalBattleManager.Instance.StopBattle();
// stop the timer!
theTimer.StopTimer();
// now display a message to tell the user the result of the
// battle
if ( !doneFinalMessage )
{
// get the final position for our local player
// (which is made first, so always has the id 1)
int finalPosition= GlobalBattleManager.Instance.
GetPosition(1);
if ( finalPosition == 1 )
finalPositionText.text = "FINISHED 1st";
if ( finalPosition == 2 )
finalPositionText.text = "FINISHED 2nd";
if ( finalPosition == 3 )
finalPositionText.text = "FINISHED 3rd";
if ( finalPosition >= 4 )
finalPositionText.text = "GAME OVER";
doneFinalMessage = true;
finalPositionText.gameObject.SetActive(true);
Now that the final position message is on the screen, a call to FinishGame will load
the main menu scene:
// drop out of the scene completely in 10 seconds...
Invoke( "FinishGame", 10 );
Search WWH ::




Custom Search