示例#1
0
文件: CityHealth.cs 项目: i-h/ld46
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
         DontDestroyOnLoad(this);
     }
 }
示例#2
0
    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);
        }
    }