示例#1
0
        private RotationInfo CreateRotated()
        {
            List <Vector2> list = Rotate(this.Points);
            RotationInfo   info = new RotationInfo(list, this.collection, this.index + 1);

            return(info);
        }
示例#2
0
        public static RotationInfo Create(List <Vector2> points)
        {
            Collection   collection = new Collection(points);
            RotationInfo info       = collection.Get(0);

            return(info);
        }
示例#3
0
        public FigureInfo(
            Figure sample,
            Vector2Int localPoint,
            Transform transform,
            Color color,
            FigureAssetScope figureAssetScope,
            GameParameters parameters,
            CubesArray cubesArray,
            AtomCubePool atomCubePool)
        {
            this.Color        = color;
            this.parameters   = parameters;
            this.cubesArray   = cubesArray;
            this.atomCubePool = atomCubePool;

            this.pos = localPoint;

            FigureAsset figureAsset = figureAssetScope.GetRandom();

            Figure figure = Util.CreateLocal(sample, transform, this.pos.ToVector3Int());

            figure.Color = color;

            figure.FigureAsset = figureAsset;
            this.cubesItems    = figure.CreateCubes(atomCubePool);
            this.Figure        = figure;

            List <Vector2> points = figureAsset.GetCubesPositions(0);

            this.rotationInfo = RotationInfo.Create(points);

            this.CheckStartPosition();

            this.UpdatePos();
        }
示例#4
0
        public bool CheckFigure(RotationInfo rotationInfo, Vector2Int newPos, bool checkCells)
        {
            RectInt rect = rotationInfo.Bounds;

            rect = rect.Offset(newPos);
            if (!this.Bounds.Contains(rect))
            {
                return(false);
            }

            if (checkCells)
            {
                foreach (Vector2Int point in rotationInfo.Points0)
                {
                    Vector2Int p    = point + newPos;
                    Cell       cell = this.GetCell(p);
                    if (cell == null)
                    {
                        continue;
                    }

                    if (cell.Type == CellType.Fixed)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
示例#5
0
            public Collection(List <Vector2> list)
            {
                RotationInfo info = new RotationInfo(list, this, 0);

                this.infos.Add(info);

                for (int i = 0; i < 3; i++)
                {
                    info = info.CreateRotated();
                    this.infos.Add(info);
                }
            }
示例#6
0
        public void SetFigure(RotationInfo figureAsset, Vector2Int point)
        {
            this.RemoveFigure();

            foreach (Vector2Int p in figureAsset.Points0)
            {
                Vector2Int pp   = p + point;
                Cell       cell = this.SetCell(pp, CellType.Figure);
                if (cell != null)
                {
                    this.figureCells.Add(cell);
                }
            }
        }
示例#7
0
        public void Rotate(bool left)
        {
            if (this.rotateAction != null)
            {
                return;
            }

            this.rotationInfo = this.rotationInfo.GetRotated(left);
            this.UpdateCubeArray();

            Vector2 position = this.GetPostion();

            this.rotateAction = new RotateAction(
                figure: this.Figure,
                multiplier: left ? 1f : -1f,
                position: position,
                parameters: this.parameters.FigureRotation);

            this.rotateAction.Complete += () => this.rotateAction = null;
        }