/// <summary> /// Creates an instance of GameObject /// </summary> /// <param name="startUpPosition">The initial position for the object</param> /// <param name="startUpRotation">The initial rotation of the object</param> /// <param name="shape">The shape of the object</param> protected GameObject(Vector3 startUpPosition, float startUpRotation, CompactRectangle shape) { drawCoordinates = new FaceCoordinates(startUpPosition, shape.Width, shape.Height); Position3 = startUpPosition; RotationAngle = startUpRotation; this.shape = shape; this.spriteID = 0; verticesCollection = new List <VertexPositionNormalTexture>(); indicesCollection = new List <int>(); }
private static int DetectPalette(LockBitmap palettes, LockBitmap lockBmp, CompactRectangle rect) { var max = 0; var value = -1; var dict = new Dictionary <int, List <Color> >(); for (var i = 0; i < palettes.Width; i++) { dict.Add(i, new List <Color>()); for (var x = rect.X; x < rect.X + rect.Width; x++) { for (var y = rect.Y; y < rect.Y + rect.Height; y++) { var orgColor = lockBmp.GetPixel(x, y); for (var c = 0; c < 256; c++) { if (orgColor != palettes.GetPixel(i, c)) { continue; } if (!dict[i].Contains(orgColor)) { dict[i].Add(orgColor); } if (dict[i].Count <= max) { continue; } value = i; max = dict[i].Count; } } } } return(value); }
/// <summary> /// Creates a instance of ControlableGameObject /// </summary> /// <param name="startUpPosition">The initial position for the object</param> /// <param name="startUpRotation">The initial rotation of the object</param> protected ControlableGameObject(Vector3 startUpPosition, float startUpRotation, CompactRectangle shape) : base(startUpPosition, startUpRotation, shape) { }
public DeltaSubItem(DeltaType type, int width, int height) { Type = type; Rectangle = new CompactRectangle(0, 0, width, height); }
/// <summary> /// Gets the coordinates for the texture acording to its rotation and flip. /// </summary> /// <remarks>The return values are stored 0->BottonLeft; 1->BottonRight; 2->TopRight; 3->TopLeft</remarks> /// <param name="tileID">The ID of the texture.</param> /// <param name="rotation">The rotation to aply to the texture.</param> /// <param name="flip">If the Texture must be fliped.</param> /// <returns>A array with 4 positions where each position represent one of the vertices od the texture, it will be a square with 64px.</returns> public Vector2[] GetNormalTexture(UInt32 tileID, RotationType rotation, Boolean flip) { var texturePosition = new Vector2[4]; CompactRectangle tex = tileAtlas[(int)tileID]; var texTopLeft = new Vector2((tex.X + 1) * pixelPerWidth, (tex.Y + 1) * pixelPerHeight); var texTopRight = new Vector2((tex.X + tex.Width - 1) * pixelPerWidth, (tex.Y + 1) * pixelPerHeight); var texBottomLeft = new Vector2((tex.X + 1) * pixelPerWidth, (tex.Y + tex.Height - 1) * pixelPerHeight); var texBottomRight = new Vector2((tex.X + tex.Width - 1) * pixelPerWidth, (tex.Y + tex.Height - 1) * pixelPerHeight); if (flip) { Vector2 helper = texTopLeft; texTopLeft = texTopRight; texTopRight = helper; helper = texBottomLeft; texBottomLeft = texBottomRight; texBottomRight = helper; if (rotation == RotationType.Rotate90) //special cases. { rotation = RotationType.Rotate270; } else if (rotation == RotationType.Rotate270) { rotation = RotationType.Rotate90; } } switch (rotation) { case RotationType.RotateNone: texturePosition[0] = texBottomLeft; texturePosition[1] = texBottomRight; texturePosition[2] = texTopRight; texturePosition[3] = texTopLeft; break; case RotationType.Rotate90: texturePosition[3] = texBottomLeft; texturePosition[0] = texBottomRight; texturePosition[1] = texTopRight; texturePosition[2] = texTopLeft; break; case RotationType.Rotate180: texturePosition[2] = texBottomLeft; texturePosition[3] = texBottomRight; texturePosition[0] = texTopRight; texturePosition[1] = texTopLeft; break; case RotationType.Rotate270: texturePosition[1] = texBottomLeft; texturePosition[2] = texBottomRight; texturePosition[3] = texTopRight; texturePosition[0] = texTopLeft; break; } return(texturePosition); }