public int LocatorPosition(float currentPosition, int trackLength) { if (MapBoxEnd.Equals(0)) { throw new Exception("Initialize has not been launched"); } var x = currentPosition <Start ?MapBoxStart : currentPosition> End ? MapBoxEnd : ((1 / TerrainGenerator.TerrainStepLength) * (currentPosition * MapBoxEnd) / trackLength * _ratioX) + MapBoxStart; return((int)x); }
public Vector2 TerrainPoint(Vector2 currentPosition, int trackLength) { if (MapBoxEnd.Equals(0)) { throw new Exception("Initialize has not been launched"); } var x = currentPosition.X <Start ?MapBoxStart : currentPosition.X> End ? MapBoxEnd : ((1 / TerrainGenerator.TerrainStepLength) * (currentPosition.X * MapBoxEnd) / trackLength * _ratioX) + MapBoxStart; var y = currentPosition.Y < 0 ? MapBoxStart : (currentPosition.Y / MapBoxYEnd * _ratioY) + MapBoxYStart; return(new Vector2(x, y)); }