Пример #1
0
    public void ReturnLaneSectionToPool(GameObject curObject)
    {
        List <GameObject> laneList;
        ObjectDifficulty  difficulty = GetDifficultyFromTag(curObject.tag);

        if (ObjectDictionary.TryGetValue(difficulty, out laneList))
        {
            curObject.SetActive(false);
            laneList.Add(curObject);
        }
    }
Пример #2
0
    private void CreateSectionList(ObjectDifficulty difficulty, List <GameObject> prefabs, int instancesPerPrefab)
    {
        List <GameObject> laneList = new List <GameObject>();

        foreach (GameObject lanePrefab in prefabs)
        {
            for (int i = 0; i < instancesPerPrefab; i++)
            {
                GameObject lane = GameObject.Instantiate(lanePrefab) as GameObject;
                lane.SetActive(false);
                lane.transform.localPosition = lane.transform.position;
                laneList.Add(lane);
            }
        }

        ObjectDictionary.Add(difficulty, laneList);
    }
Пример #3
0
    public GameObject GetLaneSectionFromPool(ObjectDifficulty difficulty)
    {
        List <GameObject> laneList;

        if (ObjectDictionary.TryGetValue(difficulty, out laneList))
        {
            if (laneList != null && laneList.Count > 0)
            {
                int randomIndex = Util.Instance.GetRandomValue(0, laneList.Count);

                GameObject lane = laneList[randomIndex];
                laneList.Remove(lane);

                return(lane);
            }

            return(null);
        }
        else
        {
            Debug.Log("Couldn't get section from pool");
            return(null);
        }
    }