public void shoot() { if (Time.time >= nextFire && AmmoCounter.AmmodownRocket > 0) { /*IsReloading = true; * if(BotDifficult.noob) * nextFire = Time.time + 3; * if (BotDifficult.abitharder) * nextFire = Time.time + 4; * if (BotDifficult.impossible) * nextFire = Time.time + 5; * reloadRate = nextFire - Time.time;*/ GameObject clone = Instantiate(shot, rPos01.position, rPos01.rotation); GameObject clone2 = Instantiate(shot1, rPos02.position, rPos02.rotation); clone.SetActive(true); clone2.SetActive(true); Destroy(clone, 5f); Destroy(clone2, 5f); AmmoCounter.AmmodownRocket -= 1; Fill.fillAmount = 0; } if (AmmoCounter.AmmodownRocket <= 0) { Zero_ammo.SetActive(true); } }
void Update() { delay += 1 * Time.deltaTime; if (PlayerPrefs.GetString("WeaponTag") == "Laser" || !PlayerPrefs.HasKey("WeaponTag")) { if (pointerDown && delay > 0.85f) { cannon.SetActive(true); particles.SetActive(true); if (temp.x <= 3.28f) // Animation function for laser. { temp.x = (ION_Cannon.size.x) + (18f * Time.deltaTime); ION_Cannon.size = temp; } Blastercount.Ammodownlazer -= 10 * Time.deltaTime; if (PlayerPrefs.GetString("WeaponTag") == "Laser" || !PlayerPrefs.HasKey("WeaponTag")) { LaserFill.fillAmount = Blastercount.Ammodownlazer / _lazerfirstammo; } } } if (PlayerPrefs.GetString("WeaponTag") == "Blaster" && pointerDown) { if (Time.time > lazernextFire && Blastercount.Ammodownlazer > 0) { lazernextFire = Time.time + 0.5f; GameObject clonelazer = Instantiate(lazer, lazer1.position, lazer1.rotation); clonelazer.SetActive(true); Destroy(clonelazer, 4f); Blastercount.Ammodownlazer -= 1; Debug.Log("Lazer count -1"); } if (Blastercount.Ammodownlazer <= 0) { Zero_ammo.SetActive(true); } } else if (Blastercount.Ammodownlazer < _lazerfirstammo && !pointerDown) { if (BotDifficult.DifficultRate == DifficultRate.Easy) { ammo = (Blastercount.Ammodownlazer += 2 * Time.deltaTime).ToString("F2"); } if (BotDifficult.DifficultRate == DifficultRate.Medium) { ammo = (Blastercount.Ammodownlazer += 3 * Time.deltaTime).ToString("F2"); } if (BotDifficult.DifficultRate == DifficultRate.Hard) { ammo = (Blastercount.Ammodownlazer += 4 * Time.deltaTime).ToString("F2"); } Blastercount.Ammodownlazer = float.Parse(ammo); LaserFill.fillAmount = Blastercount.Ammodownlazer / _lazerfirstammo; } if (!pointerDown || Blastercount.Ammodownlazer <= 0) { _loopSource.Stop(); pointerDown = false; temp.x = 0; ION_Cannon.size = temp; particles.SetActive(false); cannon.SetActive(false); } }