Example #1
0
        public void DrawTiles(SKCanvas g, Model model, float startX, float startY, int startIndex, Dictionary <string, string> overrides, float resize = 1)
        {
            var dict         = new Dictionary <string, string>();//logging
            var SKBitmapList = new List <Tuple <string, SKBitmap> >(model.TileNames.Length);

            string characterRace = model.SideData.Race.Substring(0, 6);

            string[] location = model.SideData.Place.Split(':');

            _outOfSightCache.DumpDataOnLocationChange(model.SideData.Place);

            if (!_floorandwall.TryGetValue(location[0].ToUpper(), out var CurrentLocationFloorAndWallName))
            {
                return;
            }

            if (!_floorandwallColor.TryGetValue(location[0].ToUpper(), out var CurrentLocationFloorAndWallColor))
            {
                return;
            }

            if (!_wallpng.TryGetValue(CurrentLocationFloorAndWallName[0], out var wall))
            {
                return;
            }
            if (!_floorpng.TryGetValue(CurrentLocationFloorAndWallName[1], out var floor))
            {
                return;
            }

            //TODO special handling for pan abyss zot and elf

            var currentTileX = startX;
            var currentTileY = startY;

            if (startIndex == 0)
            {
                currentTileY -= 32 * resize;                 //since start of loop begins on a newline we back up one so it isn't one line too low.
            }
            for (int i = startIndex; i < model.TileNames.Length; i++)
            {
                if (i % model.LineLength == 0)
                {
                    currentTileX  = startX;
                    currentTileY += 32 * resize;
                }
                else
                {
                    currentTileX += 32 * resize;
                }

                var tileDrawn = DrawCurrentTile(g, model, dict, model.TileNames[i], model.HighlightColors[i], wall, floor, CurrentLocationFloorAndWallColor, overrides, currentTileX, currentTileY, resize, out SKBitmap drawnTile);

                if (tileDrawn && !model.TileNames[i].IsWallOrFloor())
                {
                    SKBitmapList.Add(new Tuple <string, SKBitmap>(model.TileNames[i], drawnTile));
                }
            }
            _outOfSightCache.UpdateCache(SKBitmapList);

#if DEBUG //log unknown characters
            if (dict.Count < 10)
            {
                bool written = false;
                foreach (var item in dict)
                {
                    if (!string.IsNullOrEmpty(item.Key))
                    {
                        written = true;
                    }

                    Console.Write(item.Key + " ");
                }
                if (written)
                {
                    Console.WriteLine();
                }
            }
#endif
        }