public void Shoot() { if (time <= 0) { if (ammo > 0) { AnimMenagment(wepon, "Shoot"); Instantiate(bulletPrefab, FierPoint.position, FierPoint.rotation); muzzle = Instantiate(muzzlePrefab, FierPoint.position, FierPoint.rotation); Destroy(muzzle.gameObject, 0.09f); time = timeShoot; ammo--; txtAmmo.text = ammo.ToString(); } else { reload.PlayerSounds("Reload"); AnimMenagment(wepon, "Reload"); if (akAmmo.enabled == true && akAmmo.text != "0") { int i = int.Parse(akAmmo.text); i -= playerAmmo; akAmmo.text = i.ToString(); } else { wepon = "Pistol"; animPlayer.SetBool("AK", false); playerAmmo = 7; timeShoot = 0.5f; infinity.enabled = true; goAkAmmo.SetActive(false); FierPoint.position = new Vector2(FierPoint.position.x - 0.06f, FierPoint.position.y - 0.06f); } ammo = playerAmmo; txtAmmo.text = ammo.ToString(); } } else { time -= Time.deltaTime; } }
private void Awake() { soundMenager = GameObject.Find("SoundMenager"); bulletSound = soundMenager.GetComponent <SoundMenager>(); bulletSound.PlayerSounds("gunShoot"); }