Graphics Reference
In-Depth Information
First, the current weapon is disabled in anticipation of setting a new one:
// disable the current weapon
DisableCurrentWeapon();
selectedWeaponSlot index number is incremented and validated to make sure that it
now contains a valid index number (this is where the slot number will be looped back to
zero if it goes over the total number of available weapons):
// next slot
selectedWeaponSlot++;
// make sure that the slot isn't higher than the total
// number of weapons in our list
if(selectedWeaponSlot==weaponScripts.Count)
{
if(shouldLoop)
{
selectedWeaponSlot= 0;
} else {
selectedWeaponSlot= weaponScripts.Count-1;
}
}
The lastSelectedWeaponSlot gets updated before the new current weapon is enabled,
completing the function:
// we store this selected slot to use to prevent duplicate
// weapon slot setting
lastSelectedWeaponSlot=selectedWeaponSlot;
// enable the newly selected weapon
EnableCurrentWeapon();
}
PrevWeaponSlot works in almost exactly the same way as NextWeaponSlot(). It has a
Boolean parameter to state whether or not to loop around if the current weapon slot drops
below zero, and the most obvious difference is that the selectedWeaponSlot variable is
decremented rather than incremented:
public virtual void PrevWeaponSlot (bool shouldLoop)
{
// disable the current weapon
DisableCurrentWeapon();
// prev slot
selectedWeaponSlot--;
// make sure that the slot is a sensible number
if( selectedWeaponSlot<0 )
{
if(shouldLoop)
Search WWH ::




Custom Search