public void BeforeAnyTesting()
 {
     _landsEnd    = new WorldCoordinates(50.066388888888889d, -5.7147222222222222d, 0, 6371000);
     _JohnoGroats = new WorldCoordinates(58.643888888888889d, -3.07, 0, 6371000);
     _KscFlagpole = new WorldCoordinates(-0.094169025159008, -74.6535078892799, 64.3840068761492, 600000);
     _VAB         = new WorldCoordinates(-0.0967767169198357, -74.6194886953435, 67.5464817753527, 600000);
 }
示例#2
0
        public void TestAdd()
        {
            var coords = new WorldCoordinates(new CubeCoordinates(0, 5, 3), new Vector3(0, 0, 0.5f));
            var res    = new WorldCoordinates(new CubeCoordinates(0, 4, 4), new Vector3(0.3f, 0.8f, 0.6f));

            Assert.AreEqual(res, coords + new Vector3(0.3f, -0.2f, 1.1f));
        }
        public ReadResults ParseIntegerFlat(out ICoordinates result)
        {
            result = default;
            WorldCoordinateParser worldCoordinateParser = new WorldCoordinateParser(StringReader, UseBedrock);

            ReadResults readResults = worldCoordinateParser.ReadInteger(out WorldCoordinate x);

            if (!readResults.Successful)
            {
                return(readResults);
            }
            if (UseBedrock)
            {
                StringReader.SkipWhitespace();
            }
            else
            {
                if (!StringReader.AtEndOfArgument())
                {
                    StringReader.SetCursor(Start);
                    return(ReadResults.Failure(CommandError.Vec2CoordinatesIncomplete().WithContext(StringReader)));
                }
                StringReader.Skip();
            }

            readResults = worldCoordinateParser.ReadInteger(out WorldCoordinate z);
            if (readResults.Successful)
            {
                result = new WorldCoordinates(x, new WorldCoordinate(0.0d, true), z);
            }
            return(readResults);
        }
示例#4
0
    public Stack <Pair <int, int> > GetPath(WorldCoordinates currentPosition, WorldCoordinates destination)
    {
        startPosition.SetCoordinates(currentPosition);
        endPosition.SetCoordinates(destination);


        return(PerformPathFinding());
    }
示例#5
0
        private PixelCoordinates GetMarkerPixelCoordinates(Coordinates coordinates, int zoomLevel)
        {
            var worldCoords = new WorldCoordinates(coordinates);

            var deltaFromCentre = worldCoords - WorldCentre;

            var pixelDeltaFromCentre = new PixelCoordinates(deltaFromCentre, zoomLevel);

            return(GetPixelCentre(zoomLevel) + pixelDeltaFromCentre);
        }
示例#6
0
    public PathFindingUnitLogic()
    {
        pathFinding = new PathFinding();

        destinationCoordinates = new WorldCoordinates();
        currentCoordinates     = new WorldCoordinates();
        nextCoordinates        = new WorldCoordinates();

        currentTrueCoordinates     = new TrueCoordinates();
        destinationTrueCoordinates = new TrueCoordinates();
        nextTrueCoordinates        = new TrueCoordinates();
    }
示例#7
0
    public bool Equals(WorldCoordinates c)
    {
        if ((object)c == null)
        {
            return(false);
        }
        if (!Mathf.Approximately(X, c.X) || Mathf.Approximately(Y, c.Y))
        {
            return(false);
        }

        return(true);
    }
示例#8
0
    public bool Equals(WorldCoordinates c)
    {
        if ((object)c == null)
        {
            return(false);
        }
        if (X != c.X || Y != c.Y)
        {
            return(false);
        }

        return(true);
    }
示例#9
0
            /// <summary>
            /// Compares another object for equality to this WorldCoordinates. If the object is a non-null WorldCoordinates where all fields share the same values, returns true;
            /// else return false.
            /// </summary>
            /// <param name="obj">An object to compare to this WorldCoordinates</param>
            /// <returns>A boolean indictating equality.</returns>
            public override bool Equals(object obj)
            {
                if (obj == null)
                {
                    return(false);
                }

                if (obj is WorldCoordinates)
                {
                    WorldCoordinates test = (WorldCoordinates)obj;

                    if (X == test.X && Y == test.Y)
                    {
                        return(true);
                    }
                }
                return(false);
            }
