private void Awake() { if (Instance != null) { Destroy(gameObject); } else { Instance = this; DontDestroyOnLoad(this); } }
public void DestroyMe() { if (isDestroyed) { return; } if (Intersection.spawningEnabled == false) { Intersection.spawningEnabled = true; if (deployTanksClip) { AudioSource.PlayClipAtPoint(deployTanksClip, transform.position); } } isDestroyed = true; foreach (GameObject d in debris) { Instantiate(d, transform.position, transform.rotation); } Destroy(gameObject); if (countsTowardsScore) // Misnamed: This is "counts towards victory" { CityHealth.LoseHealth(); } Score.AddPoints(pointValue); if (deathSound) { AudioSource.PlayClipAtPoint(deathSound, transform.position); } }