Example #1
0
    void Die()
    {
        objectPooler.DeactivateSpriteInPool(this.gameObject);

        /**
         *  This is to help with performance. There's only so many multipliers we want to be spawning at a single time (especially if a huge horde of drones die at once), else the frame rate drops considerably. We just assume any extra multipliers that need to spawn will be automatically collected by the player.
         */
        if (objectPooler.AllObjectsActiveForPool("Multiplier"))
        {
            Multiplier.TriggerCollect(numMultipliersOnDeath);
        }
        else
        {
            for (int i = 0; i < numMultipliersOnDeath; i++)
            {
                multiplierManager.SpawnSpriteAround(this.transform.position, multiplierSpawnRadius);
            }
        }

        OnDroneDeath?.Invoke(this);
    }