Пример #1
0
        private void RecalculateMinMax(MultiTile tile)
        {
            if (tile.IsVirtualFloor)
            {
                return;
            }

            if (tile.GetBitmap() == null)
            {
                return;
            }

            int px = tile.XMod - GapXMod;
            int py = tile.YMod - GapYMod;

            if (px < XMin)
            {
                XMin = px;
            }

            if (py < YMin)
            {
                YMin = py;
            }

            px += tile.GetBitmap().Width;
            py += tile.GetBitmap().Height;

            if (px > XMax)
            {
                XMax = px;
            }

            if (py > YMax)
            {
                YMax = py;
            }

            if (tile.Z > ZMax)
            {
                ZMax = tile.Z;
            }

            if (tile.Z < ZMin)
            {
                ZMin = tile.Z;
            }

            _modified = false;

            XMinOrg = XMin;
            XMaxOrg = XMax;
            YMinOrg = YMin;
            YMaxOrg = YMax;

            if (_parent.ShowWalkables)
            {
                CalcWalkable();
            }

            if (_parent.ShowDoubleSurface)
            {
                CalcDoubleSurface();
            }
        }
Пример #2
0
        /// <summary>
        /// Gets <see cref="MultiTile"/> from given Pixel Location
        /// </summary>
        private MultiTile GetSelected(Point mouseLoc, int maxHeight, bool drawFloor)
        {
            if (Width == 0 || Height == 0)
            {
                return(null);
            }

            if (mouseLoc == Point.Empty)
            {
                return(null);
            }

            MultiTile selected = null;

            for (int i = Tiles.Count - 1; i >= 0; --i) // inverse for speedup
            {
                MultiTile tile = Tiles[i];
                if (tile.IsVirtualFloor)
                {
                    continue;
                }

                if (tile.Z > maxHeight)
                {
                    continue;
                }

                if (drawFloor && _parent.DrawFloorZ > tile.Z)
                {
                    continue;
                }

                Bitmap bmp = tile.GetBitmap();
                if (bmp == null)
                {
                    continue;
                }

                int px = tile.XMod;
                int py = tile.YMod;
                px -= XMin;
                py -= YMin;

                if (mouseLoc.X <= px || mouseLoc.X >= px + bmp.Width || mouseLoc.Y <= py || mouseLoc.Y >= py + bmp.Height)
                {
                    continue;
                }

                // Check for transparent part
                Color p = bmp.GetPixel(mouseLoc.X - px, mouseLoc.Y - py);
                if (p.R == 0 && p.G == 0 && p.B == 0)
                {
                    continue;
                }

                selected = tile;
                break;
            }

            return(selected);
        }