Пример #1
0
 public void Draw(RLConsole console, IMap map)
 {
     if (!map.IsExplored(X, Y))
     {
         console.Set(X, Y, Color, Colors.FloorBackgroundFov, Symbol);
     }
     else
     {
         console.Set(X, Y, RLColor.Blend(Color, RLColor.Gray, 0.5f), Colors.FloorBackground, Symbol);
     }
 }
Пример #2
0
        public void Draw(RLConsole console, IMap map)
        {
            if ((!map.IsExplored(X, Y)))
            {
                return;
            }

            if (map.IsInFov(X, Y))
            {
                console.Set(X, Y, Color, Colors.FloorBackgroundFov, Symbol);
            }
            //if the door has not been found
            else
            {
                console.Set(X, Y, RLColor.Blend(Color, RLColor.Gray, 0.5f), Colors.FloorBackground, Symbol);
            }
        }
Пример #3
0
        public override void Draw(RLConsole console, IMap map)
        {
            if (!map.GetCell(X, Y).IsExplored)
            {
                return;
            }

            double distance    = Game.DistanceBetween(Game.Player.X, Game.Player.Y, X, Y);
            float  blendRatio  = .5f / Game.Player.Awareness;
            float  blendAmount = (float)(blendRatio * distance);

            if (map.IsInFov(X, Y))
            {
                console.Set(X, Y, RLColor.Blend(Colors.LowLevelFloorFov, Colors.LowLevelFloor, .5f - blendAmount), null, Symbol);
            }
            else
            {
                console.Set(X, Y, Colors.LowLevelFloor, null, Symbol);
            }
        }
Пример #4
0
        private static void rootConsole_Render(object sender, UpdateEventArgs e)
        {
            rootConsole.Clear();
            map.ComputeFov(_playerX, _playerY, 50, true);

            foreach (var cell in map.GetAllCells())
            {
                if (!cell.IsInFov)
                {
                    map.SetCellProperties(cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, true);
                    switch (_map[cell.X, cell.Y])
                    {
                    case Tile.Floor: rootConsole.Print(cell.X, cell.Y, ".", RLColor.Gray); break;

                    case Tile.RoomFloor: rootConsole.Print(cell.X, cell.Y, ".", RLColor.White); break;

                    case Tile.Wall: rootConsole.Print(cell.X, cell.Y, "#", RLColor.LightGray); break;

                    case Tile.Door: rootConsole.Print(cell.X, cell.Y, "+", RLColor.Brown); break;
                    }
                }
                else if (cell.IsExplored)
                {
                    switch (_map[cell.X, cell.Y])
                    {
                    case Tile.Floor: rootConsole.Print(cell.X, cell.Y, ".", RLColor.Blend(RLColor.Gray, RLColor.Black)); break;

                    case Tile.RoomFloor: rootConsole.Print(cell.X, cell.Y, ".", RLColor.Blend(RLColor.White, RLColor.Black)); break;

                    case Tile.Wall: rootConsole.Print(cell.X, cell.Y, "#", RLColor.Blend(RLColor.LightGray, RLColor.Black)); break;

                    case Tile.Door: rootConsole.Print(cell.X, cell.Y, "+", RLColor.Blend(RLColor.Brown, RLColor.Black)); break;
                    }
                }
            }
            rootConsole.Print(_playerX, _playerY, "@", RLColor.LightGreen);
            rootConsole.Draw();
        }
Пример #5
0
 public static RLColor GetDarkerColor(RLColor color, float blendRatio)
 {
     return(RLColor.Blend(color, RLColor.Black, blendRatio));
 }
Пример #6
0
 public static RLColor GetDarkerColor(RLColor color)
 {
     return(RLColor.Blend(color, RLColor.Black, 150));
 }
