/// <summary> /// Restituisce la matrice di rotazione rispetto all'orientamento "down". /// </summary> /// <param name="o">Orientamento dato</param> /// <returns></returns> public static Matrix getRotationFromDownOrientation(KulaLevel.Orientation o) { Matrix m = new Matrix(); switch (o) { case (KulaLevel.Orientation.Up): { m.Rotate(180.0f, MatrixOrder.Append); break; } case (KulaLevel.Orientation.Left): { m.Rotate(90.0f, MatrixOrder.Append); break; } case (KulaLevel.Orientation.Right): { m.Rotate(-90.0f, MatrixOrder.Append); break; } default: { break; } } return(m); }
public ChangedTilePropertiesEventArgs(Editor ed) { if (ed == null) { return; } if (ed.Mode == EditorMode.SelectMode) { KulaLevel.MapTile t = ed.PointedTile; if (t != null) { curTileType = t.TileType; curSpecificTileType = TileConverter.FromByteSpecificType(curTileType, t.Type); curMode = ed.Mode; curSurface = ed.ChosenFaceDirection; } } else if (ed.Mode == EditorMode.InsertMode) { KulaLevel.MapTile t = ed.TileToBeAdded; if (t != null) { curTileType = t.TileType; curSpecificTileType = TileConverter.FromByteSpecificType(curTileType, t.Type); curMode = ed.Mode; curSurface = ed.ChosenFaceDirection; } } }
public Exit(int idxX, int idxY, KulaLevel.Orientation o) { surfacesPhysicInit(Constants.BlockWidth, 8, -RotationUtilities.getAngleFromDownOrientation(o)); PointF newCenter = suggestedCenter(idxX, idxY, o); startingX = newCenter.X; startingY = newCenter.Y; currentX = startingX; currentY = startingY; isLandingNeeded = true; }
public Spikes(int idxX, int idxY, KulaLevel.Orientation o, Bitmap img) { surfacesPhysicInit(Constants.BlockWidth * 0.875f, 24, -RotationUtilities.getAngleFromDownOrientation(o)); surfacesDrawInit(img, (int)(Constants.BlockWidth * 0.875f), 24); PointF newCenter = suggestedCenter(idxX, idxY, o); startingX = newCenter.X; startingY = newCenter.Y; currentX = startingX; currentY = startingY; isLandingNeeded = false; isEnabled = true; }
public Ice(int idxX, int idxY, KulaLevel.Orientation o) { type = SurfType.Ice; surfacesPhysicInit(Constants.BlockWidth, 8, -RotationUtilities.getAngleFromDownOrientation(o)); surfColor = Color.FromArgb(200, Color.Azure); PointF newCenter = suggestedCenter(idxX, idxY, o); startingX = newCenter.X; startingY = newCenter.Y; currentX = startingX; currentY = startingY; isLandingNeeded = true; }
protected PointF suggestedCenter(int idxX, int idxY, KulaLevel.Orientation o) { float d = Constants.BlockWidth; PointF off = new PointF(0, -d / 2.0f); Matrix m = new Matrix(); float rot = -RotationUtilities.getAngleFromDownOrientation(o); m.Rotate(rot); off = m.TransformAndThenRound(off); float cX = d / 2.0f + d * idxX; float cY = d / 2.0f + d * idxY; off = new PointF((float)Math.Round(cX + off.X), (float)Math.Round(cY + off.Y)); return(off); }
/// <summary> /// Crea un editor vuoto con righe e colonne uguali. /// Come standard, riempie tutto il controllo che lo contiene. /// </summary> public Editor() { lvlGrid = new SortedDictionary <Pair <byte>, KulaLevel.MapTile>(); isMouseDown = false; isLoaded = false; Mode = EditorMode.InsertMode; TileToBeAdded = null; lvlW = 0; lvlH = 0; cellSize = 20; lineWidth = 2; pointedSurf = KulaLevel.Orientation.Up; this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.BackColor = Color.FromArgb(255, 255, 255, 255); ChangePointer(new Pair <byte>(0, 0)); }
/// <summary> /// Restituisce l'angolo assoluto di rotazione rispetto all'orientamento "down". /// </summary> /// <param name="o">Orientamento dato</param> /// <returns></returns> public static float getAngleFromDownOrientation(KulaLevel.Orientation o) { if (o == KulaLevel.Orientation.Left) { return(-90f); } else if (o == KulaLevel.Orientation.Right) { return(90f); } else if (o == KulaLevel.Orientation.Up) { return(180f); } else { return(0f); } }
/// <summary> /// Restituisce l'orientamento inversa a quella data. /// </summary> /// <param name="o">Orientamento di cui si vuol sapere l'inverso.</param> /// <returns></returns> public static KulaLevel.Orientation Reverse(KulaLevel.Orientation o) { if (o == KulaLevel.Orientation.Up) { return(KulaLevel.Orientation.Down); } else if (o == KulaLevel.Orientation.Down) { return(KulaLevel.Orientation.Up); } else if (o == KulaLevel.Orientation.Left) { return(KulaLevel.Orientation.Right); } else if (o == KulaLevel.Orientation.Right) { return(KulaLevel.Orientation.Left); } else { return(KulaLevel.Orientation.Up); } }
public GravityChanger(int idX, int idY, float persp, Bitmap img, KulaLevel.Orientation o) { initPlaceable(idX, idY, persp, img); rot = RotationUtilities.getAngleFromDownOrientation(o); float angle = (float)Math.Round(rot - perspective) % 360; if (angle < 0f) { while ((angle += 360f) < 0f) { ; } } if (angle % 360 == 0) { toDraw.RotateFlip(RotateFlipType.RotateNoneFlipNone); } else if (angle % 360 == 270) { toDraw.RotateFlip(RotateFlipType.Rotate90FlipNone); } else if (angle % 360 == 180) { toDraw.RotateFlip(RotateFlipType.Rotate180FlipNone); } else if (angle % 360 == 90) { toDraw.RotateFlip(RotateFlipType.Rotate270FlipNone); } else { throw new Exception("What is " + angle + "deg?"); } }