Exemplo n.º 1
0
        /// <summary>
        /// Combines all tiles to form a graphic plane.
        /// </summary>
        /// <returns>
        /// Newly created graphic plane.
        /// </returns>
        public GraphicPlane Combine(CombineArgs args)
        {
            if(this.Type == MapType.Map2D)
            {
                GraphicPlane plane = new GraphicPlane(this.Width*16, this.Height*16);
                plane.Palette = ImagePalette.GetFullPalette(this.Palette);
                foreach(Tile t in this.TileData)
                {
                    Point loc = new Point(t.X*16, t.Y*16);
                    if(args.ShowUnderlays)
                    {
                        RawImage ul = IconGraphics.GetTileUnderlay(this.Tileset, t);
                        plane.Objects.Add(new GraphicObject(ul, loc));
                    }
                    if(!args.ShowHelpers&&IsHelperTile(tilesid, t.Overlay))continue;
                    if(args.ShowOverlays)
                    {
                        RawImage ol = IconGraphics.GetTileOverlay(this.Tileset, t);
                        plane.Objects.Add(new GraphicObject(ol, loc));
                    }
                }
                return plane;
            }else if(this.Type == MapType.Map3D)
            {
                MinimapType mt = MinimapType.Classic;
                LabData ld = LabData.GetLabData(this.Labdata);

                GraphicPlane plane = new GraphicPlane(this.Width*8, this.Height*8);
                ImagePalette src = ImagePalette.GetFullPalette(this.Palette);
                ImagePalette dest = plane.Palette = new MinimapPalette(src);

                if(ld != null)
                {
                    if(args.ShowFloors)
                    {
                        //Floors
                        IndexedCache<RawImage> floorcache = new IndexedCache<RawImage>(i=>Minimize(LabGraphics.GetFloor(this.Labdata, i), src, dest));
                        foreach(Block b in this.BlockData)
                        {
                            if(b.Floor != 0)
                            {
                                Point loc = new Point(b.X*8, b.Y*8);
                                plane.Objects.Add(new GraphicObject(floorcache[b.Floor], loc));
                            }
                        }
                    }

                    if(args.ShowWalls)
                    {
                        //Walls
                        foreach(Block b in this.BlockData)
                        {
                            if(b.IsWall && !ld.GetMinimapForm(b).VisibleOnMinimap)
                            {
                                WallForm form = WallForm.Close;
                                if(b.Y > 0 &&        BlockData[b.X  , b.Y-1].IsWall)form |= WallForm.OpenTop;
                                if(b.X < Width-1 &&  BlockData[b.X+1, b.Y  ].IsWall)form |= WallForm.OpenRight;
                                if(b.Y < Height-1 && BlockData[b.X  , b.Y+1].IsWall)form |= WallForm.OpenBottom;
                                if(b.X > 0 &&        BlockData[b.X-1, b.Y  ].IsWall)form |= WallForm.OpenLeft;
                                Point loc = new Point(b.X*8, b.Y*8);
                                plane.Objects.Add(new GraphicObject(AutoGFX.GetWall(form, mt), loc));
                            }
                        }
                    }
                }

                foreach(Block b in this.BlockData)
                {
                    Point loc = new Point(b.X*8, (b.Y-1)*8);
                    if(args.ShowNPCs)
                    {
                        //NPCs
                        foreach(NPC npc in UsedNPCs)
                        {
                            if(npc.Positions[0].X == b.X && npc.Positions[0].Y == b.Y)
                            {
                                byte type = 0;
                                if(npc.Interaction == 2)type = 8;
                                else type = 17;
                                if(type != 0)
                                    plane.Objects.Add(new GraphicObject(AutoGFX.GetMapObject(type, mt), loc));
                            }
                        }
                    }

                    if(args.ShowObjects)
                    {
                        //Objects
                        if(ld != null)
                        {
                            if(!b.IsEmpty)
                            {
                                byte type = ld.GetMinimapForm(b).MinimapType;
                                plane.Objects.Add(new GraphicObject(AutoGFX.GetMapObject(type, mt), loc));
                            }
                        }
                    }

                    if(args.ShowGotoPoints)
                    {
                        //Goto-points
                        if(b.GotoPoint!=null)
                        {
                            plane.Objects.Add(new GraphicObject(AutoGFX.GetMapObject(18, mt), loc));
                        }
                    }
                }
                return plane;
            }
            return null;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Combines all tiles to form a graphic plane.
        /// </summary>
        /// <returns>
        /// Newly created graphic plane.
        /// </returns>
        public GraphicPlane Combine(CombineArgs args)
        {
            if (this.Type == MapType.Map2D)
            {
                GraphicPlane plane = new GraphicPlane(this.Width * 16, this.Height * 16);
                plane.Palette = ImagePalette.GetFullPalette(this.Palette);
                foreach (Tile t in this.TileData)
                {
                    Point loc = new Point(t.X * 16, t.Y * 16);
                    if (args.ShowUnderlays)
                    {
                        RawImage ul = MapIcons.GetTileUnderlay(this.Tileset, t);
                        plane.Objects.Add(new GraphicObject(ul, loc));
                    }
                    if (!args.ShowHelpers && IsHelperTile(tilesid, t.Overlay))
                    {
                        continue;
                    }
                    if (args.ShowOverlays)
                    {
                        RawImage ol = MapIcons.GetTileOverlay(this.Tileset, t);
                        plane.Objects.Add(new GraphicObject(ol, loc));
                    }
                }
                if (args.ShowNPCs2D)
                {
                    foreach (NPC npc in UsedNPCs)
                    {
                        ImageBase img = NPCGraphics.GetNPCBig(npc.ObjectID)[6];
                        Point     loc = new Point(npc.X * 16, npc.Y * 16 - img.GetHeight() + 16);
                        plane.Objects.Add(new GraphicObject(img, loc));
                    }
                }
                return(plane);
            }
            else if (this.Type == MapType.Map3D)
            {
                MinimapType mt = MinimapType.Classic;
                LabData     ld = LabData.GetLabData(this.Labdata);

                GraphicPlane plane = new GraphicPlane(this.Width * 8, this.Height * 8);
                ImagePalette src   = ImagePalette.GetFullPalette(this.Palette);
                ImagePalette dest  = plane.Palette = new MinimapPalette(src);

                if (ld != null)
                {
                    if (args.ShowFloors)
                    {
                        //Floors
                        IndexedCache <RawImage> floorcache = new IndexedCache <RawImage>(i => Minimize(LabGraphics.GetFloor(this.Labdata, i), src, dest));
                        foreach (Block b in this.BlockData)
                        {
                            if (b.Floor != 0)
                            {
                                Point loc = new Point(b.X * 8, b.Y * 8);
                                plane.Objects.Add(new GraphicObject(floorcache[b.Floor], loc));
                            }
                        }
                    }

                    if (args.ShowWalls)
                    {
                        //Walls
                        foreach (Block b in this.BlockData)
                        {
                            if (b.IsWall && !ld.GetMinimapForm(b).VisibleOnMinimap)
                            {
                                WallForm form = WallForm.Close;
                                if (b.Y > 0 && BlockData[b.X, b.Y - 1].IsWall)
                                {
                                    form |= WallForm.OpenTop;
                                }
                                if (b.X < Width - 1 && BlockData[b.X + 1, b.Y].IsWall)
                                {
                                    form |= WallForm.OpenRight;
                                }
                                if (b.Y < Height - 1 && BlockData[b.X, b.Y + 1].IsWall)
                                {
                                    form |= WallForm.OpenBottom;
                                }
                                if (b.X > 0 && BlockData[b.X - 1, b.Y].IsWall)
                                {
                                    form |= WallForm.OpenLeft;
                                }
                                Point loc = new Point(b.X * 8, b.Y * 8);
                                plane.Objects.Add(new GraphicObject(AutoGFX.GetWall(form, mt), loc));
                            }
                        }
                    }
                }

                foreach (Block b in this.BlockData)
                {
                    Point loc = new Point(b.X * 8, (b.Y - 1) * 8);
                    if (args.ShowNPCs3D)
                    {
                        //NPCs
                        foreach (NPC npc in UsedNPCs)
                        {
                            if (npc.Positions[0].X == b.X && npc.Positions[0].Y == b.Y)
                            {
                                byte type = 0;
                                if (npc.Interaction == 2)
                                {
                                    type = 8;
                                }
                                else
                                {
                                    type = 17;
                                }
                                if (type != 0)
                                {
                                    plane.Objects.Add(new GraphicObject(AutoGFX.GetIcon(type, mt), loc));
                                }
                            }
                        }
                    }

                    if (args.ShowObjects)
                    {
                        //Objects
                        if (ld != null)
                        {
                            if (!b.IsEmpty)
                            {
                                byte type = ld.GetMinimapForm(b).MinimapType;
                                plane.Objects.Add(new GraphicObject(AutoGFX.GetIcon(type, mt), loc));
                            }
                        }
                    }

                    if (args.ShowGotoPoints)
                    {
                        //Goto-points
                        if (b.GotoPoint != null)
                        {
                            plane.Objects.Add(new GraphicObject(AutoGFX.GetIcon(18, mt), loc));
                        }
                    }
                }
                return(plane);
            }
            return(null);
        }