示例#1
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);
        }
示例#2
0
        public List <AtomCubePool.Item> CreateCubes(AtomCubePool pool)
        {
            if (this.FigureAsset == null)
            {
                return(null);
            }

            List <AtomCubePool.Item> list    = new List <AtomCubePool.Item>();
            List <Vector2>           posList = this.FigureAsset.GetCubesPositions(this.RotationIndex);

            foreach (Vector2 p in posList)
            {
                AtomCubePool.Item item = this.CreateAtom(pool, p);
                list.Add(item);
            }
            return(list);
        }
示例#3
0
        public void OnValidate()
        {
            if (!this.wasOnValidate)
            {
                this.wasOnValidate   = true;
                this.prevFigureAsset = this.FigureAsset;
            }

            if (Util.IsPlayingOrWillChangePlaymode())
            {
                return;
            }

            if (!this.EnableGeneration)
            {
                return;
            }

            if (this.AtomCube == null)
            {
                return;
            }

            if (this.prevFigureAsset == this.FigureAsset)
            {
                return;
            }

            this.transform.DestroyChildrenOnDelayCall();

            AtomCubePool pool = new AtomCubePool(this.AtomCube, MaterialsScope.Cache.Default);

            this.CreateCubes(pool);

            this.prevFigureAsset = this.FigureAsset;
        }