private void rotateShape(EnumRotation rotation) { Vector3 newRotation = gameObject.transform.localEulerAngles; newRotation.z = -(int)rotation * 90; gameObject.transform.localEulerAngles = newRotation; }
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); }
/// <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]); } }
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; }
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(); } } }
private void rotateShape() { currentRotation = validRotations[(((int)currentRotation + 1) % validRotations.Length)]; rotateShape(currentRotation); }