Ejemplo n.º 1
0
        public void OperatorNotEqualsTest()
        {
            var coordinates  = new Coordinates3(1, 2, 4);
            var Coordinates3 = new Coordinates3(2, 3, 5);

            Assert.True(coordinates != Coordinates3);
        }
Ejemplo n.º 2
0
        public void HashCodeNotEqualsTest()
        {
            var coordinates  = new Coordinates3(1, 2, 4);
            var Coordinates3 = new Coordinates3(2, 3, 5);

            Assert.NotEqual(coordinates.GetHashCode(), Coordinates3.GetHashCode());
        }
Ejemplo n.º 3
0
        public void EqualsTest()
        {
            var coordinates  = new Coordinates3(1, 2, 4);
            var Coordinates3 = new Coordinates3(1, 2, 4);

            Assert.True(coordinates.Equals((object)Coordinates3));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
        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));
            }
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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}");
            }
        }
Ejemplo n.º 11
0
        // 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);
        }
Ejemplo n.º 12
0
        public void ToStringTest()
        {
            var coordinates = new Coordinates3(5, 10, 20);

            Assert.Equal("(5,10,20)", coordinates.ToString());
        }
Ejemplo n.º 13
0
 /// <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));
 }
Ejemplo n.º 14
0
 public static Coordinates3 ToMapCoords(this Coordinates3 coords, CoordsUnit fromUnit)
 {
     coords = coords.ToUnit(fromUnit, CoordsUnit.GameWorld);
     return(new Coordinates3(coords.X, coords.Y, coords.Z));
 }
Ejemplo n.º 15
0
        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;
            }
        }