Exemplo n.º 1
0
        public Models.server.Status LoadStatus(string ServerName, string ServerPort, string sid)
        {
            // Get JSON
            string StatusJSON = GetFile(ServerName, ServerPort, "status.json", sid);

            // Load JSON world object list
            Models.server.Status Status = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.server.Status>(StatusJSON);

            return(Status);
        }
Exemplo n.º 2
0
        public PictureBox DrawMonuments(string ServerName, string ServerPort, List <Models.world.Monument> Monumentlst, PictureBox MapImg, Models.server.Status ServerStatus, RichTextBox OutPut)
        {
            HelperClass HelpMgr = new HelperClass();

            if (Monumentlst != null)
            {
                OutPut.AppendText(Environment.NewLine + "Total World Monumnets:" + Monumentlst.Count.ToString());

                foreach (Models.world.Monument Monument in Monumentlst)
                {
                    // Output the load of image
                    OutPut.AppendText(Environment.NewLine + "Attempting to draw [" + Monument.name + "]: " + Monument.displayName);

                    string ImgPath   = BuildMonumentsImagePath(Monument);
                    Image  ObjectImg = null;

                    // Check if image is cached
                    if (File.Exists("." + ImgPath))
                    {
                        // Load file from cache
                        ObjectImg = Image.FromFile("." + ImgPath);
                    }
                    else
                    {
                        // Try to get image for object
                        ObjectImg = GetImage(RustIOServer, "80", BuildMonumentsImagePath(Monument));

                        // Cache Image
                        ObjectImg.Save("." + ImgPath);
                    }

                    // Make sure its not null
                    if (ObjectImg != null)
                    {
                        // Draw Monuments
                        MapImg = DrawMonument(Monument, ObjectImg, MapImg, ServerStatus);
                    }
                }
            }

            return(MapImg);
        }
Exemplo n.º 3
0
 private double MapCenter(Models.server.Status ServerStatus)
 {
     // In-game cords zero is dead center. So take map size and div by 2. This is the MapCenter value.
     return(ServerStatus.world.size / 2);
 }
Exemplo n.º 4
0
        public PictureBox DrawMovingWorldObject(Models.world.@object worldobject, PictureBox MapImg, Models.server.Status ServerStatus)
        {
            // Scaling
            double rationy = (Convert.ToDouble(MapImg.Height) / ServerStatus.world.size) - offset;
            double rationx = (Convert.ToDouble(MapImg.Width) / ServerStatus.world.size) - offset;

            // Top + to Bottom -
            double y = MapCenter(ServerStatus) - worldobject.z;

            // Left - to Right +
            double x = MapCenter(ServerStatus) + worldobject.x;

            // Apply scale
            y = (y * rationy);
            x = (x * rationx);

            // Do rotation
            HelperClass Helpmgr = new HelperClass();

            // Move Picture Box
            // This breaks the GIF animation but I do not have a solution for this yet.
            worldobject.Icon2.Image    = (Bitmap)Helpmgr.RotateImage((Bitmap)worldobject.Icon.Clone(), worldobject.r).Clone();
            worldobject.Icon2.Location = new Point(Convert.ToInt32(x), Convert.ToInt32(y));
            worldobject.Icon2.BringToFront();

            // Update map
            return(MapImg);
        }
Exemplo n.º 5
0
        public PictureBox DrawMonument(Models.world.Monument Monument, Image MonumentImg, PictureBox MapImg, Models.server.Status ServerStatus)
        {
            // Scaling
            double rationy = (Convert.ToDouble(MapImg.Image.Height) / ServerStatus.world.size) - offset;
            double rationx = (Convert.ToDouble(MapImg.Image.Width) / ServerStatus.world.size) - offset;

            // Top + to Bottom -
            double y = MapCenter(ServerStatus) - Monument.position.z;

            // Left - to Right +
            double x = MapCenter(ServerStatus) + Monument.position.x;

            // Apply scale
            y = (y * rationy);
            x = (x * rationx);

            // Temp draw box
            using (Graphics gr = Graphics.FromImage(MapImg.Image))
            {
                // Build Rectangle
                RectangleF rect = new RectangleF(Convert.ToInt32(x), Convert.ToInt32(y), MonumentImg.Height, MonumentImg.Width);

                // Draw Solid Rectangle
                gr.DrawImage(MonumentImg, rect);
            }

            // Update map
            return(MapImg);
        }
Exemplo n.º 6
0
        public PictureBox DrawMovingWorldObjects(List <Models.world.@object> WorldObjects, PictureBox MapImg, Models.server.Status ServerStatus)
        {
            // Reset Map
            MapImg.Image = (Image)_defaultMapImg.Clone();

            foreach (Models.world.@object WorldObject in WorldObjects)
            {
                // Draw World Objects
                DrawMovingWorldObject(WorldObject, MapImg, ServerStatus);
            }

            return(MapImg);
        }