Game Development Reference
In-Depth Information
{
hit.gameObject.GetComponent("opendoor").
open = true;
}
}
else if(hit.gameObject.tag == "key")
{
. . .
Step 35. Now all the code is in place for adding the yellow and blue
keys; create your own yellow and blue doors and add the necessary
code to complete the scenario.
To complete the GUI, the player's health and head shots are required. You
can create your own head shot portraits or download ones from the Web
site at Chapter Six/health.zip.
Step 36. Open gui.js and modify as per Listing 6.15 .
Listing 6.15 Adding Health Portraits to the GUI
. . .
var greykey : Texture2D;
var healthOk: Texture2D;
var healthBad: Texture2D;
var healthAwful: Texture2D;
var healthDead: Texture2D;
var theRedKey: GameObject;
var theBlueKey: GameObject;
var theYellowKey: GameObject;
var theGreenKey: GameObject;
var theWrench: GameObject;
var health: int = 100;
function OnGUI ()
{
. . .
GUI.Box (Rect (3,3,75,75),"Health");
if(health > 75)
GUI.Box (Rect (83,3,75,75),healthOk);
else if(health > 30)
GUI.Box (Rect (83,3,75,75),healthBad);
else if(health > 0)
GUI.Box (Rect (83,3,75,75),healthAwful);
Search Nedrilad ::




Custom Search