Skip to content

Instantly share code, notes, and snippets.

@DaveVoyles
Created December 16, 2014 14:03
Show Gist options
  • Save DaveVoyles/9dc2e4b2399d4acad7b8 to your computer and use it in GitHub Desktop.
Save DaveVoyles/9dc2e4b2399d4acad7b8 to your computer and use it in GitHub Desktop.
//<summary>
//Check for user input and switch weapons accordingly
//</summary>
private void CheckIfSwitchingWeapon()
{
if (Input.GetButtonDown("SwitchWeapon"))
{
NextWeapon();
}
}
//<summary>
// Picks up the new weapon & adds it to inventory array, then sets it as active weapon
//</summary>
//<param name="weapon">Which weapon should we add to the inventory?</param>
public void PickupWeapon(int weapon)
{
weaponInventory[weapon] = true;
SwitchToWeapon(weapon);
currentWeaponIndex = weapon;
print("Current weapon pick up is: " + weapon);
}
/// <summary>
/// Switches to weapon when the player picks it up
/// </summary>
/// <param name="weapon">Which weapon did we just pickup?</param>
public void SwitchToWeapon(int weapon)
{
if (weaponInventory[weapon])
{
// animate putting currentWeapon away
BulletPreset = (BulletPresetType)weapon;
// animate pulling out currentWeapon
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment