示例#1
0
        /// <summary>
        /// Perform a floodfill click at the specified (x,y) tile coords
        /// </summary>
        /// <param name="nMapX">Map click x-position (in tiles)</param>
        /// <param name="nMapY">Map click y-position (in tiles)</param>
        /// <returns>True if the map changes as a result of this click, false otherwise.</returns>
        public bool FloodFillClick(int nMapX, int nMapY)
        {
            int tileOld, subpaletteOld;

            m_map.GetTile(nMapX, nMapY, out tileOld, out subpaletteOld);
            Sprite spriteOld = m_ss.FindSprite(tileOld);

            Sprite spriteNew     = m_ss.CurrentSprite;
            int    tileNew       = spriteNew.FirstTileId;
            int    subpaletteNew = spriteNew.SubpaletteID;

            // Sprite & tile & subpalette match - nothing to do.
            if (tileOld == tileNew && subpaletteOld == subpaletteNew)
            {
                return(false);
            }

            // If the old/new sprite matches, then we're filling over the same sprite,
            // but with the tiles offset. We need to first floodfill with another tile
            // so that we can detect the sprite boundaries correctly.
            if (spriteNew == spriteOld)
            {
                FloodFill_Sprite(nMapX, nMapY, spriteOld, subpaletteOld, null, -1, subpaletteOld);
                FloodFill_Sprite(nMapX, nMapY, null, subpaletteOld, spriteNew, tileNew, subpaletteOld);
            }
            else
            {
                FloodFill_Sprite(nMapX, nMapY, spriteOld, subpaletteOld, spriteNew, tileNew, subpaletteNew);
            }

            return(true);
        }