Ejemplo n.º 1
0
        void Prepare(out TRenderTile[] tiles, out bool[] exists)
        {
            var owner    = matchers.Owner;
            var card     = owner.Count;
            var elements = (int)Math.Pow(card, 4);

            tiles  = new TRenderTile[elements];
            exists = new bool[elements];
            for (int a = 0; a < card; a += 1)
            {
                for (int b = 0; b < card; b += 1)
                {
                    for (int c = 0; c < card; c += 1)
                    {
                        for (int d = 0; d < card; d += 1)
                        {
                            var key = new CellMapTileSelectorKey(owner[a], owner[b], owner[c], owner[d]);
                            exists[key.LinearIndex] = registry.TryFind(prefix, key, out tiles[key.LinearIndex]);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public bool Match(int x, int y, TileResultCollector <TRenderTile, TContext> resultCollector)
        {
            NavigateForDownwardRenderDirection(x, y, out MapCoordinate coordA,
                                               out MapCoordinate coordB,
                                               out MapCoordinate coordC,
                                               out MapCoordinate coordD);

            if (matchers.Match(coordA.X, coordA.Y, out ITileTagEntrySelection matchA) &&
                matchers.Match(coordB.X, coordB.Y, out ITileTagEntrySelection matchB) &&
                matchers.Match(coordC.X, coordC.Y, out ITileTagEntrySelection matchC) &&
                matchers.Match(coordD.X, coordD.Y, out ITileTagEntrySelection matchD))
            {
                var linearIndex = CellMapTileSelectorKey.LinearIndexOf(matchA, matchB, matchC, matchD);
                if (tileExists[linearIndex])
                {
                    var tile = tiles[linearIndex];
                    resultCollector(SpritePosition.CellMap, tile, contextProvider(x, y));
                    return(true);
                }
            }

            return(false);
        }