示例#10
0
    public override bool Equals(System.Object obj)
    {
        if (obj == null)
        {
            return(false);
        }
        WorldCoordinates c = obj as WorldCoordinates;

        if ((System.Object)c == null)
        {
            return(false);
        }

        if (!Mathf.Approximately(X, c.X) || !Mathf.Approximately(Y, c.Y))
        {
            return(false);
        }

        return(true);
    }
示例#11
0
    public override bool Equals(System.Object obj)
    {
        if (obj == null)
        {
            return(false);
        }
        WorldCoordinates c = obj as WorldCoordinates;

        if ((System.Object)c == null)
        {
            return(false);
        }

        if (X != c.X || Y != c.Y)
        {
            return(false);
        }

        return(true);
    }
示例#12
0
        private void textBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            var latitude  = Regex.Match(textBox.Text, @"(?<=Latitude\s=\s)[-\.\d]+").Value;
            var longitude = Regex.Match(textBox.Text, @"(?<=Longitude\s=\s)[-\.\d]+").Value;
            var altitude  = Regex.Match(textBox.Text, @"(?<=Altitude\s=\s)[-\.\d]+").Value;

            if ((latitude != string.Empty) && (longitude != string.Empty) && (altitude != string.Empty))
            {
                var coordinates =
                    new WorldCoordinates(
                        double.Parse(latitude),
                        double.Parse(longitude),
                        double.Parse(altitude),
                        600000);
                var gc     = new GreatCircle(_flagPole, coordinates);
                var output = $"        ForwardAzimuth = {gc.ForwardAzimuth}\n        Distance = {gc.DistanceAtOrigAlt} \n        DeltaAltitude = {gc.DeltaASL}";
                Clipboard.SetText(output);
                outputBlock1.Text = $"copied to clipboard:\n{output}";
            }
            else
            {
                outputBlock1.Text = "Could not extract Latitude, Longitude, and Altitude";
            }
        }
示例#13
0
            public ChunkCoordinates(WorldCoordinates world)
            {
                if (world.X >= 0)
                {
                    x = Mathf.FloorToInt(world.X / chunkTileWidth);
                    i = (int)(world.X - x * chunkTileWidth);
                }
                else
                {
                    x = Mathf.CeilToInt((world.X + 1) / chunkTileWidth) - 1;
                    i = (int)((chunkTileWidth - 1) + (world.X + 1) - (x + 1) * chunkTileWidth);
                }

                if (world.Y >= 0)
                {
                    y = Mathf.FloorToInt(world.Y / chunkTileWidth);
                    j = (int)(world.Y - y * chunkTileWidth);
                }
                else
                {
                    y = Mathf.CeilToInt((world.Y + 1) / chunkTileWidth) - 1;
                    j = (int)((chunkTileWidth - 1) + (world.Y + 1) - (y + 1) * chunkTileWidth);
                }
            }
示例#14
0
    internal void MoveUnit(GameObject unit, int x, int y, float movementSpeed)
    {
        GetPath(x, y);
        Debug.Log("Destination is " + x + " " + y);
        WorldCoordinates tempCoordinates = new WorldCoordinates();
        Pair <int, int>  point;

        isMoving = true;

        point = path.Pop();
        nextTrueCoordinates.X        = point.First;
        nextTrueCoordinates.Y        = point.Second;
        nextCoordinates.X            = point.First;
        nextCoordinates.Y            = point.Second;
        destinationTrueCoordinates.X = x;
        destinationTrueCoordinates.Y = y;
        return;

        while (!destinationCoordinates.Equals(currentCoordinates) && path.Count > 0)
        {
            point             = path.Pop();
            tempCoordinates.X = point.First;
            tempCoordinates.Y = point.Second;

            Vector2 current = new Vector2(currentCoordinates.X, currentCoordinates.Y);
            Vector2 next    = new Vector2(tempCoordinates.X, tempCoordinates.Y);

            var heading   = next - current;
            var distance  = heading.magnitude;
            var direction = heading / distance;
            int xx        = 0;

            while (current != next)
            {
                if (xx == 1000)
                {
                    break;
                }
                ++xx;
                Debug.Log("current is " + current.x + " " + current.y);
                current += direction * Time.deltaTime * movementSpeed;
                unit.transform.position = new Vector2(current.x, current.y);
            }

            /*
             * while (!(tempCoordinates.Equals(currentCoordinates)))
             * {
             *      if (tempCoordinates.X < currentCoordinates.X)
             *          currentCoordinates.X -= 1;
             *      else if (tempCoordinates.X > currentCoordinates.X)
             *          currentCoordinates.X += 1;
             *
             *      if (tempCoordinates.Y < currentCoordinates.Y)
             *          currentCoordinates.Y -= 1;
             *      else if (tempCoordinates.Y > currentCoordinates.Y)
             *          currentCoordinates.Y += 1;
             *
             * }
             */
        }
    }
