Ejemplo n.º 1
0
    private void rotateShape(EnumRotation rotation)
    {
        Vector3 newRotation = gameObject.transform.localEulerAngles;

        newRotation.z = -(int)rotation * 90;
        gameObject.transform.localEulerAngles = newRotation;
    }
Ejemplo n.º 2
0
    private void rotateShape()
    {
        /*Destroy(currentShape);
         * currentShape = Instantiate(rotateShapes[currentShapeIndex], gameObject.transform);
         * currentShapeIndex = (currentShapeIndex + 1) % rotateShapes.Length;*/

        currentRotation = validRotations[(((int)currentRotation + 1) % validRotations.Length)];
        rotateShape(currentRotation);
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Converts an EnumRotation to a Rotation.  If the enum is None, null is returned.
 /// </summary>
 public static Rotation fromEnum(EnumRotation rotation)
 {
     if (rotation == EnumRotation.NONE)
     {
         return(null);
     }
     else
     {
         return(Rotation.ALL[(int)rotation]);
     }
 }
Ejemplo n.º 4
0
    private Rotation(int id, string name, Vector2Int dir, EnumAxis axis, EnumRotation enumRot)
    {
        this.id      = id;
        this.name    = name;
        this.vector  = dir;
        this.vectorF = this.vector;
        this.axis    = axis;
        this.enumRot = enumRot;

        this.xDir = dir.x;
        this.yDir = dir.y;
    }
Ejemplo n.º 5
0
    private void OnValidate()
    {
        if (this._displayRotation == EnumRotation.NONE)
        {
            Debug.Log("Display Rotation can not be NONE");
            this._displayRotation = EnumRotation.UP;
        }

        if (!this.isRotationValid(Rotation.fromEnum(this._displayRotation)))
        {
            Rotation r = Rotation.fromEnum(this.displayRotation);
            for (int i = 0; i < 4; i++)
            {
                if (this.isRotationValid(r))
                {
                    Debug.Log(this.displayRotation + " is not a valid rotation");
                    this._displayRotation = r.enumRot;
                    break;
                }

                r = r.clockwise();
            }
        }
    }
Ejemplo n.º 6
0
 private void rotateShape()
 {
     currentRotation = validRotations[(((int)currentRotation + 1) % validRotations.Length)];
     rotateShape(currentRotation);
 }