Ejemplo n.º 1
0
        public override List <Vector2> TryRotate(List <Vector2> current, rotations currentRotation, rotationDirection direction)
        {
            if (direction == rotationDirection.clockwise)
            {
                this.position = (this.position + 1) % 4;
            }
            else
            {
                this.position = (this.position + 3) % 4;
            }

            int   maxX = 0;
            int   minX = 10;
            float centerX;
            int   maxY = -5;
            int   minY = 20;
            float centerY;

            foreach (Vector2 v in current)
            {
                if (v.X > maxX)
                {
                    maxX = (int)v.X;
                }
                if (v.X < minX)
                {
                    minX = (int)v.X;
                }
                if (v.Y > maxY)
                {
                    maxY = (int)v.Y;
                }
                if (v.Y < minY)
                {
                    minY = (int)v.Y;
                }
            }
            centerX = (minX + maxX) / 2;
            centerY = (minY + maxY) / 2;

            if (currentRotation == rotations.rotation1 && direction == rotationDirection.clockwise)
            {
                return(new List <Vector2> {
                    new Vector2(centerX + 1.5f, centerY + 2), new Vector2(centerX + 1.5f, centerY + 1), new Vector2(centerX + 1.5f, centerY), new Vector2(centerX + 1.5f, centerY - 1)
                });
            }
            if (currentRotation == rotations.rotation1 && direction == rotationDirection.counterclockwise)
            {
                return(new List <Vector2> {
                    new Vector2(centerX + 0.5f, centerY + 2), new Vector2(centerX + 0.5f, centerY + 1), new Vector2(centerX + 0.5f, centerY), new Vector2(centerX + 0.5f, centerY - 1)
                });
            }

            if (currentRotation == rotations.rotation2 && direction == rotationDirection.clockwise)
            {
                return(new List <Vector2> {
                    new Vector2(centerX + 1, centerY + 1.5f), new Vector2(centerX, centerY + 1.5f), new Vector2(centerX - 1, centerY + 1.5f), new Vector2(centerX - 2, centerY + 1.5f)
                });
            }
            if (currentRotation == rotations.rotation2 && direction == rotationDirection.counterclockwise)
            {
                return(new List <Vector2> {
                    new Vector2(centerX + 1, centerY + 0.5f), new Vector2(centerX, centerY + 0.5f), new Vector2(centerX - 1, centerY + 0.5f), new Vector2(centerX - 2, centerY + 0.5f)
                });
            }

            if (currentRotation == rotations.rotation3 && direction == rotationDirection.clockwise)
            {
                return(new List <Vector2> {
                    new Vector2(centerX + 0.5f, centerY + 1), new Vector2(centerX + 0.5f, centerY), new Vector2(centerX + 0.5f, centerY - 1), new Vector2(centerX + 0.5f, centerY - 2)
                });
            }
            if (currentRotation == rotations.rotation3 && direction == rotationDirection.counterclockwise)
            {
                return(new List <Vector2> {
                    new Vector2(centerX + 1.5f, centerY + 1), new Vector2(centerX + 1.5f, centerY), new Vector2(centerX + 1.5f, centerY - 1), new Vector2(centerX + 1.5f, centerY - 2)
                });
            }

            if (currentRotation == rotations.rotation4 && direction == rotationDirection.clockwise)
            {
                return(new List <Vector2> {
                    new Vector2(centerX + 2, centerY + 0.5f), new Vector2(centerX + 1, centerY + 0.5f), new Vector2(centerX, centerY + 0.5f), new Vector2(centerX - 1, centerY + 0.5f)
                });
            }
            if (currentRotation == rotations.rotation4 && direction == rotationDirection.counterclockwise)
            {
                return(new List <Vector2> {
                    new Vector2(centerX + 2, centerY + 1.5f), new Vector2(centerX + 1, centerY + 1.5f), new Vector2(centerX, centerY + 1.5f), new Vector2(centerX - 1, centerY + 1.5f)
                });
            }

            return(current);
        }
Ejemplo n.º 2
0
        public virtual List <Vector2> Rotate(List <Vector2> current, rotations currentRotation, rotationDirection direction, ref char?[,] array)
        {
            int            oldposition   = this.position;
            List <Vector2> afterrotation = TryRotate(current, currentRotation, direction);
            List <Vector2> mayberotated;

            foreach (Vector2 offset in this.kicks[oldposition][this.position])
            {
                mayberotated = MovePiece(afterrotation, offset);
                if (IsLegalPosition(mayberotated, ref array))
                {
                    return(mayberotated);
                }
            }
            this.position = oldposition;
            return(current);
        }
Ejemplo n.º 3
0
 public override List <Vector2> Rotate(List <Vector2> current, rotations currentRotation, rotationDirection direction, ref char?[,] array)
 {
     return(current);
 }
Ejemplo n.º 4
0
        public virtual List <Vector2> TryRotate(List <Vector2> current, rotations currentRotation, rotationDirection direction)
        {
            Vector2 center = getCenter(current);

            if (direction == rotationDirection.clockwise)
            {
                List <Vector2> newcurrent = new List <Vector2>();
                foreach (Vector2 v in current)
                {
                    newcurrent.Add(RotatePointClockwise(v, center));
                }
                this.position = (this.position + 1) % 4;
                return(newcurrent);
            }

            if (direction == rotationDirection.counterclockwise)
            {
                List <Vector2> newcurrent = new List <Vector2>();
                foreach (Vector2 v in current)
                {
                    newcurrent.Add(RotatePointCounterClockwise(v, center));
                }
                this.position = (this.position + 3) % 4;
                return(newcurrent);
            }
            return(current);
        }