public void OperatorNotEqualsTest() { var coordinates = new Coordinates3(1, 2, 4); var Coordinates3 = new Coordinates3(2, 3, 5); Assert.True(coordinates != Coordinates3); }
public void HashCodeNotEqualsTest() { var coordinates = new Coordinates3(1, 2, 4); var Coordinates3 = new Coordinates3(2, 3, 5); Assert.NotEqual(coordinates.GetHashCode(), Coordinates3.GetHashCode()); }
public void EqualsTest() { var coordinates = new Coordinates3(1, 2, 4); var Coordinates3 = new Coordinates3(1, 2, 4); Assert.True(coordinates.Equals((object)Coordinates3)); }
public void ConstructorTest() { var coordinates = new Coordinates3(4, 2, 8); Assert.Equal(4, coordinates.X); Assert.Equal(2, coordinates.Y); Assert.Equal(new[] { 4d, 2d, 8d }, coordinates); }
public void NotEqualsTest() { var coordinates = new Coordinates3(1, 2, 4); var Coordinates3 = new Coordinates3(2, 3, 5); Assert.False(coordinates.Equals(Coordinates3)); Assert.False(coordinates.Equals(null)); }
public static Coordinates3 ToContinentCoords(this Coordinates3 coords, CoordsUnit fromUnit, Rectangle mapRectangle, Rectangle continentRectangle) { var mapCoords = coords.ToMapCoords(fromUnit); double x = ((mapCoords.X - mapRectangle.TopLeft.X) / mapRectangle.Width * continentRectangle.Width) + continentRectangle.TopLeft.X; double z = ((1 - ((mapCoords.Z - mapRectangle.BottomRight.Y) / mapRectangle.Height)) * continentRectangle.Height) + continentRectangle.TopRight.Y; return(new Coordinates3(x, mapCoords.Y, z)); }
public static Coordinates3 ToUnit(this Coordinates3 coords, CoordsUnit fromUnit, CoordsUnit toUnit) { if (fromUnit == CoordsUnit.Meters && toUnit == CoordsUnit.Inches) { return(new Coordinates3(coords.X / INCH_TO_METER, coords.Y / INCH_TO_METER, coords.Z / INCH_TO_METER)); } else if (fromUnit == CoordsUnit.Inches && toUnit == CoordsUnit.Meters) { return(new Coordinates3(coords.X * INCH_TO_METER, coords.Y * INCH_TO_METER, coords.Z * INCH_TO_METER)); } return(coords); }
public bool IsPointInArea(Coordinates3 testPoint, bool isInCombat) { switch (CombatStatus) { case CombatStatus.InCombat when !isInCombat: case CombatStatus.OutOfCombat when isInCombat: return(false); default: return(Area.IsPointInArea(testPoint)); } }
private bool IsPointInCircle(Coordinates3 testPoint) { var dx = Math.Abs(testPoint.X - Center.X); if (dx > Radius) { return(false); } var dy = Math.Abs(testPoint.Z - Center.Y); if (dy > Radius) { return(false); } if (dx + dy <= Radius) { return(true); } return(dx * dx + dy * dy <= Radius * Radius); }
public bool IsPointInArea(Coordinates3 testPoint) { if (testPoint.Y < MinimumHeight) { return(false); } //TODO: Use polymorphism instead of doing this switch (AreaType) { case AreaType.Polygon: return(IsPointInPolygon(testPoint)); case AreaType.Circle: return(IsPointInCircle(testPoint)); default: throw new Exception($"Unsupported AreaType {AreaType}"); } }
// https://stackoverflow.com/a/14998816/3210008 private bool IsPointInPolygon(Coordinates3 testPoint) { var result = false; var j = Polygon.Length - 1; for (var i = 0; i < Polygon.Length; i++) { if (Polygon[i].Y < testPoint.Z && Polygon[j].Y >= testPoint.Z || Polygon[j].Y < testPoint.Z && Polygon[i].Y >= testPoint.Z) { if (Polygon[i].X + (testPoint.Z - Polygon[i].Y) / (Polygon[j].Y - Polygon[i].Y) * (Polygon[j].X - Polygon[i].X) < testPoint.X) { result = !result; } } j = i; } return(result); }
public void ToStringTest() { var coordinates = new Coordinates3(5, 10, 20); Assert.Equal("(5,10,20)", coordinates.ToString()); }
/// <summary> /// Converts Gw2Sharp's left-handed <see cref="Coordinates3"/> to XNA's right-handed <see cref="Vector3"/>. /// </summary> public static Vector3 ToXnaVector3(this Coordinates3 vector) { return(new Vector3((float)vector.X, (float)vector.Z, (float)vector.Y)); }
public static Coordinates3 ToMapCoords(this Coordinates3 coords, CoordsUnit fromUnit) { coords = coords.ToUnit(fromUnit, CoordsUnit.GameWorld); return(new Coordinates3(coords.X, coords.Y, coords.Z)); }
private void StartTimerIfNeeded(Coordinates3 lastPosition, bool wasPlayingTransition) { _client.Mumble.Update(); var newPosition = AvatarPosition; switch (_startCondition) { case StartCondition.Moving: // character moves (and was not transitioning, which would be a move too) if (!wasPlayingTransition && (newPosition.X != lastPosition.X || newPosition.Z != lastPosition.Z)) { _lastCheckpoint.Clear(); _timer.Start(); if (_loadingScreen == LoadingScreen.Only) { _timer.Pause(); // immediately pause until loading screen starts _wasAutoPaused = true; } } break; case StartCondition.Loading: // loading screen is visible if (IsLoading(true)) { _lastCheckpoint.Clear(); _timer.Start(); if (_loadingScreen == LoadingScreen.Exclude) { _timer.Pause(); // immediately pause until loading screen ends _wasAutoPaused = true; } } break; case StartCondition.NotLoading: // anything where the black bar is not visible if (!IsLoading(true)) { _lastCheckpoint.Clear(); _timer.Start(); if (_loadingScreen == LoadingScreen.Only) { _timer.Pause(); // immediately pause until next loading screen starts _wasAutoPaused = true; } } break; case StartCondition.NotTransitioning: // no loading screen or character select if (!IsTransitioning()) { _lastCheckpoint.Clear(); _timer.Start(); if (_loadingScreen == LoadingScreen.Only) { _timer.Pause(); // immediately pause until next loading screen starts _wasAutoPaused = true; } } break; } }