using System; using System.Collections.Generic; using System.Text; namespace DW.Data.World { /// /// Class describes a set of Tile Coordinates X, Y /// public class TileCoordinates : IComparable { // X coordinate private int x; // Y coordinate private int y; /// /// Gets the X coordinate. /// public int X { get { return x; } set { x = value; } } /// /// Gets the Y coordinate /// public int Y { get { return y; } set { y = value; } } /// /// Constructor. /// public TileCoordinates() { x = 0; y = 0; } /// /// Constructor /// /// X coordinate. /// Y coordinate. public TileCoordinates(int x, int y) { this.x = x; this.y = y; } /// /// Constructor /// /// X coordinate. /// Y coordinate. public TileCoordinates(float x, float y) { this.x = (int)x; this.y = (int)y; } public override bool Equals(object obj) { if (obj == null || !(obj is TileCoordinates)) { return false; } TileCoordinates tc = (TileCoordinates)obj; return this.X == tc.X && this.Y == tc.Y; } public override int GetHashCode() { return this.X * this.Y; } #region IComparable Members public int CompareTo(object obj) { if (!(obj is TileCoordinates)) { return -1; } TileCoordinates tc = (TileCoordinates) obj; if (this.Equals(obj)) { return 0; } else if (this.X <= tc.X && this.Y <= tc.Y) { return -1; } else { return 1; } } #endregion } }