示例#15
0
 internal void SetCoordinates(WorldCoordinates NewCoordinates)
 {
     X = NewCoordinates.X;
     Y = NewCoordinates.Y;
 }
示例#16
0
 public MainWindow()
 {
     InitializeComponent();
     _flagPole = new WorldCoordinates(-0.094169025159008, -74.6535078892799, 64.3840068761492, 600000);
 }
示例#17
0
 public PathFinding()
 {
     startPosition = new WorldCoordinates();
     endPosition   = new WorldCoordinates();
 }
示例#18
0
 /// <summary>
 /// Initialize this location to a chunk location
 /// </summary>
 /// <param name="chunkCoordinates">chunk location as Location.Chunk_Location struct</param>
 /// <returns>The initialized object.</returns>
 public Coordinates(ChunkCoordinates chunkCoordinates)
 {
     chunk = chunkCoordinates;
     world = new WorldCoordinates(chunk);
 }
示例#19
0
 /// <summary>
 /// Initialize this location to a world location
 /// </summary>
 /// <param name="worldCoordinates">world location as Location.World_Location struct</param>
 /// <returns>The initialized object.</returns>
 public Coordinates(WorldCoordinates worldCoordinates)
 {
     world = worldCoordinates;
     chunk = new ChunkCoordinates(world);
 }
示例#20
0
 /// <summary>
 /// Initialize this location to a world location
 /// </summary>
 /// <param name="x">horizontal position of world location as an integer</param>
 /// <param name="y">vertical position of world location as an integer</param>
 /// <returns>The initialized object.</returns>
 ///
 public Coordinates(long x, long y)
 {
     world = new WorldCoordinates(x, y);
     chunk = new ChunkCoordinates(world);
 }
示例#21
0
 public override void Context()
 {
     PreviousCoordinates = TheWorld.GetCoordinatesOf(TheWarrior, TheRoom);
     PreviousCoordinates.ShouldEqual(new WorldCoordinates(2, 2));
 }
示例#22
0
 /// <summary>
 /// Initialize this location to a chunk location
 /// </summary>
 /// <param name="x">horizontal position of the chunk in the world</param>
 /// <param name="y">vertical position of the chunk in the world</param>
 /// <param name="i">horizontal position of the location with in the chunk</param>
 /// <param name="j">vertical position of the location with in the chunk</param>
 /// <returns>The initialized object.</returns>
 public Coordinates(long x, long y, int i, int j)
 {
     chunk = new ChunkCoordinates(x, y, i, j);
     world = new WorldCoordinates(chunk);
 }
示例#23
0
 public override void Context()
 {
     TheWorld.MoveForward(TheWarrior, TheRoom);
     PreviousCoordinates = TheWorld.GetCoordinatesOf(TheWarrior, TheRoom);
 }
示例#24
0
 public Coordinates(Chunk chunk, IntegerPair tileIndices)
 {
     world      = new WorldCoordinates(chunk.lowerLeft.InChunks.X * Chunk.chunkTileWidth + tileIndices.I, chunk.lowerLeft.InChunks.Y * Chunk.chunkTileWidth + tileIndices.J);
     this.chunk = new ChunkCoordinates(world);
 }
 public void BeforeAnyTesting()
 {
     _landsEnd    = new WorldCoordinates(50.066388888888889d, -5.7147222222222222d, 0, 6371000);
     _JohnoGroats = new WorldCoordinates(58.643888888888889d, -3.07, 0, 6371000);
 }