public void upgradeTurretType() //Upgrading to the Second turret Type { if (turretUpgraded == false) { if (spawnEnemy.Instance.numberKilled >= 100) { spawnEnemy.Instance.numberKilled -= 100; health = turretHandler.Instance.health; location = turretHandler.Instance.transform; turretFireRate = turretHandler.Instance.bulletDelay; //Toggling all weapon images on rifleWep.SetActive(true); shotgunWep.SetActive(true); launcherWep.SetActive(true); rifleWep2.SetActive(true); shotgunWep2.SetActive(true); launcherWep2.SetActive(true); Destroy(GameObject.Find("turretMain")); //destroying old turret turretHandler turretSecondForm = ((GameObject)Instantiate(turret2, location.position, location.rotation)).GetComponent <turretHandler> (); //instanciating new turret turretSecondForm.bulletDelay = turretFireRate; //setting new turret values equal to old values turretSecondForm.health = health; turretSecondForm.wepSelect = 1; turretSecondForm.rifleWep = rifleWep; turretSecondForm.shotgunWep = shotgunWep; turretSecondForm.launcherWep = launcherWep; turretSecondForm.rifleWep2 = rifleWep2; turretSecondForm.shotgunWep2 = shotgunWep2; turretSecondForm.launcherWep2 = launcherWep2; //reseting weapon highlight to rifle config rifleWep.SetActive(false); rifleWep2.SetActive(true); shotgunWep2.SetActive(false); launcherWep2.SetActive(false); turretUpgraded = true; } } else if (turretUpgraded == true) { upgradedText.text = "Turret already upgraded!"; } }
// Use this for initialization void Start() { Instance = this; }