AudioSource GetAudioSource()
    {
        foreach (DestroySound D in AudioS)
        {
            if (D.gameObject.activeSelf)
            {
                continue;
            }
            return(D.Audio);
        }

        DestroySound D2 = Instantiate(Audio_Prefab, this.transform.position, Quaternion.identity, this.transform).GetComponent <DestroySound>();

        AudioS.Add(D2);
        D2.gameObject.SetActive(false);

        return(D2.Audio);
    }
Beispiel #2
0
    protected override void OnDestroyed()
    {
        if (_currentHitpoints <= 0.0f && leftWhenDestroyedInstance != null)
        {
            LeaveRuins();
        }

        if (DestroySound != null)
        {
            DestroySound.PlayEffect();
        }

        if (OnDestroy != null)
        {
            OnDestroy(this.gameObject, _lastHitFrom);
        }
        if (DestroyOnZeroHp)
        {
            Destroy(gameObject);
        }
    }