// Use this for initialization void Start() { activeWeaponType = Constants.Pistol; activeGun = pistol; gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag)); }
// 2 private void pickupAssaultRifleAmmo() { ammo.AddAmmo(Constants.AssaultRifle, 50); gameUI.SetPickUpText("Assault rifle ammo picked up + 50 ammo"); if (gunEquipper.GetActiveWeapon().tag == Constants.AssaultRifle) { gameUI.SetAmmoText(ammo.GetAmmo(Constants.AssaultRifle)); } }
void loadWeapon(GameObject weapon) { pistol.SetActive(false); assaultRifle.SetActive(false); shotgun.SetActive(false); weapon.SetActive(true); activeGun = weapon; gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag)); }
private void PickupPistolAmmo() { ammo.AddAmmo(Constants.Pistol, 20); gameUI.SetPickUpText("Pistol ammo picked up + 20 ammo"); if (gunEquipper.GetActiveWeapon().tag == Constants.Pistol) { gameUI.SetAmmoText(ammo.GetAmmo(Constants.Pistol)); } }
void Update() { DisplayAmmo(); if (Input.GetMouseButtonDown(0) && canShoot) { if (ammoSlot.GetAmmo(ammoType) > 0) { StartCoroutine(Shoot()); } } }
private IEnumerator Shoot() { canShoot = false; if (ammo.GetAmmo(type) > 0) { ammo.ReduceAmmo(type); UpdateUI(); ProcessRaycast(); PlayMuzzleFlash(); } yield return(new WaitForSeconds(secondsBetweenShots)); canShoot = true; }
private void loadWeapon(GameObject weapon) { sniper.SetActive(false); weapon.SetActive(true); activeGun = weapon; gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag)); }
private void pickupSniperAmmo() { ammo.AddAmmo(Constants.Sniper, 5); gameUI.SetPickupText("Pickup: Ammo +5"); if (gunEquipper.GetActiveWeapon().tag == Constants.Sniper) { gameUI.SetAmmoText(ammo.GetAmmo(Constants.Sniper)); } }
void Update() { if (CrossPlatformInputManager.GetButtonDown("Fire1") && canShoot) { if (ammoSlot.GetAmmo(ammoType) > 0) { StartCoroutine(Shoot()); } } }
//load the correct weapon private void SelectWeapon(GameObject weapon) { //set all as inactive Pistol.SetActive(false); AssaultRifle.SetActive(false); Shotgun.SetActive(false); weapon.SetActive(true); activeGun = weapon; gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag)); }
private void loadWeapon(GameObject weapon) { // Set all weapons inactive pistol.SetActive(false); assaultRifle.SetActive(false); shotgun.SetActive(false); // Activate the given weapon weapon.SetActive(true); activeGun = weapon; // Set the ammo UI element appropriately gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag)); }
private void processHit(GameObject hitObject) { if (hitObject.GetComponent <Player>() != null) { hitObject.GetComponent <Player>().TakeDamage(damage); } if (hitObject.GetComponent <Robot>() != null) { if (ammo.GetAmmo(tag) > 0) { hitObject.GetComponent <Robot>().TakeDamage(damage); } } }
private void loadWeapon(GameObject weapon) { //disables all guns pistol.SetActive(false); assaultRifle.SetActive(false); shotgun.SetActive(false); rocket.SetActive(false); //enables gun the player wants to switch to weapon.SetActive(true); activeGun = weapon; gameUI.SetAmmoText(ammo.GetAmmo(activeGun.tag)); }
private void Ammo(Ammo ammoValue) { for (int i = 0; i < inventory.weapons.Count; ++i) { if (inventory.weapons[i].weaponType == ammoValue.GetAmmoType()) { var getAmmo = ammoValue.GetAmmo(); inventory.weapons[i].ammo += getAmmo; ammoUI.text = "Ammo: " + inventory.weapons[i].ammo; audioSource.clip = ammoValue.GetAudioClip(); audioSource.Play(); setMessage.SetMessage("Picked Up Ammo"); return; } } setMessage.SetMessage("You do not have this weapon"); }
// Update is called once per frame void Update() { text.text = ammoSlot.GetAmmo(ammoType).ToString(); }