Beispiel #1
0
    public void Hit()
    {
        if (hitCount < hitToDestroy)
        {
            hitCount++;
            UpdateVisualState();
            for (int i = 0; i < onHitParticles.Length; i++)
            {
                onHitParticles[i].Play();
            }
            if (hitCount >= hitToDestroy)
            {
                collider2D.enabled = false;
                renderer.enabled   = false;
                audio.clip         = destructionAudio;
                audio.Play();

                if (lootTable != null)
                {
                    lootTable.Drop(transform.position);
                }

                for (int i = 0; i < destructionParticles.Length; i++)
                {
                    destructionParticles[i].Play();
                }
            }
        }
    }
Beispiel #2
0
    private void DropLoot()
    {
        if (Loot != null)
        {
            GameObject drop = Loot.Drop();

            if (drop != null)
            {
                Instantiate(drop, transform.position, Quaternion.identity);
            }
        }
    }