Graphics Reference
In-Depth Information
Fig u re 11.4 The Standard_SlotWeaponController attached to the player prefab.
// set up the data for our player
myDataManager= myPlayerManager.DataManager;
myDataManager.SetName("Player");
myDataManager.SetHealth(3);
isFinished is used to tell this player whether or not to act like it is playing the game.
When the game ends, isFinished is set to true and the user will no longer have control:
isFinished= false;
The last part of this function tells the game controller to update the lives display to
the health set within the data manager. This needs to happen for the lives display to be
populated with the right amount when the game first starts:
// tell game control to update the lives UI
GameController_LBS.Instance.UpdateLivesP1(myDataManager.GetHealth());
}
The GetInput() function overrides the one from the base class (BaseTopDown.cs) to
provide support for respawning and firing.
When the game has finished and isFinished is true, or when the player is respawning,
all of the inputs are set to zero so that the user cannot move the player around:
public override void GetInput()
{
if(isFinished || isRespawning)
{
horz=0;
vert=0;
return;
}
Before going through to check for input, the function will drop out if canControl is
false. canControl means that the user is not supposed to control this player:
Search WWH ::




Custom Search