예제 #1
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();
            }
        }