private void DisplayAmmo() { int ammoAmount = ammoSlot.GetCurrentAmmo(ammoType); ammoText.text = ammoAmount.ToString(); switch (ammoType) { case AmmoType.Lightammo: lightAmmoIcon.enabled = true; heavyAmmoIcon.enabled = false; shellIcon.enabled = false; break; case AmmoType.Heavyammo: lightAmmoIcon.enabled = false; heavyAmmoIcon.enabled = true; shellIcon.enabled = false; break; case AmmoType.Shells: lightAmmoIcon.enabled = false; heavyAmmoIcon.enabled = false; shellIcon.enabled = true; break; } }
private void DisplayAmmo() { int currentAmmo = ammoSlot.GetCurrentAmmo(ammoType); ammoCount.text = currentAmmo.ToString(); ammoKind.text = ammoType.ToString(); }
private void Water() { if (ammoSlot.GetCurrentAmmo() > 0) { PlayWateringFx(); ProccessRayCast(); ammoSlot.ReduceCurrentAmmo(); } }
void Update() { DisplayAmmo(); if (ammoSlot.GetCurrentAmmo(ammoType) <= 0) { return; } if (Input.GetButtonDown("Fire1") && canShoot == true) { StartCoroutine(Shoot()); } }
IEnumerator Shoot() { canShoot = false; if (ammoSlot.GetCurrentAmmo() > 0) { PlayMuzzleFlash(); ProcessRaycast(); ammoSlot.ReduceCurrentAmmo(); } else if (ammoSlot.GetCurrentAmmo() <= 0) { Debug.Log("Out of Ammo!"); } yield return(new WaitForSeconds(TimeBetweenShots)); canShoot = true; }
private void Shoot() { if (ammoSlot.GetCurrentAmmo(ammoType) > 0) { PlayMuzzleFlash(); Process(); ammoSlot.ReduceCurrentAmmo(ammoType); } }
IEnumerator Shoot() { canShoot = false; if (ammoSlot.GetCurrentAmmo(ammoType) > 0) { PlayMuzzleFlash(); ProcessRayCast(); GetComponent <AudioSource>().Play(); ammoSlot.ReduceAmmo(ammoType); } else { GetComponent <AudioSource>().PlayOneShot(noBulletSound); } yield return(new WaitForSeconds(timeBetweenShots)); canShoot = true; }
void Update() { DisplayAmmo(); if (Input.GetButtonDown("Fire1") && canShoot == true) { StartCoroutine(Shoot()); } if (Input.GetKeyDown(KeyCode.R)) { if (ammoSlot.GetCurrentAmmo(ammoType) == ammoSlot.GetAmmoInGun(ammoType)) { //do nothing } else { StartCoroutine(Reload()); } } }
void Update() { DisplayAmmo(); if (semiAuto) { if (Input.GetMouseButtonDown(0) && ammoSlot.GetCurrentAmmo(ammoType) > 0 && ableToShoot) { Shoot(); StartCoroutine(ShotDelay()); } } else { if (Input.GetMouseButton(0) && ammoSlot.GetCurrentAmmo(ammoType) > 0 && ableToShoot) { Shoot(); StartCoroutine(ShotDelay()); } } }
void Update() { bool isValidShot = Input.GetMouseButtonDown(0) && // is mouse button down? ammoSlot.GetCurrentAmmo(ammoType) > 0 && // is ammo greater than 0? canShoot; // is shot too soon before last shot if (isValidShot) { StartCoroutine(Shoot()); } }
private void Update() { DisplayAmmo(); if (isReloading) { return; } if (ammoSlot.GetCurrentAmmo(ammoType) <= 0) { StartCoroutine(Reload()); return; } if (Input.GetMouseButton(0) && Time.time >= nextTimeToFire) { nextTimeToFire = Time.time + 1f / fireRate; Shoot(); } }
// private void Shoot() { if (ammoSlot.GetCurrentAmmo() > 0) { PlayMuzzleFlash(); ammoSlot.ReduceCurrentAmmo(); ProcessRaycast(); } else { Debug.Log("CLICK CLICK ALL OUT!"); } }
private IEnumerator Shoot() { canShoot = false; if (ammoSlot.GetCurrentAmmo(ammoType) > 0) { ammoSlot.ReduceCurrentAmmo(ammoType); PlayMuzzleFlash(); ProcessRaycast(); } yield return(new WaitForSeconds(shootingDelay)); canShoot = true; }
IEnumerator Shoot() { canShoot = false; if (ammoSlot.GetCurrentAmmo(ammoType) > 0) { PlayMuzzleFlash(); ProcessRaycast(); ammoSlot.ReduceCurrentAmmo(ammoType); } yield return(new WaitForSeconds(timeBetweenShots)); canShoot = true; }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { int currentAmmo = ammo.GetCurrentAmmo(ammoType); int maxAmmo = ammo.GetMaxAmmo(ammoType); if (currentAmmo == maxAmmo) { return; } ammo.RaiseAmmoAmount(ammoType, ammoAmount); Debug.Log(ammoType + " Item Pickup"); Destroy(gameObject); } }
IEnumerator Shoot() { canShoot = false; if (ammoSlot.GetCurrentAmmo(activeWeapon.ammoType) > 0) //if the ammo of the type of the active weapon you hold are more than 0 { onShootEvent?.Invoke(this, EventArgs.Empty); PlayShootingSound(); if (activeWeapon.isHitscan) //If the weapon is hitscan shoot ray { float range = activeWeapon.weaponRange; int damage = activeWeapon.weaponDamage; RaycastHit hit; Ray landingRay = new Ray(cameraPosition.position, cameraPosition.transform.forward); if (Physics.Raycast(landingRay, out hit, range)) { if (hit.transform.tag == "Enemy") { MessagesHandler.Instance.WriteMessage("hit " + hit.transform.name + " with " + activeWeapon.weaponDamage); hit.transform.GetComponent <Health>().TakeDamage(damage); } } } else //If the weapon is not hitscan shoot the weapon bullet { GameObject bullet = Instantiate(activeWeapon.bullet, shootingPoint.position, Quaternion.identity); bullet.GetComponent <Bullet>().SetBulletDirection(shootingPoint.transform.forward); Destroy(bullet, 3); } } yield return(new WaitForSeconds(activeWeapon.weaponDelay)); canShoot = true; }
private void ShowAmmoAmount() { gameplayUI.GetComponentInChildren <Text>().text = ammoSlot.GetCurrentAmmo(ammoType).ToString(); }
void OnEnable() { canShoot = true; UIcanvas.UpdateAmmoDisplay(ammoSlot.GetCurrentAmmo(ammoType)); }
private void DisplayAmmo() { int currentAmmo = ammoSlot.GetCurrentAmmo(); ammoText.text = currentAmmo.ToString(); }
private void DisplayAmmo() { int ammo = ammoSlot.GetCurrentAmmo(ammoType); ammoDisplayText.text = ammo.ToString(); }
private void UpdateAmmoUI() { int currentAmmo = ammoSlot.GetCurrentAmmo(ammoType); ammoUIText.text = currentAmmo.ToString("# ###"); }
private void DisplayAmmo() { ammoText.text = ammoSlot.GetCurrentAmmo(ammoType).ToString(); }