Пример #7
0
        private void SetConsoleSymbolForCell(RLConsole console, ICell cell)
        {
            if (!cell.IsExplored)
            {
                return;
            }

            double distance    = Game.DistanceBetween(Game.Player.X, Game.Player.Y, cell.X, cell.Y);
            float  blendRatio  = .5f / Game.Player.Awareness;
            float  blendAmount = (float)(blendRatio * distance);

            // Floor values used in Actor.cs
            if (Game.MapLevel < 3)
            {
                if (IsInFov(cell.X, cell.Y))
                {
                    if (cell.IsWalkable)
                    {
                        console.Set(cell.X, cell.Y, RLColor.Blend(Colors.LowLevelFloorFov, Colors.LowLevelFloor, .5f - blendAmount), RLColor.Blend(Colors.BackgroundFov1, Colors.BackgroundFov2, .5f - blendAmount), '.');
                    }
                    else
                    {
                        console.Set(cell.X, cell.Y, RLColor.Blend(Colors.LowLevelWallFov, Colors.LowLevelWall, .5f - blendAmount), RLColor.Blend(Colors.BackgroundFov1, Colors.BackgroundFov2, .5f - blendAmount), '#');
                    }
                }
                else
                {
                    if (cell.IsWalkable)
                    {
                        console.Set(cell.X, cell.Y, Colors.LowLevelFloor, Colors.Background, '.');
                    }
                    else
                    {
                        console.Set(cell.X, cell.Y, Colors.LowLevelWall, Colors.Background, '#');
                    }
                }
            }
            else if (Game.MapLevel < 5)
            {
                if (IsInFov(cell.X, cell.Y))
                {
                    if (cell.IsWalkable)
                    {
                        console.Set(cell.X, cell.Y, RLColor.Blend(Colors.FloorFov, Colors.Floor, .5f - blendAmount), RLColor.Blend(Colors.BackgroundFov1, Colors.BackgroundFov2, .5f - blendAmount), '.');
                    }
                    else
                    {
                        console.Set(cell.X, cell.Y, RLColor.Blend(Colors.WallFov, Colors.Wall, .5f - blendAmount), RLColor.Blend(Colors.BackgroundFov1, Colors.BackgroundFov2, .5f - blendAmount), '#');
                    }
                }
                else
                {
                    if (cell.IsWalkable)
                    {
                        console.Set(cell.X, cell.Y, Colors.Floor, Colors.Background, '.');
                    }
                    else
                    {
                        console.Set(cell.X, cell.Y, Colors.Wall, Colors.Background, '#');
                    }
                }
            }
            else if (Game.MapLevel < 7)
            {
                if (IsInFov(cell.X, cell.Y))
                {
                    if (cell.IsWalkable)
                    {
                        console.Set(cell.X, cell.Y, RLColor.Blend(Colors.IceFloorFov, Colors.IceFloor, .5f - blendAmount), RLColor.Blend(Colors.BackgroundFov1, Colors.BackgroundFov2, .5f - blendAmount), '.');
                    }
                    else
                    {
                        console.Set(cell.X, cell.Y, RLColor.Blend(Colors.IceWallFov, Colors.IceWall, .5f - blendAmount), RLColor.Blend(Colors.BackgroundFov1, Colors.BackgroundFov2, .5f - blendAmount), '#');
                    }
                }
                else
                {
                    if (cell.IsWalkable)
                    {
                        console.Set(cell.X, cell.Y, Colors.IceFloor, Colors.Background, '.');
                    }
                    else
                    {
                        console.Set(cell.X, cell.Y, Colors.IceWall, Colors.Background, '#');
                    }
                }
            }
            else if (Game.MapLevel < 9)
            {
                if (IsInFov(cell.X, cell.Y))
                {
                    if (cell.IsWalkable)
                    {
                        console.Set(cell.X, cell.Y, RLColor.Blend(Colors.CaveFloorFov, Colors.CaveFloor, .5f - blendAmount), RLColor.Blend(Colors.BackgroundFov1, Colors.BackgroundFov2, .5f - blendAmount), '.');
                    }
                    else
                    {
                        console.Set(cell.X, cell.Y, RLColor.Blend(Colors.CaveWallFov, Colors.CaveWall, .5f - blendAmount), RLColor.Blend(Colors.BackgroundFov1, Colors.BackgroundFov2, .5f - blendAmount), '#');
                    }
                }

                else
                {
                    if (cell.IsWalkable)
                    {
                        console.Set(cell.X, cell.Y, Colors.CaveFloor, Colors.Background, '.');
                    }
                    else
                    {
                        console.Set(cell.X, cell.Y, Colors.CaveWall, Colors.Background, '#');
                    }
                }
            }
            else
            {
                if (IsInFov(cell.X, cell.Y))
                {
                    if (cell.IsWalkable)
                    {
                        console.Set(cell.X, cell.Y, RLColor.Blend(Colors.HellFloorFov, Colors.HellFloor, .5f - blendAmount), RLColor.Blend(Colors.BackgroundFov1, Colors.BackgroundFov2, .5f - blendAmount), '.');
                    }
                    else
                    {
                        console.Set(cell.X, cell.Y, RLColor.Blend(Colors.HellWallFov, Colors.HellWall, .5f - blendAmount), RLColor.Blend(Colors.BackgroundFov1, Colors.BackgroundFov2, .5f - blendAmount), '#');
                    }
                }
                else
                {
                    if (cell.IsWalkable)
                    {
                        console.Set(cell.X, cell.Y, Colors.HellFloor, Colors.Background, '.');
                    }
                    else
                    {
                        console.Set(cell.X, cell.Y, Colors.HellWall, Colors.Background, '#');
                    }
                }
            }
        }
