Exemplo n.º 1
0
 // Author: DeAngelo Wilson
 protected GameShape(Block anchor, ShapeRenderer.Orientation orientation = ShapeRenderer.Orientation.ORIENT_0)
 {
     this.anchor         = anchor;
     this.blocks         = new List <Block>();
     this.orientation    = orientation;
     this.isAboutToPlace = false;
     this.isPlaced       = false;
 }
Exemplo n.º 2
0
        // Author: DeAngelo Wilson
        public IReadOnlyCollection <Vector2> GetOrientationOffsets(ShapeRenderer.Orientation ori)
        {
            List <Vector2> offsets;

            nextOriToOffsets.TryGetValue(ori, out offsets);

            return(offsets);
        }
Exemplo n.º 3
0
        // Dillon Gould
        public L1Shape(Block anchor, ShapeRenderer.Orientation orientation = ShapeRenderer.Orientation.ORIENT_0) : base(anchor, orientation)
        {
            this.color = ShapeRenderer.GetL1Color();
            anchor.SetColor(this.color);

            // Draw a grid and determine what the shape looks like when it is at 0, 90, 180, and 270 degrees.
            // Then determine the other block offsets. The anchor is (x, y), the block immediately on the right is (x+1, y), the block immediately below is (x, y-1), etc.
            // Handle adding/creating the other blocks for each potential orientation
            this.blocks.Add(anchor);

            switch (orientation)
            {
            case ShapeRenderer.Orientation.ORIENT_0:              // 0 - Anchor is on the top left
                this.blocks.Add(anchor.Copy(new Vector2(0, -1))); // Block the the left 2
                this.blocks.Add(anchor.Copy(new Vector2(1, 0)));  // Block to the right 3
                this.blocks.Add(anchor.Copy(new Vector2(2, 0)));  // Block below 4
                break;

            case ShapeRenderer.Orientation.ORIENT_1:             // 90 - anchor is on the top right
                this.blocks.Add(anchor.Copy(new Vector2(1, 0))); // Block above 2
                this.blocks.Add(anchor.Copy(new Vector2(0, 1))); // Block below 3
                this.blocks.Add(anchor.Copy(new Vector2(0, 2))); // Block to the left 4
                break;

            case ShapeRenderer.Orientation.ORIENT_2:              // 180 - anchor is on the bottom right
                this.blocks.Add(anchor.Copy(new Vector2(0, 1)));  // Block to the right 2
                this.blocks.Add(anchor.Copy(new Vector2(-1, 0))); // Block to the left 3
                this.blocks.Add(anchor.Copy(new Vector2(-2, 0))); // Block above 4
                break;

            case ShapeRenderer.Orientation.ORIENT_3:              // 270 - anchor is on the bottom left
                this.blocks.Add(anchor.Copy(new Vector2(-1, 0))); // Block  below 2
                this.blocks.Add(anchor.Copy(new Vector2(0, -1))); // Block above 3
                this.blocks.Add(anchor.Copy(new Vector2(0, -2))); // Block to the right 4
                break;

            default:
                throw new ArgumentException("Unexpected ShapeRenderer::Orientation in L1Shape constructor: " + orientation);
            }

            anchor.SetColor(ShapeRenderer.GetL1AnchorColor());

            //rotation offset dictionary
            this.nextOriToOffsets = new Dictionary <ShapeRenderer.Orientation, List <Vector2> >();

            // Note: Set the first Vector2 to (0, 0) to not move the anchor
            // 270 -> 0
            nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_0, new[] { new Vector2(0, 0), new Vector2(1, -1), new Vector2(1, 1), new Vector2(2, 2) }.ToList());
            // 0 -> 90
            nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_1, new[] { new Vector2(0, 0), new Vector2(1, 1), new Vector2(-1, 1), new Vector2(-2, 2) }.ToList());
            // 90 -> 180
            nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_2, new[] { new Vector2(0, 0), new Vector2(-1, 1), new Vector2(-1, -1), new Vector2(-2, -2) }.ToList());
            // 180 -> 270
            nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_3, new[] { new Vector2(0, 0), new Vector2(-1, -1), new Vector2(1, -1), new Vector2(2, -2) }.ToList());
        }
Exemplo n.º 4
0
        private L2Shape BasicShapeInitialize(out List <Vector2> coordinates, ShapeRenderer.Orientation ori)
        {
            Block   anchor = new Block(100, 100);
            L2Shape L_2    = new L2Shape(anchor, ori);

            coordinates = new List <Vector2>();
            foreach (Block b in L_2.blocks)
            {
                coordinates.Add(new Vector2(b.GetX(), b.GetY()));
            }

            return(L_2);
        }
