Beispiel #1
0
        // Должен отрисовывать только изменения карты
        public void DrawMap()
        {
            Logging.WriteDebbug("Я рисую");
            if (_prevMap == null)
            {
                for (int rowCnt = 0; rowCnt <= _map.Height; rowCnt++)
                {
                    for (int colCnt = 0; colCnt <= _map.Width; colCnt++)
                    {
                        var item = _map.ArrayMap[rowCnt, colCnt];



                        var wall = item as Wall;
                        if (wall != null)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkCyan;
                            Console.Write(ConsoleConsts.SYMBOL_WALL);
                            Console.ResetColor();
                            continue;
                        }
                        var wallUpgradeFar = item as WallWithUpgradeFar;
                        if (wallUpgradeFar != null)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkCyan;
                            Console.Write(ConsoleConsts.SYMBOL_WALL);
                            Console.ResetColor();
                            continue;
                        }
                        var wallUpgradeRemote = item as WallWithUpgradeRemote;
                        if (wallUpgradeRemote != null)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkCyan;
                            Console.Write(ConsoleConsts.SYMBOL_WALL);
                            Console.ResetColor();
                            continue;
                        }
                        var wallUpgradeMultiBomb = item as WallWithUpgradeMultiBomb;
                        if (wallUpgradeMultiBomb != null)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkCyan;
                            Console.Write(ConsoleConsts.SYMBOL_WALL);
                            Console.ResetColor();
                            continue;
                        }
                        var upgradeFar = item as UpgradeFar;
                        if (upgradeFar != null)
                        {
                            Console.ForegroundColor = ConsoleColor.Cyan;
                            Console.Write(ConsoleConsts.SYMBOL_UPGRADE_FAR);
                            Console.ResetColor();
                            continue;
                        }
                        var upgradeRemote = item as UpgradeRemote;
                        if (upgradeRemote != null)
                        {
                            Console.ForegroundColor = ConsoleColor.Cyan;
                            Console.Write(ConsoleConsts.SYMBOL_UPGRADE_REMOTE);
                            Console.ResetColor();
                            continue;
                        }
                        var upgradeMultiBomb = item as UpgradeMultiBomb;
                        if (upgradeMultiBomb != null)
                        {
                            Console.ForegroundColor = ConsoleColor.Cyan;
                            Console.Write(ConsoleConsts.SYMBOL_UPGRADE_MULTI_BOMB);
                            Console.ResetColor();
                            continue;
                        }
                        var space = item as Space;
                        if (space != null)
                        {
                            Console.Write(ConsoleConsts.SYMBOL_SPACE);
                            continue;
                        }

                        var monster_fly = item as MonsterFly;
                        if (monster_fly != null)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Write(ConsoleConsts.SYMBOL_MONSTER_ARE_FLY);
                            Console.ResetColor();
                            continue;
                        }
                        var monster_not_fly = item as MonsterNotFly;
                        if (monster_not_fly != null)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Write(ConsoleConsts.SYMBOL_MONSTER_NOT_FLY);
                            Console.ResetColor();
                            continue;
                        }
                        var monsterClever = item as MonsterClever;
                        if (monsterClever != null)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Write(ConsoleConsts.SYMBOL_MONSTER_CLEVER);
                            Console.ResetColor();
                            continue;
                        }
                        var bomber = item as Bomber;
                        if (bomber != null)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkMagenta;
                            Console.Write(ConsoleConsts.SYMBOL_BOMBER);
                            Console.ResetColor();
                            continue;
                        }
                        var wallAngle = item as WallAngle;
                        if (wallAngle != null)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Console.Write(ConsoleConsts.SYMBOL_MAP_ANGLE);
                            Console.ResetColor();
                            continue;
                        }
                        var wallVert = item as WallVerticale;
                        if (wallVert != null)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Console.Write(ConsoleConsts.SYMBOL_MAP_WALL_VERTICAL);
                            Console.ResetColor();
                            continue;
                        }
                        var wallHoriz = item as WallHorizontal;
                        if (wallHoriz != null)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Console.Write(ConsoleConsts.SYMBOL_MAP_WALL_HORIZONTAL);
                            Console.ResetColor();
                            continue;
                        }
                    }
                    Console.WriteLine();
                }
            }
            else
            {
                Entity item;

                for (int colCnt = 0; colCnt <= _map.Height; colCnt++)
                {
                    for (int rowCnt = 0; rowCnt <= _map.Width; rowCnt++)
                    {
                        if (!_map.ArrayMap[colCnt, rowCnt].Equals(_prevMap.ArrayMap[colCnt, rowCnt]))
                        {
                            WriteToPosition(_map.ArrayMap[colCnt, rowCnt], rowCnt, colCnt);
                        }
                    }
                }
            }



            // Запоминаем прошлую карту
            _prevMap           = (ConsoleMap)_map.Clone();
            Console.WindowTop  = 0;
            Console.WindowLeft = 0;
            Logging.WriteDebbug("Я дорисовал");
        }
Beispiel #2
0
 public ConsoleDisplay(ConsoleMap map)
 {
     this._map = map;
 }