Graphics Reference
In-Depth Information
If weaponControl is not null (suggesting that a weapon control script exists, and we
have a usable reference to it), the script now goes ahead and makes the call to weapon
Control.Fire():
// tell weapon control to fire, if we have a weapon
// controller
if(weaponControl!=null)
{
// tell weapon to fire
weaponControl.Fire();
}
After the call to fire the weapon has been made, canFire is set to false to delay firing
until the function ResetFire() is called to set it back to true again. An Invoke call sets up
the call to ResetFire at a time set by fireDelayTime:
// set a flag to disable firing temporarily (providing a
// delay between firing)
canFire= false;
// invoke a function call in <fireDelayTime> to reset
// canFire back to true, allowing another firing session
Invoke ( "ResetFire", fireDelayTime );
}
}
}
canFire is reset by ResetFire(), meaning that after the delay set by fireDelayTime, this
enemy can fire its weapon again:
public void ResetFire ()
{
canFire=true;
}
}
Search WWH ::




Custom Search