Graphics Reference
In-Depth Information
// the 'isLoaded' var tells us if this weapon is loaded and
// ready to fire
isLoaded= true;
}
public virtual void SetCollider( Collider aCollider )
{
parentCollider= aCollider;
}
public virtual void Fire( Vector3 aDirection, int ownerID )
{
// be sure to check canFire so that the weapon can be
// enabled or disabled as required!
if( !canFire )
return;
// if the weapon is not loaded, drop out
if( !isLoaded )
return;
// if we're out of ammo and we do not have infinite ammo,
// drop out...
if( ammo<=0 && !isInfiniteAmmo )
return;
// decrease ammo
ammo--;
// generate the actual projectile
FireProjectile( aDirection, ownerID );
// we need to reload before we can fire again
isLoaded= false;
// schedule a completion of reloading in <reloadTime>
// seconds:
CancelInvoke( "Reloaded" );
Invoke( "Reloaded", reloadTime );
}
public virtual void FireProjectile( Vector3 fireDirection, int
ownerID )
{
// make our first projectile
theProjectile= MakeProjectile( ownerID );
// direct the projectile toward the direction of fire
Search WWH ::




Custom Search