Beispiel #1
0
    private void  CreatePoolByType(ObjectTypeEnum typeEnum, int count)
    {
        List <GameObject> getObject;
        var isExists = _poolsObjects.TryGetValue(typeEnum, out getObject);

        if (isExists)
        {
            return;
        }
        _poolsObjects[typeEnum] = new List <GameObject>();
        for (var i = 0; i < count; i++)
        {
            var prefab = GetObjectInStorage <GameObject>(typeEnum);
            var clone  = _objectLoader.Instantiate(prefab, _configurateManager.GetPoolParent());
            clone.SetActive(false);
            _poolsObjects[typeEnum].Add(clone);
        }
    }
Beispiel #2
0
        private void CreateNewObject(Vector3 position)
        {
            var index      = Random.Range(0, _objectTypes.Count);
            var objectType = _objectTypes[index];
            var prefab     = _assetBundlesStorage.GetPrefabByObjectType(objectType);

            if (prefab == null)
            {
                // Вывод сообщения, что префаба с таким ObjectType нет.
                return;
            }

            var clone = _objectLoader.Instantiate(prefab);

            clone = _configurationTool.ConfigurateBaseObject(clone);
            clone.transform.localPosition = position;
            var renderer = clone.GetComponent <Renderer>();

            renderer.material.SetColor("_Color", Random.ColorHSV());

            var geometryObjectModel = new GeometryObjectModel
            {
                ClickCount = 0,
                Color      = renderer.material.color,
                Renderer   = renderer
            };

            var objectData = new ObjectData
            {
                ObjectType = objectType, GeometryObjectModel = geometryObjectModel
            };

            _objectsOnScene[clone] = objectData;

            Observable.Interval(System.TimeSpan.FromSeconds(_observableTime))
            .Subscribe(_ => ChangeColor(clone));
        }