Esempio n. 1
0
 public Shape()
 {
     myorientation = Shape_Orientation.ZERO;
     myshape       = (Shape_choice)Random.Range(1, 8);
     //myshape = (Shape_choice) 2;
     shape_parts = Create_choice(myshape);
     mycolor     = Shape_coloring(myshape);
 }
Esempio n. 2
0
    public void Shape_rotate_anticlockwise()
    {
        if (myshape == Shape_choice.O)
        {
            return;
        }
        else
        {
            myorientation--;
            if (myorientation < Shape_Orientation.ZERO)
            {
                myorientation = Shape_Orientation.ZERO;
            }

            if (myshape == Shape_choice.I)
            {
                if (myorientation == Shape_Orientation.NINTY)
                {
                    for (int part_of_shape = 0; part_of_shape < 4; part_of_shape++)
                    {
                        shape_parts[part_of_shape].position += Vector2.right;
                    }
                }
                if (myorientation == Shape_Orientation.ONEEIGHTY)
                {
                    for (int part_of_shape = 0; part_of_shape < 4; part_of_shape++)
                    {
                        shape_parts[part_of_shape].position += Vector2.left;
                    }
                }
            }
            Vector2 pivot = shape_parts[0].position;
            for (int part_of_shape = 1; part_of_shape < shape_parts.Count; part_of_shape++)
            {
                Vector2 direction_of_block = pivot - shape_parts[part_of_shape].position;
                Vector2 rotated;
                rotated.x = -direction_of_block.y;
                rotated.y = direction_of_block.x;
                shape_parts[part_of_shape].position = rotated + pivot;
            }
        }
    }
Esempio n. 3
0
 public Shape(Shape_choice specific_shape)
 {
     myorientation = Shape_Orientation.ZERO;
     shape_parts   = Create_choice(specific_shape);
     mycolor       = Shape_coloring(specific_shape);
 }