Exemplo n.º 5
0
        private SquareShape BasicShapeInitialize(out List <Vector2> coordinates, ShapeRenderer.Orientation ori)
        {
            Block       anchor = new Block(100, 100);
            SquareShape square = new SquareShape(anchor, ori);

            coordinates = new List <Vector2>();
            foreach (Block b in square.blocks)
            {
                coordinates.Add(new Vector2(b.GetX(), b.GetY()));
            }

            return(square);
        }
Exemplo n.º 6
0
        // Author: Alex Schertler
        public Z1Shape(Block anchor, ShapeRenderer.Orientation orientation = ShapeRenderer.Orientation.ORIENT_0) : base(anchor, orientation)
        {
            // Check ShapeRenderer.draw___ which will tell you the color of the shape
            this.color = ShapeRenderer.GetZ1Color();
            anchor.SetColor(this.color);

            this.blocks.Add(anchor);

            switch (orientation)
            {
            case ShapeRenderer.Orientation.ORIENT_0:              // 0 - anchor is on the top middle collumn
            case ShapeRenderer.Orientation.ORIENT_2:
                this.blocks.Add(anchor.Copy(new Vector2(-1, 0))); // 1 (block to left)
                this.blocks.Add(anchor.Copy(new Vector2(0, -1))); // 4 (block below)
                this.blocks.Add(anchor.Copy(new Vector2(1, -1))); // 3 (block below and to right)
                break;

            case ShapeRenderer.Orientation.ORIENT_1:               // 90 - anchor is on the bottom right collumn
            case ShapeRenderer.Orientation.ORIENT_3:
                this.blocks.Add(anchor.Copy(new Vector2(0, 1)));   // 1 (block above)
                this.blocks.Add(anchor.Copy(new Vector2(-1, 0)));  // 4 (block to left)
                this.blocks.Add(anchor.Copy(new Vector2(-1, -1))); // 3 (block below and to left)
                break;

            default:
                throw new ArgumentException("Unexpected ShapeRenderer::Orientation in Z1Shape constructor: " + orientation);
            }

            anchor.SetColor(ShapeRenderer.GetZ1AnchorColor());

            //rotation offset dictionary
            this.nextOriToOffsets = new Dictionary <ShapeRenderer.Orientation, List <Vector2> >();

            var vectorSetOne = new[] { new Vector2(0, 0), new Vector2(-1, -1), new Vector2(1, -1), new Vector2(2, 0) };
            var vectorSetTwo = new[] { new Vector2(0, 0), new Vector2(1, 1), new Vector2(-1, 1), new Vector2(-2, 0) };

            // 270 -> 0
            nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_0, vectorSetOne.ToList());
            // 0 -> 90
            nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_1, vectorSetTwo.ToList());
            // 90 -> 180 (same as 270 -> 0)
            nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_2, vectorSetOne.ToList());
            // 180 -> 270 (same as 0 -> 90)
            nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_3, vectorSetTwo.ToList());
        }
Exemplo n.º 7
0
        // Author: Greg Kulasik
        public DummyShape(Block anchor, ShapeRenderer.Orientation orientation) : base(anchor, orientation)
        {
            // Check ShapeRenderer.draw___ which will tell you the color of the shape
            this.color = DrawColor.Shade.COLOR_GREY;

            this.blocks.Add(anchor);

            //rotation offset dictionary
            this.nextOriToOffsets = new Dictionary <ShapeRenderer.Orientation, List <Vector2> >();
            // 270 -> 0
            nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_0, new[] { new Vector2(0, 0) }.ToList());
            // 0 -> 90
            nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_1, new[] { new Vector2(0, 0) }.ToList());
            // 90 -> 180
            nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_2, new[] { new Vector2(0, 0) }.ToList());
            // 180 -> 270
            nextOriToOffsets.Add(ShapeRenderer.Orientation.ORIENT_3, new[] { new Vector2(0, 0) }.ToList());
        }
Exemplo n.º 8
0
        // Author: Greg Kulasik
        // Rotates the shape in place (Square is special since rotate does not change the shape but we need to show it rotating - so the anchor will rotate around)
        // New offsets are calculated for each 90 degree rotation
        // For each block apply the roation for that block (both lists are ordered - blocks move clockwise)
        protected void Rotate(List <Block> blocksToRotate)
        {
            ShapeRenderer.Orientation nextOri = GetNextOrientation();

            List <Vector2> rotationOffsets;

            if (nextOriToOffsets.TryGetValue(nextOri, out rotationOffsets))
            {
                for (int i = 0; i < blocksToRotate.Count(); i++)
                {
                    blocksToRotate.ElementAt(i).ApplyOffset(rotationOffsets.ElementAt(i));
                }
                if (canMutateOrientation)
                {
                    //set new orientation
                    this.orientation = nextOri;
                }
            }
        }