Example #1
0
    void OnEnemyDeath(Transform enemyTransform)
    {
        enemiesAlive--;
        if (enemiesAlive <= 0)
        {
            GoToNextRoom();
            roomCleared = true;

            //DROPS

            MoneyDrop currentMoneyDrop = Instantiate(moneyDrop,
                                                     enemyTransform.position + Vector3.up * 2, Quaternion.identity) as MoneyDrop;
            currentMoneyDrop.SetAmount(UnityEngine.Random.Range(enemiesSpawned * 2, enemiesSpawned * 4));
            currentMoneyDrop.InitialForce();
            currentDrops.Add(currentMoneyDrop);

            //CHANGE TO VARIABLE SPAWN PERCENT
            if (UnityEngine.Random.Range(0f, 1f) < 0.2f)
            {
                Drop drop        = GetRandomDrop();
                Drop currentDrop = Instantiate(drop, enemyTransform.position + Vector3.up * 2, Quaternion.identity) as Drop;
                currentDrop.InitialForce();
                currentDrops.Add(currentDrop);
            }
        }
    }