Exemplo n.º 1
0
    private void Spawn()
    {
        int num         = Random.Range(minSpawnNumber, maxSpawnNumber);
        int totalWeight = 0;

        foreach (var spawnSet in spawnSets)
        {
            totalWeight += spawnSet.weight;
        }

        for (int i = 0; i < num; i++)
        {
            int r = Random.Range(0, totalWeight - 1);
            foreach (var spawnSet in spawnSets)
            {
                r -= spawnSet.weight;
                if (r <= 0)
                {
                    Vector3 position = GetSpawnPoint();
                    if (position == PlayerController.Zero)
                    {
                        break;
                    }
                    CancerController cancer = Get(spawnSet.cancerName);
                    cancer.transform.position = position;
                    TerrainController.BakeNavMesh();
                    break;
                }
            }
        }
    }
Exemplo n.º 2
0
 public static void Recycle(CancerController cancer)
 {
     cancer.gameObject.SetActive(false);
     idleCancers[cancer.identifierName].Enqueue(cancer);
     TerrainController.BakeNavMesh();
 }