Пример #8
0
        // Event handler for RLNET's Render event
        private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
        {
            DateTime _currentTime = DateTime.Now;

            if (!_gameOver && _time.AddMilliseconds(160) < _currentTime)
            {
                _renderRequired = true;
                _nextAnimation  = true;
                _time           = _currentTime;
            }
            if (_renderRequired && !_gameOver)
            {
                _rootConsole.Clear();
                _mapConsole.Clear();
                _statConsole.Clear();
                _messageConsole.Clear();
                _inventoryConsole.Clear();

                Point mapBlitOrigin = GetMapBlitOrigin();

                _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, Colors.Alternate);
                _messageConsole.SetBackColor(0, 0, _messageWidth, _messageHeight, Colors.Secondary);
                if (_mapLevel == 1)
                {
                    _mapConsole.SetBackColor(mapBlitOrigin.X, mapBlitOrigin.Y, _onConsoleMapWidth, _onConsoleMapHeight, RLColor.Black);
                }
                else
                {
                    for (int i = 0; i < _onConsoleMapHeight; i++)
                    {
                        _mapConsole.SetBackColor(mapBlitOrigin.X, mapBlitOrigin.Y + i, _onConsoleMapWidth, 1, RLColor.Blend(Colors.gradient1, Colors.gradient2, 1f - i / (_onConsoleMapHeight - 1f)));
                    }
                }
                _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Colors.Compliment);
                _inventoryConsole.Print(1, 1, "Inventaire", RLColor.White);

                Map.Draw(_mapConsole, _statConsole, _nextAnimation);
                Player.Draw(_mapConsole, Map, _nextAnimation);
                MessageLog.Draw(_messageConsole);
                Player.DrawStats(_statConsole);
                Inventory.DrawWithEffect(_inventoryConsole, _mapConsole);

                ICell cell = Map.GetCell(Player.X, Player.Y);

                Point mousePos = GetMousePosOnMap();
                if (Map.IsInFov(mousePos.X, mousePos.Y) && Map.GetMonsterAt(mousePos.X, mousePos.Y) != null)
                {
                    CellSelection.DrawPath(Player.Coord, mousePos, _mapConsole);
                    _mapConsole.SetBackColor(mousePos.X, mousePos.Y, Colors.AlternateDarker);
                }

                _renderRequired = CellSelection.ShockWaveEffect(_mapConsole);
                _nextAnimation  = false;

                if (Map is InvertedMap invertedMap)
                {
                    _mapConsole   = invertedMap.InvertMap(_mapConsole);
                    mapBlitOrigin = new Point(_mapWidth - mapBlitOrigin.X - _onConsoleMapWidth, _mapHeight - mapBlitOrigin.Y - _onConsoleMapHeight);
                }

                // Blit the sub consoles to the root console in the correct locations
                RLConsole.Blit(_mapConsole, mapBlitOrigin.X, mapBlitOrigin.Y, _onConsoleMapWidth, _onConsoleMapHeight, _rootConsole, 0, _inventoryHeight);
                RLConsole.Blit(_statConsole, 0, 0, _statWidth, _statHeight, _rootConsole, _onConsoleMapWidth, 0);
                RLConsole.Blit(_messageConsole, 0, 0, _messageWidth, _messageHeight, _rootConsole, 0, _screenHeight - _messageHeight);
                RLConsole.Blit(_inventoryConsole, 0, 0, _inventoryWidth, _inventoryHeight, _rootConsole, 0, 0);

                // Tell RLNET to draw the console that we set
                _rootConsole.Draw();
            }
            else if (_gameOver)
            {
                _UIConsole.Clear();
                _UIConsole.SetBackColor(0, 0, _screenWidth, _screenHeight, Colors.ComplimentLighter);
                menu.Draw(_UIConsole, GetMousePos());
                RLConsole.Blit(_UIConsole, 0, 0, _UIWidth, _UIHeight, _rootConsole, 0, 0);
                _rootConsole.Draw();
            }
        }