public void AddAmmoWeaponsEquiped(int count) { firstWeapon.AddAmmo(count); if (secondaryWeapon) { secondaryWeapon.AddAmmo(count); } OnWeaponChange(currentWeapon.currentAmmoOnCharger, currentWeapon.totalAmmo); }
void OnCollisionEnter(Collision collision) { Gun gunComponent = collision.collider.gameObject.GetComponent <Gun>(); if (gunComponent != null) { gunComponent.AddAmmo(amount); Destroy(gameObject); } }
public void AddAmmo(Weapon.TYPE weaponType,float percent) { if (!(equipments[(int)weaponType] == null)) { Gun component = equipments[(int)weaponType].GetComponent <Gun>(); if (component != null) { component.AddAmmo(percent); } } }
public override void Consume(Collider other) { PlayerWeapon playerWeapon = other.gameObject.GetComponent <PlayerWeapon>(); if (playerWeapon != null) { Gun gun = playerWeapon.Guns[WeaponIndex]; gun.AddAmmo(Ammo); Destroy(gameObject); } }
public bool AddAmmo(int amount, Gun.categories ammoType) { //Will update the primary weapon's ammo whenever called because the amount shown to the shotgun only changes when you add if (primaryWeapon.CanPickupAmmo(ammoType)) { primaryWeapon.AddAmmo(amount); return(true); } else if (secondaryWeapon.CanPickupAmmo(ammoType)) { secondaryWeapon.AddAmmo(amount); return(true); } else { return(false); } }
// @TODO: handle multiple candidates by taking the closest one // @TODO: if the weapon we're in the trigger of is already held, ignore // if the weapon is owned by something, dont include it void OnTriggerEnter(Collider collider) { if (collider.gameObject.tag == "Gun") { canPickupWeapon = true; candidateWeapon = collider.gameObject.transform.parent.gameObject; } else { // @BUG: return; } Gun gun = candidateWeapon.GetComponent <Gun>(); bool canPickup = true; // @GACK: this isnt the most elegant way to check weapons, if (activeWeaponIndex >= 0) { for (int i = 0; i < 2; i++) { if (weapons[i] == null) { continue; } Gun activeGun = weapons[i].GetComponent <Gun>(); Debug.Log(activeGun.type); if (activeGun.type == gun.type) { // @BUG: wtf why wont this work? Debug.Log(activeGun.ammoType); // @GACK: Its really gross we cant just check ammou count if (activeGun.ammoType == AmmoType.Plasma && gun.ammoInClip > activeGun.ammoInClip) { Debug.Log("CAN PICKUP DONT TAKE THE AMMO"); canPickup = true; } else { canPickup = false; int takenAmmo = activeGun.AddAmmo(gun.ammoCount + gun.ammoInClip); gun.ammoCount -= takenAmmo; } } else { canPickup &= true; } } } if (canPickup) { if (gun.owned) { candidateWeapon = null; canPickupWeapon = false; return; } pickupTextPrompt.active = true; Text text = pickupTextPrompt.GetComponent <Text>(); String message = "Press X to Pickup "; // @PERF: bake these messages out! text.text = message + gun.type.ToString(); } else { candidateWeapon = null; canPickupWeapon = false; } }
public void OnControllerColliderHit(Gun gunComponent) { gunComponent.AddAmmo(amount); Destroy(gameObject); }