Esempio n. 1
0
    EnvironmentalistAi TakeFromEnvironmentalPool()
    {
        foreach (EnvironmentalistAi p in m_EnvironmentalCrowdPool)
        {
            if (!p.gameObject.activeInHierarchy)
            {
                return(p);
            }
        }

        GameObject obj = Instantiate(EnvironmentalPersonPrefab, transform.GetChild(1).transform, true);

        obj.SetActive(false);
        EnvironmentalistAi environmentalistAi = obj.GetComponent <EnvironmentalistAi>();

        m_EnvironmentalCrowdPool.Add(environmentalistAi);

        return(environmentalistAi);
    }
Esempio n. 2
0
    // call this func every wave
    public void GenerateActiveCrowd(int waveSize, float businessPercentage, float environmentalPercentage, Lane currentLane)
    {
        for (int i = 0; i < waveSize; i++)
        {
            // grab a business person
            if (Random.Range(0f, 1f) < businessPercentage)
            {
                EconomistAi p = TakeFromBusinessPool();
                currentLane.AddAiController(p, currentLane.transform.position);
                m_ActiveBusinessCrowd.Add(p);
            }

            // grab a environmental person
            else
            {
                EnvironmentalistAi p = TakeFromEnvironmentalPool();
                currentLane.AddAiController(p, currentLane.transform.position);
                m_ActiveEnvironmentalCrowd.Add(p);
            }
        }
    }