Beispiel #1
0
        public override bool Match(int x, int y, TileResultCollector <TRenderTile, TContext> resultCollector)
        {
            coordinates = GridNavigator.NavigateCardinalNeighbours(new MapCoordinate(x, y), coordinates);

            var  n      = Matches(coordinates[(int)Direction.Up]);
            var  e      = Matches(coordinates[(int)Direction.Right]);
            var  s      = Matches(coordinates[(int)Direction.Down]);
            var  w      = Matches(coordinates[(int)Direction.Left]);
            bool result = false;

            if (n)
            {
                if (e)
                {
                    if (tileExists[1])
                    {
                        resultCollector(SpritePosition.Whole, tiles[1], ContextProvider(x, y));
                    }

                    result = true;
                }

                if (w)
                {
                    if (tileExists[0])
                    {
                        resultCollector(SpritePosition.Whole, tiles[0], ContextProvider(x, y));
                    }

                    result = true;
                }
            }

            if (s)
            {
                if (e)
                {
                    if (tileExists[2])
                    {
                        resultCollector(SpritePosition.Whole, tiles[2], ContextProvider(x, y));
                    }

                    result = true;
                }

                if (w)
                {
                    if (tileExists[3])
                    {
                        resultCollector(SpritePosition.Whole, tiles[3], ContextProvider(x, y));
                    }

                    result = true;
                }
            }

            return(result);
        }
Beispiel #2
0
        public override bool Match(int x, int y, TileResultCollector <TRenderTile, TContext> resultCollector)
        {
            // The current tile is not a land tile. If it is an ocean tile, we can test
            // whether one of the cardinal neighbours is a river that flows into the
            // ocean.
            if (!selfMatcher(x, y))
            {
                return(false);
            }

            coordinates = GridNavigator.NavigateCardinalNeighbours(new MapCoordinate(x, y), coordinates);
            if (Matches(coordinates[CardinalIndex.North.AsInt()]))
            {
                if (northTileExists)
                {
                    resultCollector(SpritePosition.Whole, northTile, ContextProvider(x, y));
                }

                return(true);
            }

            if (Matches(coordinates[CardinalIndex.East.AsInt()]))
            {
                if (eastTileExists)
                {
                    resultCollector(SpritePosition.Whole, eastTile, ContextProvider(x, y));
                }

                return(true);
            }

            if (Matches(coordinates[CardinalIndex.South.AsInt()]))
            {
                if (southTileExists)
                {
                    resultCollector(SpritePosition.Whole, southTile, ContextProvider(x, y));
                }

                return(true);
            }

            if (Matches(coordinates[CardinalIndex.West.AsInt()]))
            {
                if (westTileExists)
                {
                    resultCollector(SpritePosition.Whole, westTile, ContextProvider(x, y));
                }

                return(true);
            }

            return(false);
        }
Beispiel #3
0
        public override bool Match(int x, int y, TileResultCollector <TRenderTile, TContext> resultCollector)
        {
            if (!selfMatcher(x, y))
            {
                return(false);
            }

            Coordinates = GridNavigator.NavigateCardinalNeighbours(new MapCoordinate(x, y), Coordinates);
            int idx = 0;

            idx += MatchAsFlag(Coordinates[CardinalIndex.North.AsInt()]);
            idx += MatchAsFlag(Coordinates[CardinalIndex.East.AsInt()]) << 1;
            idx += MatchAsFlag(Coordinates[CardinalIndex.South.AsInt()]) << 2;
            idx += MatchAsFlag(Coordinates[CardinalIndex.West.AsInt()]) << 3;

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

            return(false);
        }