Ejemplo n.º 1
0
        public override bool Match(int x, int y, TileResultCollector <TRenderTile, TContext> resultCollector)
        {
            if (!Matcher(x, y))
            {
                return(false);
            }

            var context = ContextProvider(x, y);

            neighbourPositions = GridNavigator.NavigateNeighbours(new MapCoordinate(x, y), neighbourPositions);
            bool matchedOne = false;

            for (var i = 1; i < positions.Length; i++)
            {
                var mc = neighbourPositions[i - 1];
                if (Matcher(mc.X, mc.Y) && tileExists[i])
                {
                    resultCollector(SpritePosition.Whole, tiles[i], context);
                    matchedOne = true;
                }
            }

            if (!matchedOne)
            {
                // isolated tile ..
                if (tileExists[0])
                {
                    resultCollector(SpritePosition.Whole, tiles[0], context);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public override bool Match(int x, int y, TileResultCollector <TRenderTile, TContext> resultCollector)
        {
            if (!selfMatcher(x, y))
            {
                return(false);
            }

            neighbours = GridNavigator.NavigateNeighbours(new MapCoordinate(x, y), neighbours);
            var idx = MatchAsFlag(neighbours[NeighbourIndex.NorthEast.AsInt()]) << 0;

            idx += MatchAsFlag(neighbours[NeighbourIndex.SouthEast.AsInt()]) << 1;
            idx += MatchAsFlag(neighbours[NeighbourIndex.SouthWest.AsInt()]) << 2;
            idx += MatchAsFlag(neighbours[NeighbourIndex.NorthWest.AsInt()]) << 4;

            if (tagExists[idx])
            {
                resultCollector(SpritePosition.Whole, tags[idx], ContextProvider(x, y));
            }

            return(true);
        }