Пример #1
0
        private void RedrawMap(bool clear, Graphics g)
        {
            if (this.CurrentFloorImage == null)
            {
                return;
            }
            if (clear)
            {
                g.Clear(Color.Black);
            }

            Objects.Location playerLoc = this.Client.Player.Location;

            if (checkboxLockToPlayer.Checked && this.Client.Player.Connected)
            {
                // get map location
                Point pt = new Point(playerLoc.X - this.CurrentFloorBounds.X,
                                     playerLoc.Y - this.CurrentFloorBounds.Y);
                // set current location based on player location
                this.CurrentLocation = new Objects.Location(pt.X - (int)(this.picboxMap.Width / this.Scale / 2),
                                                            pt.Y - (int)(this.picboxMap.Height / this.Scale / 2), playerLoc.Z);
            }

            g.DrawImage(this.CurrentFloorImage, new Rectangle(0, 0, this.picboxMap.Width, this.picboxMap.Height),
                        new Rectangle(this.CurrentLocation.X, this.CurrentLocation.Y,
                                      (int)(this.picboxMap.Width / this.Scale), (int)(this.picboxMap.Height / this.Scale)),
                        GraphicsUnit.Pixel);

            // get viewport
            Rectangle viewport = new Rectangle(this.CurrentLocation.X, this.CurrentLocation.Y,
                                               (int)(picboxMap.Width / this.Scale), (int)(picboxMap.Height / this.Scale));

            // draw creatures on the map
            if (checkboxDrawCreatures.Checked && this.Client.Player.Connected)
            {
                foreach (Objects.Creature c in this.Client.BattleList.GetCreatures(true, true))
                {
                    if (c.Z == this.CurrentLocation.Z)
                    {
                        // get map location of creature
                        Point mapLoc = new Point(c.X - this.CurrentFloorBounds.X, c.Y - this.CurrentFloorBounds.Y);
                        // check if creature is within view
                        if (mapLoc.X >= viewport.Left && mapLoc.Y >= viewport.Top &&
                            mapLoc.X <= viewport.Right && mapLoc.Y <= viewport.Bottom)
                        {
                            // get position relative to the image
                            Point pos = new Point((int)((mapLoc.X - viewport.Left) * this.Scale),
                                                  (int)((mapLoc.Y - viewport.Top) * this.Scale));
                            g.DrawLine(Pens.Red, new Point(pos.X - (int)(25 / this.Scale), pos.Y),
                                       new Point(pos.X + (int)(25 / this.Scale), pos.Y));
                            g.DrawLine(Pens.Red, new Point(pos.X, pos.Y - (int)(25 / this.Scale)),
                                       new Point(pos.X, pos.Y + (int)(25 / this.Scale)));
                        }
                    }
                }
            }

            // draw players/npcs on the map
            if (checkboxDrawPlayersNPCs.Checked && this.Client.Player.Connected)
            {
                foreach (Objects.Creature c in this.Client.BattleList.GetPlayers(true, true))
                {
                    if (c.Z == this.CurrentLocation.Z)
                    {
                        // get map location of player
                        Point mapLoc = new Point(c.X - this.CurrentFloorBounds.X, c.Y - this.CurrentFloorBounds.Y);
                        // check if creature is within view
                        if (mapLoc.X >= viewport.Left && mapLoc.Y >= viewport.Top &&
                            mapLoc.X <= viewport.Right && mapLoc.Y <= viewport.Bottom)
                        {
                            // get position relative to the image
                            Point pos = new Point((int)((mapLoc.X - viewport.Left) * this.Scale),
                                                  (int)((mapLoc.Y - viewport.Top) * this.Scale));
                            g.DrawLine(Pens.Blue, new Point(pos.X - (int)(25 / this.Scale), pos.Y),
                                       new Point(pos.X + (int)(25 / this.Scale), pos.Y));
                            g.DrawLine(Pens.Blue, new Point(pos.X, pos.Y - (int)(25 / this.Scale)),
                                       new Point(pos.X, pos.Y + (int)(25 / this.Scale)));
                        }
                    }
                }
            }

            // draw waypoints
            if (checkboxDrawWaypointPaths.Checked)
            {
                foreach (Modules.Cavebot.Waypoint wp in this.Client.Modules.Cavebot.GetWaypoints())
                {
                    // check if waypoint is on our current floor
                    if (wp.Location.Z != this.CurrentLocation.Z)
                    {
                        continue;
                    }

                    // get map location of waypoint
                    Point mapLoc = new Point(wp.Location.X - this.CurrentFloorBounds.X,
                                             wp.Location.Y - this.CurrentFloorBounds.Y);

                    // check if waypoint is within view
                    if (mapLoc.X >= viewport.Left && mapLoc.Y >= viewport.Top &&
                        mapLoc.X <= viewport.Right && mapLoc.Y <= viewport.Bottom)
                    {
                        // get position relative to the image
                        Point pos = new Point((int)((mapLoc.X - viewport.Left) * this.Scale),
                                              (int)((mapLoc.Y - viewport.Top) * this.Scale));
                        int ellipseSize = 10;
                        g.FillEllipse(Brushes.SkyBlue, new Rectangle(pos.X - ellipseSize / 2, pos.Y - ellipseSize / 2,
                                                                     ellipseSize, ellipseSize));
                        g.DrawEllipse(Pens.Black, new Rectangle(pos.X - ellipseSize / 2, pos.Y - ellipseSize / 2,
                                                                ellipseSize, ellipseSize));
                    }

                    if (this.hoveredWaypoint != null)
                    {
                        mapLoc = new Point(this.hoveredWaypoint.Location.X - this.CurrentFloorBounds.X,
                                           this.hoveredWaypoint.Location.Y - this.CurrentFloorBounds.Y);
                        Point pos = new Point((int)((mapLoc.X - viewport.Left) * this.Scale),
                                              (int)((mapLoc.Y - viewport.Top) * this.Scale));
                        this.DrawOutlinedText(g, this.hoveredWaypoint.ToString(), this.TextFont,
                                              Brushes.Yellow, Brushes.Black, pos);
                    }
                }
            }

            // draw player cross on the map
            if (this.CurrentLocation.Z == playerLoc.Z && this.Client.Player.Connected)
            {
                // get map location of player
                Point mapLoc = new Point(playerLoc.X - this.CurrentFloorBounds.X, playerLoc.Y - this.CurrentFloorBounds.Y);
                // check if player is within view
                if (mapLoc.X >= viewport.Left && mapLoc.Y >= viewport.Top &&
                    mapLoc.X <= viewport.Right && mapLoc.Y <= viewport.Bottom)
                {
                    // get position relative to the image
                    Point playerPosition = new Point((int)((mapLoc.X - viewport.Left) * this.Scale),
                                                     (int)((mapLoc.Y - viewport.Top) * this.Scale));

                    // draw outline
                    g.DrawLine(Pens.Black, new Point(playerPosition.X - (int)(25 / this.Scale), playerPosition.Y - 1),
                               new Point(playerPosition.X + (int)(25 / this.Scale), playerPosition.Y - 1));
                    g.DrawLine(Pens.Black, new Point(playerPosition.X - 1, playerPosition.Y - (int)(25 / this.Scale)),
                               new Point(playerPosition.X - 1, playerPosition.Y + (int)(25 / this.Scale)));
                    g.DrawLine(Pens.Black, new Point(playerPosition.X - (int)(25 / this.Scale), playerPosition.Y + 1),
                               new Point(playerPosition.X + (int)(25 / this.Scale), playerPosition.Y + 1));
                    g.DrawLine(Pens.Black, new Point(playerPosition.X + 1, playerPosition.Y - (int)(25 / this.Scale)),
                               new Point(playerPosition.X + 1, playerPosition.Y + (int)(25 / this.Scale)));

                    g.DrawLine(Pens.White, new Point(playerPosition.X - (int)(25 / this.Scale), playerPosition.Y),
                               new Point(playerPosition.X + (int)(25 / this.Scale), playerPosition.Y));
                    g.DrawLine(Pens.White, new Point(playerPosition.X, playerPosition.Y - (int)(25 / this.Scale)),
                               new Point(playerPosition.X, playerPosition.Y + (int)(25 / this.Scale)));
                }
            }

            // time to draw a text overlay
            // get world location from viewport
            Objects.Location worldLoc = this.CurrentLocation.Offset(viewport.X, viewport.Y, 0);
            worldLoc.SetOffset((ushort)this.CurrentFloorBounds.X, (ushort)this.CurrentFloorBounds.Y, 0);
            // draw it
            this.DrawOutlinedText(g, worldLoc.ToString(), this.TextFont,
                                  Brushes.Yellow, Brushes.Black, new PointF(5, 5));

            return;
        }