Пример #1
0
        private static Item CreateFunc(AtomCubePool pool, AtomCube sample)
        {
            AtomCube cube = Object.Instantiate(sample);

            Item item = new Item(pool, cube);

            return(item);
        }
Пример #2
0
        public AtomCubePool(AtomCube sample, MaterialsScope.Cache materialsCache)
            : base(pool => CreateFunc((AtomCubePool)pool, sample))
        {
            this.materialsCache = materialsCache ?? throw new Exception("materialsCache");

            Renderer renderer = sample.GetComponent <Renderer>();

            this.materialSample = renderer.sharedMaterial;
        }
Пример #3
0
        private AtomCubePool.Item CreateAtom(AtomCubePool pool, Vector2 p, Color?color = null)
        {
            AtomCubePool.Item item = pool.Get();
            AtomCube          cube = item.AtomCube;

            cube.transform.parent        = this.transform;
            cube.transform.localPosition = p;

            Renderer rndr = cube.GetComponent <Renderer>();

            this.SetMaterial(item, rndr, color);
            return(item);
        }
Пример #4
0
        private static void CreateRandomAtom(int x, int y, AtomCube atomCube, GameObject cupLayer, MaterialsScope materialsScope)
        {
            Vector3 localPoint = new Vector3(x + 0.5f, y + 0.5f, 0);
            Vector3 point      = cupLayer.transform.TransformPoint(localPoint);

            AtomCube atom = Instantiate(atomCube, point, Quaternion.identity, cupLayer.transform);

            Renderer rndr = atom.GetComponent <Renderer>();

            if (materialsScope?.Count > 0)
            {
                int color = Random.Range(0, materialsScope.Count);
                rndr.sharedMaterial = materialsScope.GetMaterial(color);
            }
        }
Пример #5
0
 public Item(AtomCubePool pool, AtomCube atomCube)
 {
     this.pool     = pool;
     this.AtomCube = atomCube;
     this.renderer = atomCube.GetComponent <Renderer>();
 }