Ejemplo n.º 1
0
        public static Location GetLocation(string input, int matchedStartIndex, int matchedLength)
        {
            if (matchedLength <= 0)
            {
                return(new Location());
            }
            if (matchedStartIndex < 0)
            {
                matchedStartIndex = 0;
            }
            if (matchedStartIndex + matchedLength > input.Length)
            {
                matchedLength = input.Length - matchedStartIndex;
            }

            var        beforeMatch = input.Substring(0, matchedStartIndex);
            Coordinate start       = Coordinate.GetCoordinate(beforeMatch);

            var        matched    = input.Substring(matchedStartIndex, matchedLength);
            Coordinate startToEnd = Coordinate.GetCoordinate(matched);
            Coordinate end        = start.Add(startToEnd);

            return(new Location {
                StartLocation = start, EndLocation = end
            });
        }
Ejemplo n.º 2
0
        public IEnumerable <Coordinate> EnumerateGridPoints()
        {
            if ((Resolution & 128) == 0 || // The direction increments have to be given
                ScanMode != 0)             // Expect to scan the grid from North to South and West to East, and consecutive in i direction
            {
                throw new NotSupportedException();
            }

            var firstGridPoint = new Coordinate(La1, Lo1);
            var lastGridPoint  = new Coordinate(La2, Lo2);

            var xStep            = Dx;
            var yStep            = -Dy;
            var currentGridPoint = firstGridPoint;

            // Adjacent points in x direction are consecutive
            var latitudeOffset = 0d;

            for (var y = 0; y < Ny; y++)
            {
                var longitudeOffset = 0d;
                for (var x = 0; x < Nx; x++)
                {
                    currentGridPoint = firstGridPoint.Add(latitudeOffset, longitudeOffset);
                    yield return(currentGridPoint);

                    longitudeOffset += xStep;
                }
                latitudeOffset += yStep;
            }

            Debug.Assert(lastGridPoint.Equals(currentGridPoint));
        }
