protected Coords(CoordsType coordsType, IntVector2D vector) { switch (coordsType) { default: case CoordsType.Canon: _vectorCanon = vector; isUserNull = isCustomNull = true; break; case CoordsType.User: _vectorUser = vector; isCustomNull = isCanonNull = true; break; case CoordsType.Custom: _vectorCustom = vector; isCanonNull = isUserNull = true; break; } }
public Coords(CoordsType newType, Vector v) { this._type = newType; if (newType == CoordsType.Tile) { _X = (Int32)(v.X / Constants.TileSize); _Y = (Int32)(v.Y / Constants.TileSize); return; } _X = (Int32)Math.Floor(v.X); _Y = (Int32)Math.Floor(v.Y); }
/* * // Returns the transform that centers the form on the player * private PointF TransformCenterAtPlayer() * { * PointF topDownPoint = new PointF(_player.PositionPixel.X * this._zoom, this._player.PositionPixel.Y * this._zoom); * return new PointF(0.5f * this.Width - topDownPoint.X, 0.5f * this.Height - topDownPoint.Y); * } */ // Returns the coords of the clicked tile assuming the center of the screen is the // player's position private Coords TransformInverseScreenpointToCoords(Int32 x, Int32 y, CoordsType type) { // maybe should store the translation instead of recalcualting it float xf = (x - _screenAnchor.X) / this._zoom; float yf = (y - _screenAnchor.Y) / this._zoom; Int32 xcoord = (Int32)(Math.Floor(xf)); Int32 ycoord = (Int32)(Math.Floor(yf)); if (type == CoordsType.Tile) { return(new Coords(type, xcoord / Constants.TileSize, ycoord / Constants.TileSize)); } return(new Coords(type, xcoord, ycoord)); }
public Coords(CoordsType newType, Coords c) { this._type = newType; if (newType == CoordsType.Tile && c._type == CoordsType.Pixel) { _X = c.X / Constants.TileSize; _Y = c.Y / Constants.TileSize; return; } else if (newType == CoordsType.Pixel && c._type == CoordsType.Tile) { _X = c.X + (Int32)(0.5 * Constants.TileSize); _Y = c.Y + (Int32)(0.5 * Constants.TileSize); return; } _X = c.X; _Y = c.Y; }
public Coords(CoordsType myType, Int32 Xval, Int32 Yval) { this._type = myType; this._X = Xval; this._Y = Yval; }
HexCoords(CoordsType coordsType, int x, int y) : base(coordsType, new IntVector2D(x, y)) { }
HexCoords(CoordsType coordsType, IntVector2D vector) : base(coordsType, vector) { }
/* // Returns the transform that centers the form on the player private PointF TransformCenterAtPlayer() { PointF topDownPoint = new PointF(_player.PositionPixel.X * this._zoom, this._player.PositionPixel.Y * this._zoom); return new PointF(0.5f * this.Width - topDownPoint.X, 0.5f * this.Height - topDownPoint.Y); } */ // Returns the coords of the clicked tile assuming the center of the screen is the // player's position private Coords TransformInverseScreenpointToCoords(Int32 x, Int32 y, CoordsType type) { // maybe should store the translation instead of recalcualting it float xf = (x - _screenAnchor.X) / this._zoom; float yf = (y - _screenAnchor.Y) / this._zoom; Int32 xcoord = (Int32)(Math.Floor(xf)); Int32 ycoord = (Int32)(Math.Floor(yf)); if (type == CoordsType.Tile) { return new Coords(type, xcoord / Constants.TileSize, ycoord / Constants.TileSize); } return new Coords(type, xcoord, ycoord); }