Example #1
0
    public void Spawn_Items(int SpawnNum = GLOBAL_VALUES.ITEMS_PER_SPAWN)
    {
        int Spawn_Number                    = SpawnNum;
        List <GameObject> spawns            = new List <GameObject>();
        List <GameObject> availableSpawners = GetAvailableSpawns();

        // Get three random spawners
        if (availableSpawners.Count >= Spawn_Number)
        {
            for (int i = 0; i < Spawn_Number; i++)
            {
                int num = Random.Range(0, (availableSpawners.Count));
                while (spawns.Contains(availableSpawners[num]))
                {
                    num = Random.Range(0, (availableSpawners.Count));
                }
                spawns.Add(availableSpawners[num]);
            }
            foreach (GameObject s in spawns)
            {
                ItemSpawner other = (ItemSpawner)s.GetComponent(typeof(ItemSpawner));
                other.Trigger();
            }
        }
    }