示例#1
0
        // --------------------------------------------------------------
        #region LOCAL FUNCTIONS
        // --------------------------------------------------------------

        /// <summary>
        /// Add the part to the list and check the location
        /// </summary>
        /// <param name="part">Part to add</param>
        private void AddPart(MultiItemPart part)
        {
            // add the part to the list
            Parts.Add(part);

            // update the max coordinates
            MaxX = Math.Max(part.X, MaxX);
            MaxY = Math.Max(part.Y, MaxY);
            MaxZ = Math.Max(part.Z, MaxZ);

            // update the min coordinates
            MinX = Math.Min(part.X, MinX);
            MinY = Math.Min(part.Y, MinY);
            MinZ = Math.Min(part.Z, MinZ);
        }
示例#2
0
        /// <summary>
        /// Calculate the final position in the canvas for the part to draw
        /// </summary>
        /// <param name="p">Part to draw</param>
        /// <param name="itm">Item data for the item to draw</param>
        /// <param name="width">Canvas width</param>
        /// <param name="height">Canvas height</param>
        /// <returns>Drawing position for the part</returns>
        private Point GetDrawingPosition(MultiItemPart p, ItemData itm, int width, int height)
        {
            // calculate the middle of the canvas (origin point 0,0)
            int halfWidth  = width / 2;
            int halfHeight = height / 2;

            // are we using the old KR items?
            if (Settings.Default.useOldKRItems)
            {
                // tile size to use
                int tileSize = defaultTileSize.Height;

                // calculate the item size
                int itmWidth  = itm.ECOffsets[1] - itm.ECOffsets[3];
                int itmHeight = -itm.ECOffsets[0];

                // initialize the extra shifting
                int shifX = 0;
                int shifY = 0;

                // floors are not isometric, so we need to fix the way they are drawn...
                if (itm.Flags.HasFlag(ItemData.TileFlag.Surface) && !itm.Flags.HasFlag(ItemData.TileFlag.Bridge) && !itm.Flags.HasFlag(ItemData.TileFlag.StairRight) && !itm.Flags.HasFlag(ItemData.TileFlag.Container))
                {
                    // set the shifting value
                    shifX = -(tileSize / 2);
                    shifY = -(tileSize / 2);

                    // change the tile size
                    tileSize -= 2;
                }

                // ship mast are drawn incorrectly
                if (itm.Flags.HasFlag(ItemData.TileFlag.Foliage))
                {
                    // set the shifting value (based on the mast ID)
                    switch (itm.ID)
                    {
                    case 15962:
                    {
                        shifY = -2;
                        break;
                    }

                    case 16093:
                    {
                        shifY = -10;
                        break;
                    }

                    case 15980:
                    {
                        shifY = -25;
                        break;
                    }
                    }
                }

                // calculate the position of the item in the canvas
                int itmCanvasX = halfWidth - (p.Y * tileSize) + (p.X * tileSize) + itmHeight + shifX;
                int itmCanvasY = halfHeight + (p.Y * tileSize) + (p.X * tileSize) + itmWidth + 64 + itmHeight - (p.OriginalZ * 6) + shifY;

                // calculate the final position
                int x = itmCanvasX + itm.ECOffsets[4];
                int y = itmCanvasY + itm.ECOffsets[5];

                return(new Point(x, y));
            }
            else
            {
                // tile size to use
                int tileSize = defaultTileSize.Width;

                // calculate the item size
                int itmWidth  = itm.CCOffsets[1] - itm.CCOffsets[3];
                int itmHeight = itm.CCOffsets[0];

                // calculate the position of the item in the canvas
                int itmCanvasX = halfWidth - (p.Y * tileSize) + (p.X * tileSize) + itmHeight;
                int itmCanvasY = halfHeight + (p.Y * tileSize) + (p.X * tileSize) + itmWidth + 64 + itmHeight - (p.OriginalZ * 4);

                // calculate the final position
                int x = itmCanvasX + itm.CCOffsets[4];
                int y = itmCanvasY + itm.CCOffsets[5];

                return(new Point(x, y));
            }
        }