Esempio n. 1
0
    private void DeactivateObstacles(bool _newGame)
    {
        // ----- DEACTIVATE PROJECTILES -----

        // Loop CURRENT PROJECTILES list in reverse in order to remove elements safely
        for (int i = currentProjectiles.Count - 1; i >= 0; i--)
        {
            // If projectile is eligible for deactivating
            if (_newGame ||
                (currentProjectiles[i].CheckIf_ItsActive() && currentProjectiles[i].CheckIf_ItsGone()))
            {
                // ----- REMOVE FROM "CURRENT PROJECTILE GROUPS" -----

                // Loop "current projectile groups" list
                for (int a = currentProjectileGroups.Count - 1; a >= 0; a--)
                {
                    // Loop projectiles in current group
                    for (int b = currentProjectileGroups[a].Count - 1; b >= 0; b--)
                    {
                        // If projectile is found
                        if (currentProjectileGroups[a][b] == currentProjectiles[i])
                        {
                            // Remove from list
                            currentProjectileGroups[a].RemoveAt(b);
                        }
                    }

                    // Remove child list from parent list if child list is empty
                    if (currentProjectileGroups[a].Count == 0)
                    {
                        currentProjectileGroups.RemoveAt(a);
                    }
                }

                // ----- DEACTIVATE -----

                // Deactivate obstacle wall child
                DeactivateObstacleWallChild(currentProjectiles[i].gameObject);

                // Deactivate projectile
                currentProjectiles[i].Deactivate();

                // ----- REMOVE FROM "CURRENT PROJECTILES" -----

                // Remove from list
                currentProjectiles.RemoveAt(i);
            }
        }

        // ----- DEACTIVATE MINIONS -----


        // ----- DEACTIVATE FLAWED PROJECTILES -----

        if (_newGame || (flawedProjectile.CheckIf_ItsActive() && flawedProjectile.CheckIf_ItsGone()))
        {
            flawedProjectile.Deactivate();
        }
    }