예제 #1
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);
        }
예제 #2
0
        public Models.world.@object LoadWorldObjectImage(Models.world.@object WorldObject, string WorldObjectType, PictureBox MapImg)
        {
            string ImgPath = string.Empty;

            // Data map
            switch (WorldObjectType)
            {
            case "b":
                ImgPath = "/map/img/bradley.png";
                break;

            case "S":
                ImgPath = "/map/img/ship.png";
                break;

            case "h":
                ImgPath = "/map/img/heli.gif";
                break;

            case "p":
                ImgPath = "/map/img/plane.png";
                break;

            case "l":
                ImgPath = "/map/img/self.png";
                break;

            case "s":
                ImgPath = "unknown.png";
                break;

            default:
                ImgPath = "unknown.png";
                break;
            }

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

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

            WorldObject.Icon2.Parent    = MapImg;
            WorldObject.Icon2.BackColor = Color.Transparent;
            WorldObject.Icon2.Size      = new Size(WorldObject.Icon2.Image.Width, WorldObject.Icon2.Image.Height);
            WorldObject.Icon2.Location  = new Point(1, 1);
            WorldObject.Icon2.BringToFront();

            if (WorldObjectType == "h")
            {
                WorldObject.Icon.RotateFlip(RotateFlipType.RotateNoneFlipXY);
            }
            return(WorldObject);
        }