示例#1
0
    private void SpawnUI()
    {
        if (currentlySpawnablePrefabs.Count == 0)
        {
            return;
        }

        int        spawnIndex             = Random.Range(0, currentlySpawnablePrefabs.Count);
        GameObject currentSpawnablePrefab = currentlySpawnablePrefabs[spawnIndex];
        var        spawned = Instantiate <GameObject>(currentSpawnablePrefab, canvas.transform);

        ruleController.RandomizeObject(spawned);

        ElementAttributes eA = currentSpawnablePrefab.GetComponent <ElementAttributes>();

        if (eA.IsUnique)
        {
            currentlySpawnablePrefabs.RemoveAt(spawnIndex);
        }

        if (eA.IsPersistent)
        {
            ++currentPresistentElements;
            if (currentPresistentElements >= GetLevelArrayValue(maxPersistentElement))
            {
                PurgetPersistentElements();
            }
        }
    }