Ejemplo n.º 3
0
        public void AddTest()
        {
            var target = new Coordinate(5, 15);
            var position = new Coordinate(5, 15);
            var expected = new Coordinate(10, 30);

            Coordinate actual = target.Add(position);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 4
0
        public void AddTest()
        {
            var target   = new Coordinate(5, 15);
            var position = new Coordinate(5, 15);
            var expected = new Coordinate(10, 30);

            Coordinate actual = target.Add(position);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 5
0
        public void check_()
        {
            Directions _direction  = Directions.North;
            Coordinate _coordinate = new Coordinate()
            {
                X = 2, Y = 2
            };

            _coordinate = _coordinate.Add(MovementHelper._moveindirection[_direction]);
            Assert.Equal(2, _coordinate.X);
            Assert.Equal(3, _coordinate.Y);
        }
Ejemplo n.º 6
0
    public Coordinate move(Coordinate src, Coordinate direction, int player, bool jumpedOverFriend)
    {
        Coordinate position = src.Add(direction);
        //Debug.Log (direction.ToString());
        int  cell = getCell(position.getLine(), position.getColumn());
        bool flag = jumpedOverFriend;

        if (cell == -1)
        {
            return(null);
        }
        if (cell == 0 || (flag && isEnemy(cell, player)) || isGoal(cell, player))
        {
            return(position);
        }
        if (!flag && cell == player)
        {
            flag = true;
        }

        return(move(direction, position, player, flag));
    }
Ejemplo n.º 7
0
        public override IEnumerable <Coordinate> EnumerateGridPoints()
        {
            var scanningMode = (ScanningMode)ScanMode;
            var resolution   = ResolutionAndComponent;

            if (resolution != (ResolutionAndComponent.JDirectionIncrementGiven | ResolutionAndComponent.IDirectionIncrementGiven) ||
                (scanningMode & ~(ScanningMode.ScanJPositive | ScanningMode.ScanIReverse)) != ScanningMode.Default)
            {
                throw new NotImplementedException();
            }

            var firstGridPoint = new Coordinate(La1, Lo1);
            var lastGridPoint  = new Coordinate(La2, Lo2);

            var xStep            = Dx * (scanningMode.HasFlag(ScanningMode.ScanIReverse) ? -1 : 1);
            var yStep            = Dy * (scanningMode.HasFlag(ScanningMode.ScanJPositive) ? 1 : -1);
            var currentGridPoint = firstGridPoint;

            // Adjacent points in x direction are consecutive
            var latitudeOffset = 0d;

            for (var y = 0; y < Ny; y++)
            {
                var longitudeOffset = 0d;
                for (var x = 0; x < Nx; x++)
                {
                    currentGridPoint = firstGridPoint.Add(latitudeOffset, longitudeOffset);
                    yield return(currentGridPoint);

                    longitudeOffset += xStep;
                }
                latitudeOffset += yStep;
            }

            Debug.Assert(lastGridPoint.Equals(currentGridPoint));
        }
Ejemplo n.º 8
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            if (MemoryLocations.Database.Count == 0)
            {
                return;
            }

            Coordinate origin = new Coordinate((float)((this.ActualWidth / 2)),
                                               (float)((this.ActualHeight / 2)), 0);


            float scale    = ((float)(this.ActualHeight / 2.0f) / 125.0f);
            int   targetID = -1;

            List <int> aggroList = _aggrohelper.GetAggroList();

            Pen dashedPen = new Pen(new SolidColorBrush(Colors.White), 2);

            dashedPen.DashStyle = DashStyles.DashDotDot;

            Pen targetedPen = new Pen(new SolidColorBrush(Colors.Yellow), 1);

            targetedPen.DashStyle = DashStyles.DashDotDot;

            try // Added this because the designer was going crazy without it.
            {
                targetID = MemoryFunctions.GetTarget();
                MemoryFunctions.GetCharacters(_monsters, _fate, _players, ref _user);
                MemoryFunctions.GetNPCs(_npcs);
                MemoryFunctions.GetGathering(_gathering);
            } catch
            {
                return;
            }


            float rotationAmount;

            if (CompassMode)
            {
                rotationAmount = _user.Heading;

                drawingContext.DrawImage(_radarheading,
                                         new Rect(new Point(origin.X - 128, origin.Y - 256),
                                                  new Size(256, 256)));
            }
            else
            {
                rotationAmount = (float)3.14159265;
            }


            if (ShowPlayers)
            {
                foreach (Character player in _players)
                {
                    if (player.Valid == false)
                    {
                        continue;
                    }

                    if (player.Name.ToLower().Contains(Filter) == false)
                    {
                        continue;
                    }

                    if (_user.Valid == false)
                    {
                        return;
                    }

                    if (_user.IsHidden)
                    {
                        continue;
                    }


                    Coordinate offset           = _user.Coordinate.Subtract(player.Coordinate).Rotate2d(rotationAmount).Scale(scale);
                    Coordinate screenCoordinate = offset.Add(origin);

                    if (player.Address == targetID)
                    {
                        drawingContext.DrawEllipse(Brushes.Transparent, new Pen(new SolidColorBrush(Colors.Cyan), 2),
                                                   new Point(screenCoordinate.X, screenCoordinate.Y), 13, 13);
                    }

                    if (player.Name == _user.Name)
                    {
                        continue;
                    }

                    if (player.TargetID == _user.Address)
                    {
                        drawingContext.DrawLine(targetedPen, new Point(origin.X, origin.Y), new Point(screenCoordinate.X, screenCoordinate.Y));
                    }

                    screenCoordinate = screenCoordinate.Add(-8, -8, 0);

                    if (player.Health_Current == 0)
                    {
                        drawingContext.DrawImage(_skullicon,
                                                 new Rect(new Point(screenCoordinate.X, screenCoordinate.Y),
                                                          new Size(16, 16)));
                    }
                    else
                    {
                        DrawPlayerIcon(drawingContext, player, screenCoordinate);
                    }



                    if (ShowPlayerName)
                    {
                        FormattedText playerLabel = new FormattedText(player.ToString(), System.Globalization.CultureInfo.InvariantCulture, FlowDirection.LeftToRight, new Typeface("Arial"), 8, Brushes.White);

                        drawingContext.DrawText(playerLabel, new Point(screenCoordinate.X - 15, screenCoordinate.Y - 13));
                    }
                }
            }



            if (ShowMonsters)
            {
                foreach (Character monster in _monsters)
                {
                    if (monster.Name.ToLower().Contains(Filter) == false)
                    {
                        continue;
                    }

                    if (monster.IsHidden)
                    {
                        continue;
                    }

                    Coordinate offset;

                    try
                    {
                        offset = _user.Coordinate.Subtract(monster.Coordinate).Rotate2d(rotationAmount).Scale(scale);
                    } catch
                    {
                        return;
                    }

                    Coordinate screenCoordinate = offset.Add(origin);

                    if (monster.Address == targetID)
                    {
                        drawingContext.DrawEllipse(Brushes.Transparent, new Pen(new SolidColorBrush(Colors.Cyan), 2),
                                                   new Point(screenCoordinate.X, screenCoordinate.Y), 12, 12);
                    }

                    // System.Diagnostics.Debug.Print(aggroList.Count.ToString());
                    // Check for aggro!
                    if (aggroList.Contains(monster.ID))
                    {
                        drawingContext.DrawLine(targetedPen, new Point(origin.X, origin.Y),
                                                new Point(screenCoordinate.X, screenCoordinate.Y));

                        drawingContext.DrawEllipse(Brushes.Red, new Pen(new SolidColorBrush(Colors.Red), 2),
                                                   new Point(screenCoordinate.X, screenCoordinate.Y), 8, 8);
                    }

                    screenCoordinate = screenCoordinate.Add(-8, -8, 0);


                    if (monster.Health_Current == 0)
                    {
                        drawingContext.DrawImage(_skullicon,
                                                 new Rect(new Point(screenCoordinate.X, screenCoordinate.Y),
                                                          new Size(16, 16)));
                    }
                    else
                    {
                        drawingContext.DrawImage(monster.IsClaimed?_monsterclaimedicon:_monstericon,
                                                 new Rect(new Point(screenCoordinate.X, screenCoordinate.Y),
                                                          new Size(16, 16)));
                    }

                    if (ShowMonsterName)
                    {
                        FormattedText monsterLabel = new FormattedText(monster.ToString() + " " + monster.UsingAbilityID.ToString("X"),
                                                                       System.Globalization.CultureInfo.InvariantCulture,
                                                                       FlowDirection.LeftToRight, new Typeface("Arial"), 8,
                                                                       Brushes.White);

                        drawingContext.DrawText(monsterLabel, new Point(screenCoordinate.X - 15, screenCoordinate.Y - 13));
                    }
                }
            }

            if (ShowHunts)
            {
                foreach (Character monster in _monsters)
                {
                    if (monster.Name.Contains("Bloody Mary") == false &&
                        monster.Name.Contains("Hellsclaw") == false &&
                        monster.Name.Contains("Garlok") == false &&
                        monster.Name.Contains("Barbastelle") == false &&
                        monster.Name.Contains("Unktehi") == false &&
                        monster.Name.Contains("Croakadile") == false &&
                        monster.Name.Contains("Skogs Fru") == false &&
                        monster.Name.Contains("Vogaal Ja") == false &&
                        monster.Name.Contains("Croque-Mitaine") == false &&
                        monster.Name.Contains("Vuokho") == false &&
                        monster.Name.Contains("Cornu") == false &&
                        monster.Name.Contains("Mahisha") == false &&
                        monster.Name.Contains("Myradrosh") == false &&
                        monster.Name.Contains("Marberry") == false &&
                        monster.Name.Contains("Nandi") == false &&
                        monster.Name.Contains("Dark Helmet") == false &&
                        monster.Name.Contains("Nahn") == false &&
                        monster.Name.Contains("Bonnacon") == false &&
                        monster.Name.Contains("White Joker") == false &&
                        monster.Name.Contains("Forneus") == false &&
                        monster.Name.Contains("Laideronnette") == false &&
                        monster.Name.Contains("Stinging Sophie") == false &&
                        monster.Name.Contains("Melt") == false &&
                        monster.Name.Contains("Wulgaru") == false &&
                        monster.Name.Contains("Phecda") == false &&
                        monster.Name.Contains("Girtab") == false &&
                        monster.Name.Contains("Thousand-cast Theda") == false &&
                        monster.Name.Contains("Ghede Ti Malice") == false &&
                        monster.Name.Contains("Mindflayer") == false &&
                        monster.Name.Contains("Naul") == false &&
                        monster.Name.Contains("Marraco") == false &&
                        monster.Name.Contains("Safat") == false &&
                        monster.Name.Contains("Ovjang") == false &&
                        monster.Name.Contains("Sabotender Bailarina") == false &&
                        monster.Name.Contains("Brontes") == false &&
                        monster.Name.Contains("Gatling") == false &&
                        monster.Name.Contains("Maahes") == false &&
                        monster.Name.Contains("Lampalagua") == false &&
                        monster.Name.Contains("Flame Sergeant Dalvag") == false &&
                        monster.Name.Contains("Dalvag's Final Flame") == false &&
                        monster.Name.Contains("Minhocao") == false &&
                        monster.Name.Contains("Albin the Ashen") == false &&
                        monster.Name.Contains("Zanig'oh") == false &&
                        monster.Name.Contains("Nunyunuwi") == false &&
                        monster.Name.Contains("Sewer Syrup") == false &&
                        monster.Name.Contains("Alectyron") == false &&
                        monster.Name.Contains("Zona Seeker") == false &&
                        monster.Name.Contains("Leech King") == false &&
                        monster.Name.Contains("Kurrea") == false &&
                        monster.Name.Contains("Agrippa") == false)
                    {
                        continue;
                    }


                    if (monster.IsHidden)
                    {
                        continue;
                    }

                    Coordinate offset;

                    try
                    {
                        offset = _user.Coordinate.Subtract(monster.Coordinate).Rotate2d(rotationAmount).Scale(scale);
                    }
                    catch
                    {
                        return;
                    }

                    Coordinate screenCoordinate = offset.Add(origin);

                    if (monster.Address == targetID)
                    {
                        drawingContext.DrawEllipse(Brushes.Transparent, new Pen(new SolidColorBrush(Colors.Cyan), 2),
                                                   new Point(screenCoordinate.X, screenCoordinate.Y), 12, 12);
                    }

                    // System.Diagnostics.Debug.Print(aggroList.Count.ToString());
                    // Check for aggro!
                    if (aggroList.Contains(monster.ID))
                    {
                        drawingContext.DrawLine(targetedPen, new Point(origin.X, origin.Y),
                                                new Point(screenCoordinate.X, screenCoordinate.Y));

                        drawingContext.DrawEllipse(Brushes.Red, new Pen(new SolidColorBrush(Colors.Red), 2),
                                                   new Point(screenCoordinate.X, screenCoordinate.Y), 8, 8);
                    }

                    screenCoordinate = screenCoordinate.Add(-8, -8, 0);


                    if (monster.Health_Current == 0)
                    {
                        drawingContext.DrawImage(_skullicon,
                                                 new Rect(new Point(screenCoordinate.X, screenCoordinate.Y),
                                                          new Size(16, 16)));
                    }
                    else
                    {
                        drawingContext.DrawImage(monster.IsClaimed ? _monsterclaimedicon : _monstericon,
                                                 new Rect(new Point(screenCoordinate.X, screenCoordinate.Y),
                                                          new Size(16, 16)));
                    }

                    if (ShowHuntsName)
                    {
                        FormattedText monsterLabel = new FormattedText(monster.ToString() + " " + monster.UsingAbilityID.ToString("X"),
                                                                       System.Globalization.CultureInfo.InvariantCulture,
                                                                       FlowDirection.LeftToRight, new Typeface("Arial"), 8,
                                                                       Brushes.White);

                        drawingContext.DrawText(monsterLabel, new Point(screenCoordinate.X - 15, screenCoordinate.Y - 13));
                    }
                }
            }

            if (ShowFate)
            {
                foreach (Character monster in _fate)
                {
                    if (monster.Name.ToLower().Contains(Filter) == false)
                    {
                        continue;
                    }

                    if (monster.IsHidden)
                    {
                        continue;
                    }

                    Coordinate offset;

                    try
                    {
                        offset = _user.Coordinate.Subtract(monster.Coordinate).Rotate2d(rotationAmount).Scale(scale);
                    }
                    catch
                    {
                        return;
                    }

                    Coordinate screenCoordinate = offset.Add(origin);

                    if (monster.Address == targetID)
                    {
                        drawingContext.DrawEllipse(Brushes.Transparent, new Pen(new SolidColorBrush(Colors.Cyan), 2),
                                                   new Point(screenCoordinate.X, screenCoordinate.Y), 12, 12);
                    }

                    // Check for aggro!
                    if (aggroList.Contains(monster.ID))
                    {
                        drawingContext.DrawLine(targetedPen, new Point(origin.X, origin.Y),
                                                new Point(screenCoordinate.X, screenCoordinate.Y));

                        drawingContext.DrawEllipse(Brushes.BlueViolet, new Pen(new SolidColorBrush(Colors.BlueViolet), 2),
                                                   new Point(screenCoordinate.X, screenCoordinate.Y), 8, 8);
                    }

                    screenCoordinate = screenCoordinate.Add(-8, -8, 0);


                    if (monster.Health_Current == 0)
                    {
                        drawingContext.DrawImage(_skullicon,
                                                 new Rect(new Point(screenCoordinate.X, screenCoordinate.Y),
                                                          new Size(16, 16)));
                    }
                    else
                    {
                        drawingContext.DrawImage(_fateicon,
                                                 new Rect(new Point(screenCoordinate.X, screenCoordinate.Y),
                                                          new Size(16, 16)));
                    }

                    if (ShowMonsterName)
                    {
                        FormattedText monsterLabel = new FormattedText(monster.ToString(),
                                                                       System.Globalization.CultureInfo.InvariantCulture,
                                                                       FlowDirection.LeftToRight, new Typeface("Arial"), 8,
                                                                       Brushes.White);

                        drawingContext.DrawText(monsterLabel, new Point(screenCoordinate.X - 15, screenCoordinate.Y - 13));
                    }
                }
            }

            if (ShowNPCs)
            {
                foreach (Character NPC in _npcs)
                {
                    if (NPC.Name.ToLower().Contains(Filter) == false)
                    {
                        continue;
                    }

                    if (NPC.Type == CharacterType.NPC && ShowNPCs == false)
                    {
                        continue;
                    }

                    if (NPC.IsHidden)
                    {
                        continue;
                    }

                    Coordinate screenCoordinate;

                    try
                    {
                        Coordinate offset = _user.Coordinate.Subtract(NPC.Coordinate).Rotate2d(rotationAmount).Scale(scale);
                        screenCoordinate = offset.Add(origin);
                    }
                    catch (Exception)
                    {
                        return;
                    }


                    if (NPC.Address == targetID)
                    {
                        drawingContext.DrawEllipse(Brushes.Transparent, new Pen(new SolidColorBrush(Colors.Cyan), 2),
                                                   new Point(screenCoordinate.X, screenCoordinate.Y), 13, 13);
                    }

                    screenCoordinate = screenCoordinate.Add(-8, -8, 0);


                    drawingContext.DrawImage(_npcicon,
                                             new Rect(new Point(screenCoordinate.X, screenCoordinate.Y),
                                                      new Size(16, 16)));

                    if (ShowNPCName)
                    {
                        FormattedText npcLabel = new FormattedText(NPC.Name,
                                                                   System.Globalization.CultureInfo.InvariantCulture,
                                                                   FlowDirection.LeftToRight, new Typeface("Arial"),
                                                                   8,
                                                                   Brushes.Wheat);

                        drawingContext.DrawText(npcLabel,
                                                new Point(screenCoordinate.X - 15, screenCoordinate.Y - 13));
                    }
                }
            }



            if (ShowGathering)
            {
                foreach (Gathering gather in _gathering)
                {
                    if (gather.Name.ToLower().Contains(Filter) == false)
                    {
                        continue;
                    }

                    if (gather.IsHidden && ShowHidden == false)
                    {
                        continue;
                    }


                    gather.IsHidden = false;

                    Coordinate screenCoordinate;

                    try
                    {
                        Coordinate offset = _user.Coordinate.Subtract(gather.Coordinate).Rotate2d(rotationAmount).Scale(scale);
                        screenCoordinate = offset.Add(origin);
                    }
                    catch (Exception)
                    {
                        return;
                    }


                    if (gather.Address == targetID)
                    {
                        drawingContext.DrawEllipse(Brushes.Transparent, new Pen(new SolidColorBrush(Colors.Cyan), 2),
                                                   new Point(screenCoordinate.X, screenCoordinate.Y), 13, 13);
                    }

                    screenCoordinate = screenCoordinate.Add(-8, -8, 0);


                    drawingContext.DrawImage(_woodicon,
                                             new Rect(new Point(screenCoordinate.X, screenCoordinate.Y),
                                                      new Size(16, 16)));

                    if (ShowGatheringName)
                    {
                        FormattedText npcLabel = new FormattedText(gather.Name,
                                                                   System.Globalization.CultureInfo.InvariantCulture,
                                                                   FlowDirection.LeftToRight, new Typeface("Arial"),
                                                                   8,
                                                                   Brushes.DarkOrange);

                        drawingContext.DrawText(npcLabel,
                                                new Point(screenCoordinate.X - 15, screenCoordinate.Y - 13));
                    }
                }
            }

            drawingContext.DrawEllipse(Brushes.Green, new Pen(new SolidColorBrush(Colors.Green), 1),
                                       new Point(origin.X, origin.Y), 4, 4);

            if (!CompassMode)
            {
                Coordinate heading = new Coordinate(0, 8, 0);
                heading = heading.Rotate2d(-_user.Heading);
                heading = heading.Add(origin);

                drawingContext.DrawLine(new Pen(new SolidColorBrush(Colors.Green), 5),
                                        new Point(origin.X, origin.Y),
                                        new Point(heading.X, heading.Y));
            }
        }
Ejemplo n.º 9
0
    public Coordinate move(Coordinate src, Coordinate direction, int player, bool jumpedOverFriend)
    {
        Coordinate position = src.Add(direction);
        //Debug.Log (direction.ToString());
        int cell = getCell(position.getLine(), position.getColumn());
        bool flag = jumpedOverFriend;

        if ( cell == -1 ) return null;
        if ( cell == 0 || (flag && isEnemy(cell,player)) || isGoal(cell,player)) return position;
        if (!flag && cell == player) flag = true;

        return move(direction,position,player,flag);
    }
Ejemplo n.º 10
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            if (MemoryLocations.Database.Count == 0)
            {
                return;
            }

            if (_map == null)
            {
                return;
            }

            _mapScaleX = this.ActualWidth / XPixelCount;
            _mapScaleY = this.ActualHeight / YPixelCount;

            MemoryFunctions.GetCharacters(_monsters, _fate, _players, ref _user);
            MemoryFunctions.GetNPCs(_npcs);

            // Calculate the 2d map coordinates from 3d world coordinates.
            Coordinate userMapCoord = WorldToMap(_user.Coordinate);

            // Draw the map
            drawingContext.DrawImage(_map, new Rect(new Point(0, 0), new Size(this.ActualWidth, this.ActualHeight)));

            if (_mapIndex == 0)
            {
                return;
            }

            DrawMarkers(drawingContext);
            DrawPaths(drawingContext);
            DrawMonsters(drawingContext);
            DrawPlayers(drawingContext);
            DrawNPCs(drawingContext);

            if (ShowSelf)
            {
                // Draw the user coordinates

                if (SmallSelfIcon)
                {
                    drawingContext.DrawEllipse(Brushes.Cyan, new Pen(new SolidColorBrush(Colors.Cyan), 1), new Point(userMapCoord.X, userMapCoord.Y), 1, 1);
                }
                else
                {
                    drawingContext.DrawEllipse(Brushes.Cyan, new Pen(new SolidColorBrush(Colors.Cyan), 2),
                                               new Point(userMapCoord.X, userMapCoord.Y), 3, 3);

                    try
                    {
                        Coordinate heading = new Coordinate(0, 10 / _mapinfo.XScale, 0);
                        heading = heading.Rotate2d(-_user.Heading);
                        heading = WorldToMap(heading.Add(_user.Coordinate));
                        drawingContext.DrawLine(new Pen(new SolidColorBrush(Colors.Cyan), 3),
                                                new Point(userMapCoord.X, userMapCoord.Y),
                                                new Point(heading.X, heading.Y));
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }