コード例 #1
0
    PoolObject SpawnPatternObject(ChildInfo info, Vector3 pos)
    {
        var type = ObjectType.Group;

        if (!Enum.TryParse(info.ObjectName, out type))
        {
            return(null);
        }

        var obj = _pool.GetObjectOfType <PoolObject>(type);

        if (obj == null)
        {
            Debug.LogError("There is no " + info.ObjectName + " object in pool!");

            return(null);
        }

        obj.transform.position = pos;


        if (type == ObjectType.Group)
        {
            var group = (obj as GroupPoolObject);

            if (group != null)
            {
                group.Init(_pool, _currentColor);
            }
        }

        obj.AcceptSettings(info.Settings);

        return(obj);
    }
コード例 #2
0
    void SpawnCells()
    {
        if (_pool == null)
        {
            Debug.LogError("Group " + gameObject.name + " dont have pool access!");
            return;
        }

        for (var i = 0; i < _cellsCoordinates.Count; i++)
        {
            var obj = _pool.GetObjectOfType <CellPoolObject>(_cellsCoordinates[i].CellType);
            obj.transform.SetParent(transform);
            obj.transform.localPosition = _cellsCoordinates[i].Position;
            Color = PlayerPass ? _currentCollors.LightColor : _currentCollors.DarkColor;
            obj.SetColor(Color);

            _cellsObjects.Add(obj);

            obj.Join(this);
        }
    }