Graphics Reference
In-Depth Information
There may also be several custom states that are applicable to particular types of
games, such as a state for showing a cutscene or perhaps a state for playing a special audio
clip. I recommend creating a new state for any game action that affects how one or more
of your scripts work. That way, you can always have the scripts rely on the game controller
to know how to behave.
The base game controller script, found in Scripts/BASE, looks like this:
public class BaseGameController : MonoBehavior
{
bool paused;
public GameObject explosionPrefab;
public virtual void PlayerLostLife ()
{
// deal with player life lost (update U.I. etc.)
}
public virtual void SpawnPlayer ()
{
// the player needs to be spawned
}
public virtual void Respawn ()
{
// the player is respawning
}
public virtual void StartGame()
{
// do start game functions
}
public void Explode ( Vector3 aPosition )
{
// instantiate an explosion at the position passed into this function
Instantiate( explosionPrefab,aPosition, Quaternion.identity );
}
public virtual void EnemyDestroyed( Vector3 aPosition, int pointsValue,
int hitByID )
{
// deal with enemy destroyed
}
public virtual void BossDestroyed()
{
// deal with the end of a boss battle
}
public virtual void RestartGameButtonPressed()
{
// deal with restart button (default behavior re-loads the
// currently loaded scene)
Application.LoadLevel(Application.loadedLevelName);
}
public bool Paused
{
Search WWH ::




Custom Search