Game Development Reference
In-Depth Information
Engage thrusters
Let's get started:
1. Go to the folder (for C# users, Chapter6 | Scenes | C# | UI , or for JavaScript users,
Chapter6 | Scenes | JavaScript | UI ) in the Project view, right-click and choose
Create | C# Script (for C# users) or Create | Javasrcript (for JavaScript users),
rename it to HitPoint .
2. Double-click on the HitPoint script to open it in MonoDevelop. Start by creat-
ing all properties and the Update() function, as follows:
// Unity JavaScript user:
#pragma strict
var ai : AI;
var player : Player;
var frameTexture : Texture2D;
var hpTexture : Texture2D;
var aiTexture : Texture2D;
var textHpTexture : Texture2D;
var textAiTexture : Texture2D;
function Update() {
if ((player.HpPercent <= 0.0f) || (ai.HpPercent <=
0.0f)) {
CharacterClass.IS_GAMEOVER = true;
StopAllCoroutines();
}
}
// C# user:
using UnityEngine;
using System.Collections;
public class HitPoint : MonoBehaviour {
public AI ai;
public Player player;
public Texture2D frameTexture;
Search WWH ::




Custom Search