//Decides how to dispose of an object depending on if it's a player or anything else. public void ObjectKill(GameObject obj) { if (obj.tag == "Player") { Instantiate(obj.GetComponent <scr_Dest_Collision> ().playerExplosion, obj.transform.position, obj.transform.rotation); gameController.GameOver(); Destroy(obj.gameObject); Destroy(gameObject); } else { Instantiate(obj.GetComponent <scr_Dest_Collision> ().explosion, obj.transform.position, obj.transform.rotation); obj.GetComponentInParent <scr_DamageSystem> ().addScore(obj.GetComponentInParent <scr_DamageSystem> ().scoreValue); if (obj.GetComponentInParent <scr_HealthSystem>().health <= 0) { //Debug.Log (string.Format ("{0} health: {1}", obj.name, obj.GetComponentInParent<scr_HealthSystem> ().health)); Destroy(obj.gameObject); } else { return; } } }
// Use this for initialization void Update() { foreach (GameObject bullet in WeaponTypes) { if (bullet.tag != "SS") { bullet.GetComponent <BoltCollision>().stats.Damage = stats.Damage; } } if (rb.useGravity) { countdown -= Time.deltaTime; if (countdown <= 0f) { Instantiate(explosion, transform.position, transform.rotation); Destroy(this.gameObject); } transform.Rotate(transform.right, 30 * Time.deltaTime); transform.Rotate(transform.up, 60 * Time.deltaTime); } if (locked) { return; } if (Input.GetButton("Fire1") && Time.time > nextFire) { FireWeapon(); nextFire = Time.time + stats.fireRate; if (powerUpMeter < 100 && !powerActive && powerTimer == -1f) { powerUpMeter += increase; } } if (Input.GetButton("Fire2") && powerUpMeter > 0 && powerActive) { powerupAction("Active", this); } if ((powerTimer <= 0 && powerTimer > -1)) { powerUpMeter = 0; powerActive = false; powerupAction("Deactivate", this); } if (powerUpMeter == 100) { powerActive = true; } if (powerUpMeter > 100) { powerUpMeter = 100; } if (powerTimer > -1f) { powerTimer -= Time.deltaTime; } else { powerTimer = -1f; } if (weaponStrength > 5) { weaponStrength = 5; } //Check if player's supposed to be dead if (dead) { gameController.GameOver(); locked = true; rb.useGravity = true; } }