Example #1
0
        public void InitializeMap()
        {
            img            = new Bitmap(pB_Map.Width, pB_Map.Height);
            pB_Map.Image   = img;
            graphics       = System.Drawing.Graphics.FromImage(img);
            timer.Interval = 15;
            timer.Tick    += timer_Tick;

            WorldOffset    = UserData.System.Coordinates;
            CameraPosition = /*UserData.System.Coordinates + */ new Data.Vector3(0, 0, 40);

            //Position = new Vector(UserData.System.Coordinates.X - (img.Width / 2), UserData.System.Coordinates.Z - (img.Height / 2));
            //Style.Add(UserData.System, new SystemDrawOptions() { Text = "You are Here", Color = Color.Red, Size = 10, ShowName = true });

            /*var testroute = new Data.Route();
             * testroute.Add(UserData.System);
             * testroute.Add(GlobalData.Systems[0]);
             * Routes.Add(testroute);*/

            timer_Tick(null, null);
            pB_Map.MouseWheel += pB_Map_MouseWheel;

            CameraZoom = (double)pB_Map.Width / 1.5;

            pB_Map.Focus();

            OldMousePosition = pB_Map.PointToClient(Control.MousePosition);
        }
Example #2
0
        void timer_Tick(object sender, EventArgs e)
        {
            graphics.Clear(Color.Black);

            foreach (var route in Routes)
            {
                foreach (var step in route.Steps)
                {
                    if (!Style.ContainsKey(step.System))
                    {
                        Style.Add(step.System, new SystemDrawOptions()
                        {
                            ShowName = true, Color = Color.BlueViolet, Size = 10
                        });
                    }
                }
            }

            var MousePosition = pB_Map.PointToClient(Control.MousePosition);

            if (OldMouseInitial)
            {
                OldMousePosition = MousePosition;
                OldMouseInitial  = false;
            }
            var Movement = new System.Drawing.Point(OldMousePosition.X - MousePosition.X, OldMousePosition.Y - MousePosition.Y);

            //Position += new Vector(Movement.X, Movement.Y);

            if (RotateMode)
            {
                WorldRotationY   += Movement.X;
                CameraPosition.Y += Movement.Y / 15 * (CameraPosition.Z * 0.1);
            }
            else if (Control.MouseButtons == System.Windows.Forms.MouseButtons.Right)
            {
                CameraPosition += new Data.Vector3(-Movement.X, 0, Movement.Y);
            }
            OldMousePosition = MousePosition;



            var ScreenRect = new System.Drawing.Rectangle(
                new System.Drawing.Point(0, 0),
                new System.Drawing.Size((int)(pB_Map.Width), (int)(pB_Map.Height)));


            int VisibleRectangles = 0;

            VisibleRectangles += DrawSystems(GlobalData.Systems, ScreenRect);

            DrawRoutes(ScreenRect);

            pB_Map.Image   = img;
            VisibleSystems = VisibleRectangles;
            if (OnVisibleSystemsChanged != null)
            {
                OnVisibleSystemsChanged(VisibleSystems);
            }
        }
Example #3
0
        private void Click()
        {
            var ScreenRectangle = new System.Drawing.Rectangle(
                new System.Drawing.Point(0, 0),
                new System.Drawing.Size((int)(pB_Map.Width), (int)(pB_Map.Height)));

            var MousePosition = pB_Map.PointToClient(Control.MousePosition);

            foreach (var system in GlobalData.Systems)
            {
                var Options = new SystemDrawOptions();
                if (Style.ContainsKey(system))
                {
                    Options = Style[system];
                }


                int Value = ((int)(((WorldOffset - system.Coordinates).Length * ViewDistance) * -1) + 255).Clamp(0, 255);

                var WorldPosition = (system.Coordinates - WorldOffset).RotateY(WorldRotationY);

                var DrawSize = (int)(Value / 50);

                if (Options.Size > 0)
                {
                    DrawSize = Options.Size;
                }

                var ScreenPos = Translate(WorldPosition) + new Vector((ScreenRectangle.Width), (ScreenRectangle.Height)); //new Vector(system.Coordinates.Z, system.Coordinates.X) - Position;

                var DrawRect = new Rectangle((int)((ScreenPos.X - ScreenRectangle.Width / 2)), (int)((ScreenPos.Y - ScreenRectangle.Height / 2)), DrawSize, DrawSize);

                if (DrawRect.Contains(MousePosition))
                {
                    WorldOffset = system.Coordinates;
                    if (!Style.ContainsKey(system))
                    {
                        Style.Add(system, new SystemDrawOptions()
                        {
                            ShowName = true, Color = Color.Blue
                        });
                    }
                    CameraPosition = /*UserData.System.Coordinates + */ new Data.Vector3(0, 0, 40);
                }
            }
            timer_Tick(null, null);
        }
Example #4
0
        private Vector Translate(Data.Vector3 Point)
        {
            Vector returnVec = new Vector();

            if (Point.Z - CameraPosition.Z >= 0)
            {
                returnVec.X = (int)((double)-(Point.X - CameraPosition.X) / (-0.1f) * CameraZoom);
                returnVec.Y = (int)((double)(Point.Y - CameraPosition.Y) / (-0.1f) * CameraZoom);
            }
            else
            {
                //tmpOrigin.X = (int)((double)(cubeOrigin.X - CameraPosition.X) / (double)(cubeOrigin.Z - CameraPosition.Z) * CameraZoom);
                //tmpOrigin.Y = (int)((double)-(cubeOrigin.Y - CameraPosition.Y) / (double)(cubeOrigin.Z - CameraPosition.Z) * CameraZoom);

                returnVec.X = (float)((Point.X - CameraPosition.X) / (Point.Z - CameraPosition.Z) * CameraZoom);
                returnVec.Y = (float)(-(Point.Y - CameraPosition.Y) / (Point.Z - CameraPosition.Z) * CameraZoom);

                //returnVec.X = (int)point3D[i].X;
                //returnVec.Y = (int)point3D[i].Y;
            }
            return(returnVec);
        }