Graphics Reference
In-Depth Information
{
Instantiate( powerUpPrefab,aPosition,Quaternion.identity );
powerupExplosionCounter=0;
}
}
Explode() is a simple function to instantiate an explosion special effect as required. Its
only parameter is a position for the explosion to happen at:
public void Explode ( Vector3 aPosition )
{
// instantiate an explosion at the position passed into this
// function
Instantiate( explosionPrefab,aPosition, Quaternion.identity );
}
When a player is hit by a projectile, its Player_SpaceShip_IP script component has its
LostLife() function called. It takes care of most of the logic behind the respawning and UI
update, but the instantiation of an explosion effect is dealt with by this PlayerHit() func-
tion, which will also be called by the player controller script:
public void PlayerHit(Transform whichPlayer)
{
BaseSoundController is called to play an explosion sound effect:
// tell our sound controller to play an explosion sound
BaseSoundController.Instance.PlaySoundByIndex( 2,
whichPlayer.position );
The Explode() function takes care of the particle effect:
// call the explosion function!
Explode( whichPlayer.position );
}
In contrast to the other example games in this topic, Interstellar Paranoids has its own
UI control script that uses Unity's OnGUI() system to render text to the screen. This script
holds a reference to the UI script in the variable UIControl. Rather than affecting GUIText
components directly, as the other example games do, the update calls to the UI simply pass
on the details to UIControl:
// UI update calls
public void UpdateScoreP1( int aScore )
{
if( UIControl != null )
UIControl.UpdateScoreP1( aScore );
}
public void UpdateLivesP1( int aScore )
{
if( UIControl != null )
UIControl.UpdateLivesP1( aScore );
}
public void UpdateScoreP2( int aScore )
Search WWH ::




Custom Search