public static bool TryParse(string value, out Coords coords, bool isBase36) { string[] mainTokens = value.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); uint sectorIndexX = 0; uint sectorIndexY = 0; int sX = 0, sY = 0, sZ = 0; coords = new Coords(0, 0, 0, 0, 0); if (mainTokens.Length == 0) { return(false); } string[] sectorTokens = mainTokens[0].Split('.'); if (sectorTokens.Length != 2) { return(false); } else { if (isBase36) { sectorIndexX = (uint)Base36.Decode(sectorTokens[0]); } else if (!uint.TryParse(sectorTokens[0], out sectorIndexX)) { return(false); } if (isBase36) { sectorIndexY = (uint)Base36.Decode(sectorTokens[1]); } else if (!uint.TryParse(sectorTokens[1], out sectorIndexY)) { return(false); } } if (mainTokens.Length > 1) { string[] systemTokens = mainTokens[1].Split('.'); if (systemTokens.Length >= 3) { if (isBase36) { sX = (int)Base36.Decode(systemTokens[0]); } else if (!int.TryParse(systemTokens[0], out sX)) { return(false); } if (isBase36) { sY = (int)Base36.Decode(systemTokens[1]); } else if (!int.TryParse(systemTokens[1], out sY)) { return(false); } if (isBase36) { sZ = (int)Base36.Decode(systemTokens[2]); } else if (!int.TryParse(systemTokens[2], out sZ)) { return(false); } } } coords = new Coords(sectorIndexX, sectorIndexY, sX, sY, sZ); return(true); }
public double CalculateDistance(Coords coords) { return(this._galacticLocation.CalculateDistance(coords._galacticLocation)); }
public bool IsInRange(Coords coords, double range) { return(this._galacticLocation.CalculateDistance(coords._galacticLocation) <= range); }
private void BuildCoords() { Coords = new Coords(Sector.IndexX, Sector.IndexY, this._x, this._y, this._z); }