Beispiel #1
0
        public static void Main()
        {
            _gameOver = true;

            menu       = new MainMenu(_screenWidth, _screenHeight);
            numberOnly = true;

            string fontFileName = "ExtendTestBis.png";

            // Donne le fichier de caractere a utiliser ainsi que leur taille (16 x 16 pixels)
            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight,
                                             16, 16, 1f, "Game Name");
            _rootConsole.SetWindowState(RLWindowState.Fullscreen);

            // Initialise la console principale sur laquelle viendront se coller toutes les autres
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);             // Console  qui affiche la carte
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);     // Console  qui affiche les messages
            _statConsole      = new RLConsole(_statWidth, _statHeight);           // Console  qui affiche les stats du joueurs et les monstres aux alentours
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight); // Console qui affiche l'inventaire
            _UIConsole        = new RLConsole(_screenWidth, _screenHeight);       // Console qui affiche les menus

            // Set up a handler for RLNET's Update event
            _rootConsole.Update += OnRootConsoleUpdate;
            // Set up a handler for RLNET's Render event
            _rootConsole.Render += OnRootConsoleRender;

            // Set background color and text for each console
            _rootConsole.SetBackColor(0, _inventoryHeight, _onConsoleMapWidth, _onConsoleMapHeight, Colors.Primary);
            _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, Colors.Alternate);
            _statConsole.Print(1, 1, "Stats", RLColor.White);

            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Colors.Compliment);
            _inventoryConsole.Print(1, 1, "Inventaire", RLColor.White);

            _time = DateTime.Now;

            // Begin RLNET's game loop
            _rootConsole.Run();
        }
Beispiel #2
0
        public void DrawInventory(RLConsole inventoryConsole)
        {
            inventoryConsole.Print(1, 1, "Equipment", Colors.InventoryHeading);
            inventoryConsole.Print(1, 3, $"Head: {Head.Name}", Head == HeadEquipment.None() ? Swatch.DbOldStone : Swatch.DbLight);
            inventoryConsole.Print(1, 5, $"Body: {Body.Name}", Body == BodyEquipment.None() ? Swatch.DbOldStone : Swatch.DbLight);
            inventoryConsole.Print(1, 7, $"Hand: {Hand.Name}", Hand == HandEquipment.None() ? Swatch.DbOldStone : Swatch.DbLight);
            inventoryConsole.Print(1, 9, $"Feet: {Feet.Name}", Feet == FeetEquipment.None() ? Swatch.DbOldStone : Swatch.DbLight);

            inventoryConsole.Print(28, 1, "Abilities", Colors.InventoryHeading);
            DrawAbility(QAbility, inventoryConsole, 0);
            DrawAbility(WAbility, inventoryConsole, 1);
            DrawAbility(EAbility, inventoryConsole, 2);
            DrawAbility(RAbility, inventoryConsole, 3);

            inventoryConsole.Print(55, 1, "Items", Colors.InventoryHeading);
            DrawItem(Item1, inventoryConsole, 0);
            DrawItem(Item2, inventoryConsole, 1);
            DrawItem(Item3, inventoryConsole, 2);
            DrawItem(Item4, inventoryConsole, 3);
        }
        public static void PrintBar(RLConsole console, int x, int y, int length, string name, Counter counter, RLColor color)
        {
            if (counter.Max == 0)
            {
                console.Print(x, y, name + ": 0/0", RLColor.White);
                return;
            }

            var counterStart = name.Length + 2;
            var counterText  = counter.ToString();

            for (int i = 0; i < length; i++)
            {
                char glyph = ' ';

                if (i < name.Length)
                {
                    glyph = name[i];
                }
                else if (i == name.Length)
                {
                    glyph = ':';
                }
                else if (i >= counterStart && i < counterStart + counterText.Length)
                {
                    glyph = counterText[i - counterStart];
                }

                if ((decimal)i / length < (decimal)counter.Current / counter.Max)
                {
                    console.Set(x + i, y, RLColor.Black, color, glyph);
                }
                else
                {
                    console.Set(x + i, y, color, RLColor.Black, glyph);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Event handler for RLNET update event
        /// </summary>
        private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e)
        {
            _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, Colors.FloorBackground);
            _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, Swatch.DbOldStone);
            _statConsole.Print(1, 1, "Stats", Colors.TextHeading);

            /**
             * _invConsole.SetBackColor(0, 0, _invWidth, _invHeight, Swatch.DbWood);
             * _invConsole.Print(1, 1, "Inventory", Colors.TextHeading);
             **/

            RLKeyPress keyPress    = _rootConsole.Keyboard.GetKeyPress();
            bool       playerActed = false;

            if (keyPress != null)
            {
                if (keyPress.Key == RLKey.Up)
                {
                    playerActed = CommandSystem.MovePlayer(Direction.Up, player, DungeonMap);
                }
                else if (keyPress.Key == RLKey.Down)
                {
                    playerActed = CommandSystem.MovePlayer(Direction.Down, player, DungeonMap);
                }
                else if (keyPress.Key == RLKey.Left)
                {
                    playerActed = CommandSystem.MovePlayer(Direction.Left, player, DungeonMap);
                }
                else if (keyPress.Key == RLKey.Right)
                {
                    playerActed = CommandSystem.MovePlayer(Direction.Right, player, DungeonMap);
                }
            }
            if (playerActed)
            {
                renderRequired = true;
            }
        }
Beispiel #5
0
        // Event handler for RLNET's Render event
        private static void OnRootConsoleRender(object sender, UpdateEventArgs e)
        {
            if (_renderRequired)
            {
                _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, Colors.FloorBackground);
                _mapConsole.Print(1, 1, "Map", Colors.TextHeading);

                _messageConsole.SetBackColor(0, 0, _messageWidth, _messageHeight, Swatch.DbDeepWater);
                _messageConsole.Print(1, 1, "Messages", Colors.TextHeading);

                _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, Swatch.DbOldStone);
                _statConsole.Print(1, 1, "Stats", Colors.TextHeading);

                _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Swatch.DbWood);
                _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);

                // Draw the map
                DungeonMap.Draw(_mapConsole);

                // Draw player
                Player.Draw(_mapConsole, DungeonMap);

                // Blit the sub consoles to the root console in the correct locations
                RLConsole.Blit(_mapConsole, 0, 0, _mapWidth, _mapHeight,
                               _rootConsole, 0, _inventoryHeight);
                RLConsole.Blit(_statConsole, 0, 0, _statWidth, _statHeight,
                               _rootConsole, _mapWidth, 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();

                _renderRequired = false;
            }
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            rootConsole = new RLRootConsole("cheepicus12x12.png", rootWidth, rootHeigth, 12, 12, 1f, "TestRL");

            rootConsole.Update += OnRootConsoleUpdate;
            rootConsole.Render += OnRootConsoleRender;

            mapConsole       = new RLConsole(mapWidth, mapHeigth);
            inventoryConsole = new RLConsole(inventoryWidth, inventoryHeigth);
            logConsole       = new RLConsole(logWidth, logHeigth);
            statsConsole     = new RLConsole(statsWidth, statsHeigth);

            mapConsole.SetBackColor(0, 0, mapWidth, mapHeigth, RLColor.Black);
            //mapConsole.Print(1, 1, "Map", RLColor.White);

            logConsole.SetBackColor(0, 0, logWidth, logHeigth, RLColor.Gray);
            logConsole.Print(1, 1, "Log", RLColor.White);

            inventoryConsole.SetBackColor(0, 0, inventoryWidth, inventoryHeigth, RLColor.Brown);
            inventoryConsole.Print(1, 1, "Inventory", RLColor.White);

            statsConsole.SetBackColor(0, 0, statsWidth, statsHeigth, RLColor.Cyan);
            statsConsole.Print(1, 1, "Stats", RLColor.White);

            MapGenerator mapGenerator = new MapGenerator(mapWidth, mapHeigth);

            dungeonMap = mapGenerator.CreateCave(true);

            cmd = new Command();

            player = new Player();

            dungeonMap.UpdateFOV(player);

            rootConsole.Run();
        }
Beispiel #7
0
        public static void Main()
        {
            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);
            string fontFileName = "cp437_12x12.png";
            string consoleTitle = $"Game - Level {_mapLevel} - Seed {seed}";

            MessageLog = new MessageLog();
            MessageLog.Add("The rogue arrives...");
            MessageLog.Add($"Level created with seed '{seed}'");

            _rootConsole      = new RLRootConsole(fontFileName, _screenWidth, _screenHeight, 12, 12, 1f, consoleTitle);
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);

            SchedulingSystem = new SchedulingSystem();
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, _mapLevel);

            DungeonMap = mapGenerator.CreateMap();
            DungeonMap.UpdatePlayerFieldOfView();
            CommandSystem = new CommandSystem();

            _rootConsole.Update += OnRootConsoleUpdate;
            _rootConsole.Render += OnRootConsoleRender;

            _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, Colors.FloorBackground);
            _mapConsole.Print(1, 1, "", Colors.TextHeading);

            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Swatch.DbSky);
            _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);

            _rootConsole.Run();
        }
Beispiel #8
0
        private void DrawInventoryMenu(RLConsole console)
        {
            int currentX = 4;
            int currentY = 4;

            var inventory = this.Floor.Player.GetComponentOfType <Component_Inventory>();

            int idx = 0;

            foreach (var entity in inventory.InventoriedEntities)
            {
                RLKey useKey = (RLKey)(idx + 83);
                console.Print(currentX, currentY, useKey.ToString() + ": " + entity.Label, RLColor.Black);
                currentY += 2;

                if (currentY > Menu_Inventory.inventoryHeight - 4)
                {
                    currentX = Menu_Inventory.inventoryWidth / 2;
                    currentY = 4;
                }

                idx += 1;
            }
        }
Beispiel #9
0
        protected override void DisplayInternal(RLConsole console, IDataRogueControl display, ISystemContainer systemContainer, List <MapCoordinate> playerFov)
        {
            var size = display.Position.Size;

            var backgroundConsole = new RLConsole(size.Width, size.Height);

            CalculateLines(size, (display as LinesControl).Configuration);

            var foreColor = RLColor.White;
            var backColor = RLColor.Black;

            for (int x = 0; x < size.Width; x++)
            {
                for (int y = 0; y < size.Height; y++)
                {
                    if (_lineChars[x, y].HasValue)
                    {
                        backgroundConsole.Print(x, y, _lineChars[x, y].ToString(), foreColor, backColor);
                    }
                }
            }

            RLConsole.Blit(backgroundConsole, 0, 0, backgroundConsole.Width, backgroundConsole.Height, console, 0, 0);
        }
        public void Draw()
        {
            for (int y = 0; y <= h; y++)
            {
                console.Set(0, y, RLColor.Gray, RLColor.Black, 178);
            }
            console.Print(1, 1, "Info:", RLColor.White);
            for (int x = 0; x <= w; x++)
            {
                console.Set(x, 2, RLColor.Gray, RLColor.Black, 178);
            }
            console.Print(1, 4, "Health: ", RLColor.White);
            console.Print(8, 4, player.health.ToString(), RLColor.Red);
            Entity target = player.getTarget(engine);

            console.Print(1, 8, "Target:", RLColor.White);
            console.Print(1, 9, "Health: ", RLColor.White);
            console.Print(8, 9, target.health.ToString(), RLColor.Red);
        }
Beispiel #11
0
 public void DrawInventory(RLConsole inventoryConsole)
 {
     inventoryConsole.Print(1, 1, "Inventory", Colors.DbBrightWood);
     for (int i = 0; i < items.Count; i++)
     {
         DrawItem(items[i], inventoryConsole, i);
     }
     if (Head.Name == "None")
     {
         inventoryConsole.Print(0, 3 + (items.Count * 2), $"Head: {Head.Name}", Head == HeadEquipment.None() ? Colors.DbOldStone : Colors.DbLight);
     }
     else
     {
         inventoryConsole.Print(0, 3 + (items.Count * 2), $"Head: {Head.Name}, (+{Head.Defense} DEF)", Head == HeadEquipment.None() ? Colors.DbOldStone : Colors.DbLight);
     }
     if (Body.Name == "None")
     {
         inventoryConsole.Print(0, 3 + (items.Count * 2) + 2, $"Body: {Body.Name}", Body == BodyEquipment.None() ? Colors.DbOldStone : Colors.DbLight);
     }
     else
     {
         inventoryConsole.Print(0, 3 + (items.Count * 2) + 2, $"Body: {Body.Name}, (+{Head.Defense} DEF)", Body == BodyEquipment.None() ? Colors.DbOldStone : Colors.DbLight);
     }
     if (Hand.Name == "None")
     {
         inventoryConsole.Print(0, 3 + (items.Count * 2) + 4, $"Hand: {Hand.Name}", Hand == HandEquipment.None() ? Colors.DbOldStone : Colors.DbLight);
     }
     else
     {
         inventoryConsole.Print(0, 3 + (items.Count * 2) + 4, $"Hand: {Hand.Name}, (+{Head.Defense} DEF)", Hand == HandEquipment.None() ? Colors.DbOldStone : Colors.DbLight);
     }
     if (Feet.Name == "None")
     {
         inventoryConsole.Print(0, 3 + (items.Count * 2) + 6, $"Feet: {Feet.Name}", Feet == FeetEquipment.None() ? Colors.DbOldStone : Colors.DbLight);
     }
     else
     {
         inventoryConsole.Print(0, 3 + (items.Count * 2) + 6, $"Feet: {Feet.Name}, (+{Head.Defense} DEF)", Feet == FeetEquipment.None() ? Colors.DbOldStone : Colors.DbLight);
     }
     // Draw the controls
     inventoryConsole.Print(0, inventoryConsole.Height - 8, "numpad/arrows: move", Colors.Text);
     inventoryConsole.Print(0, inventoryConsole.Height - 6, "</>/,/.: use stairs", Colors.Text);
     inventoryConsole.Print(0, inventoryConsole.Height - 4, "1-0: use items", Colors.Text);
     inventoryConsole.Print(0, inventoryConsole.Height - 2, "L: look around, P: pick up", Colors.Text);
 }
Beispiel #12
0
        public static void Main()
        {
            //Setting the seed on base with the system time
            int seed = (int)DateTime.UtcNow.Ticks;

            Random = new DotNetRandom(seed);

            // This must be the exact name of the bitmap font file we are using or it will error.
            string fontFileName = "terminal8x8.png";

            // The title will appear at the top of the console
            //Also include the seed code in the title
            string consoleTitle = $"RougeSharp V3 Tutorial - Level {_mapLevel} - Seed {seed}";

            // Tell RLNet to use the bitmap font that we specified and that each tile is 8 x 8 pixels
            _rootConsole = new RLRootConsole(fontFileName, _screenWidth, _screenHeight,
                                             8, 8, 1f, consoleTitle);

            //Enter name

            /*_rootConsole.Print(30, 35, "What's yer name, traveler?", RLColor.White);
             * PlayerName = Console.ReadLine();
             * _rootConsole.Print(50, 35, PlayerName, RLColor.White);*/

            // Create a new MessageLog and print the random seed used to generate the level

            MessageLog = new MessageLog();
            MessageLog.Add("The rogue arrives on level 1");
            MessageLog.Add($"Level created with seed '{seed}'");

            //Initialize the sub consoles that we will Blit to the root console
            _mapConsole       = new RLConsole(_mapWidth, _mapHeight);
            _messageConsole   = new RLConsole(_messageWidth, _messageHeight);
            _statConsole      = new RLConsole(_statWidth, _statHeight);
            _inventoryConsole = new RLConsole(_inventoryWidth, _inventoryHeight);

            //Instantiete a new Schedule system
            SchedulingSystem = new SchedulingSystem();

            //Sets maps generator
            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, _mapLevel);

            DungeonMap = mapGenerator.CreateMap();

            //Updater field of view
            DungeonMap.UpdatePlayerFieldOfView();

            //Command setting in main
            CommandSystem = new CommandSystem();

            // Set up a handler for RLNET's Update event
            _rootConsole.Update += OnRootConsoleUpdate;

            // Set up a handler for RLNET's Render event
            _rootConsole.Render += OnRootConsoleRender;

            // Set background color and text for each console
            _messageConsole.SetBackColor(0, 0, _messageWidth, _messageHeight, Palette.DbDeepWater);
            _messageConsole.Print(1, 1, "Messages", Colors.TextHeading);

            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Palette.DbWood);
            _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);

            // Begin RLNET's game loop
            _rootConsole.Run();
        }
 protected override void DisplayInternal(RLConsole console, IDataRogueControl display, ISystemContainer systemContainer, List <MapCoordinate> playerFov)
 {
     console.Print(display.Position.X, display.Position.Y, $"Time: {systemContainer.TimeSystem.TimeString}", display.Color.ToRLColor(), display.BackColor.ToRLColor());
 }
        protected override void DisplayInternal(RLConsole console, IDataRogueControl display, ISystemContainer systemContainer, List <MapCoordinate> playerFov)
        {
            var entity = (display as IDataRogueInfoControl).Entity;

            console.Print(display.Position.X, display.Position.Y, entity.Get <Description>().Detail, display.Color.ToRLColor(), display.BackColor.ToRLColor());
        }
Beispiel #15
0
        protected override void DisplayInternal(RLConsole console, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov)
        {
            var formData = control as TextFormData;

            console.Print(control.Position.X, control.Position.Y, ((string)formData.Value).PadRight(30, '_'), formData.IsFocused ? RLColor.Cyan : RLColor.White);
        }
Beispiel #16
0
        public void DrawInventory(RLConsole inventoryConsole)
        {
            inventoryConsole.Print(1, 1, "Armor", RLColor.White);
            inventoryConsole.Print(1, 3, "Head: Plate", RLColor.LightGray);
            inventoryConsole.Print(1, 5, "Body: Chain", RLColor.LightGray);
            inventoryConsole.Print(1, 7, "Hand: None", RLColor.LightGray);
            inventoryConsole.Print(1, 9, "Feet: Leather", RLColor.LightGray);

            inventoryConsole.Print(28, 1, "Abilities", RLColor.White);
            inventoryConsole.Print(28, 3, "Q - Charge", RLColor.LightGray);
            inventoryConsole.Print(28, 5, "W - Whirlwind Attack", RLColor.LightGray);
            inventoryConsole.Print(28, 7, "E - Fireball", RLColor.LightGray);
            inventoryConsole.Print(28, 9, "R - Lightning Bolt", RLColor.LightGray);

            inventoryConsole.Print(55, 1, "Items", RLColor.White);
            inventoryConsole.Print(55, 3, "1 - Health Potion", RLColor.LightGray);
            inventoryConsole.Print(55, 5, "2 - Mana Potion", RLColor.LightGray);
            inventoryConsole.Print(55, 7, "3 - Scroll", RLColor.LightGray);
            inventoryConsole.Print(55, 9, "4 - Wand", RLColor.LightGray);
        }
Beispiel #17
0
        //Main Game loop
        public static void Main()
        {
            SchedulingSystem = new SchedulingSystem();
            //Generates a semi-random number from the current timestamp
            int seed = (int)DateTime.UtcNow.Ticks;

            mapSeed = seed;
            //Sets the random number to be equal to the current seed
            Random = new DotNetRandom(seed);

            //File name for the custom font (RLNet library requires custom 8x8 font)
            string fontFile = "terminal8x8.png";
            //Title included at the top of the console window
            //      UPDATE LATER TO SHOW CURRENT DUNGEON LEVEL
            string windowTitle = "Shiv - Seed: " + seed + " Level: " + mapLevel;

            //Creates a new commands to control the player
            Commands = new Commands();

            //Creates new console window using below parameters
            //(font file name, screen width, screen height, width per tile,
            //      height per tile, scale of tiles, console title)
            rootConsole = new RLRootConsole(fontFile, screenWidth, screenHeight, 8, 8, 1f, windowTitle);

            //Instantiates console subdivisions
            mapConsole       = new RLConsole(mapWidth, mapHeight);
            messageConsole   = new RLConsole(messageWidth, messageHeight);
            statsConsole     = new RLConsole(statsWidth, statsHeight);
            inventoryConsole = new RLConsole(inventoryWidth, inventoryHeight);
            armourConsole    = new RLConsole(armourWidth, armourHeight);

            //Creates a new map generator
            MapGenerator mapGenerator = new MapGenerator(mapWidth, mapHeight, 40, 14, 7, mapLevel);

            //Creates a new map using the map generator instantiated above
            DungeonMap = mapGenerator.CreateMap();
            //Updates the Player's field of view on the map
            DungeonMap.UpdatePlayerFOV();

            Inventory = new Inventory();


            //Sets background color for each subdivision of the console window
            //Prints string to label each subdivision
            mapConsole.SetBackColor(0, 0, mapWidth, mapHeight, Colors.FloorBackground);

            messageConsole.SetBackColor(0, 0, messageWidth, messageHeight, Palette.AlternateLightest);
            messageConsole.Print(1, 1, "Messages", Colors.TextHeading);
            messageConsole.Print(1, 2, "________", Colors.TextHeading);

            statsConsole.SetBackColor(0, 0, statsWidth, statsHeight, Palette.AlternateLightest);
            statsConsole.Print(1, 1, "Stats", Colors.TextHeading);
            statsConsole.Print(1, 2, "_____", Colors.TextHeading);

            statsConsole.Print(1, 21, "Enemies:", Colors.TextHeading);
            statsConsole.Print(1, 22, "________", Colors.TextHeading);

            inventoryConsole.SetBackColor(0, 0, inventoryWidth, inventoryHeight, Palette.PrimaryDarker);
            inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);
            inventoryConsole.Print(1, 2, "_________", Colors.TextHeading);
            inventoryConsole.Print(1, 5, "Slot 1: " + Inventory.slot1, Colors.TextHeading);
            inventoryConsole.Print(1, 7, "Slot 2: " + Inventory.slot2, Colors.TextHeading);
            inventoryConsole.Print(1, 9, "Slot 3: " + Inventory.slot3, Colors.TextHeading);
            inventoryConsole.Print(1, 11, "Slot 4: " + Inventory.slot4, Colors.TextHeading);
            inventoryConsole.Print(1, 13, "Slot 5: " + Inventory.slot5, Colors.TextHeading);

            armourConsole.SetBackColor(0, 0, armourWidth, armourHeight, Palette.PrimaryDarker);
            armourConsole.Print(1, 1, "Armour", Colors.TextHeading);
            armourConsole.Print(1, 2, "______", Colors.TextHeading);
            armourConsole.Print(1, 5, "Head:   " + Player.Head, Colors.TextHeading);
            armourConsole.Print(1, 7, "Neck:   " + Player.Neck, Colors.TextHeading);
            armourConsole.Print(1, 9, "Chest:  " + Player.Chest, Colors.TextHeading);
            armourConsole.Print(1, 11, "Legs:   " + Player.Legs, Colors.TextHeading);
            armourConsole.Print(1, 13, "Gloves: " + Player.Gloves, Colors.TextHeading);
            armourConsole.Print(1, 15, "Boots:  " + Player.Boots, Colors.TextHeading);
            armourConsole.Print(1, 21, "Weapon: " + Player.Weapon, Colors.TextHeading);
            armourConsole.Print(1, 23, "Shield: " + Player.Shield, Colors.TextHeading);

            //Instantiates a handler for RLNet's update event
            rootConsole.Update += OnRootConsoleUpdate;
            //Instantiates a handler for RLNet's render event
            rootConsole.Render += OnRootConsoleRender;

            //Begin the game loop
            rootConsole.Run();
        }
Beispiel #18
0
        private static void OnPauseUpdate(object sender, UpdateEventArgs e)
        {
            RLKeyPress inputKey = rootConsole.Keyboard.GetKeyPress();

            renderRequired = true;
            if (inputKey != null)
            {
                if (inputKey.Key == RLKey.Up)
                {
                    menuConsole.Print((menuConsole.Width - pauseOptions[position].Length) / 2, 40 + position * 5, pauseOptions[position], RLColor.White);
                    position--;
                    if (position == -1)
                    {
                        position = 3;
                    }
                }
                if (inputKey.Key == RLKey.Down)
                {
                    menuConsole.Print((menuConsole.Width - pauseOptions[position].Length) / 2, 40 + position * 5, pauseOptions[position], RLColor.White);
                    position++;
                    if (position == 4)
                    {
                        position = 0;
                    }
                }
                menuConsole.Print((menuConsole.Width - pauseOptions[position].Length) / 2, 40 + position * 5, pauseOptions[position], RLColor.LightRed);
                if (inputKey.Key == RLKey.Enter)
                {
                    switch (position)
                    {
                    case 0:
                    {
                        rootConsole.Update -= OnPauseUpdate;
                        rootConsole.Render -= OnMenuRender;
                        rootConsole.Update += OnGameUpdate;
                        rootConsole.Render += OnGameRender;
                        break;
                    }

                    case 1:
                    {
                        rootConsole.Update -= OnPauseUpdate;
                        rootConsole.Render -= OnMenuRender;
                        rootConsole.Update += OnGameUpdate;
                        rootConsole.Render += OnGameRender;
                        StartNewGame();
                        position = 0;
                        break;
                    }

                    case 2:
                    {
                        menuConsole.Clear();
                        rootConsole.Update -= OnPauseUpdate;
                        rootConsole.Render -= OnMenuRender;
                        rootConsole.Update += OnMenuUpdate;
                        rootConsole.Render += OnMenuRender;
                        if (File.Exists("Save.xml"))
                        {
                            File.Delete("Save.xml");
                        }
                        SerializedGame game   = new SerializedGame(true);
                        XmlWriter      writer = XmlWriter.Create("Save.xml");
                        game.WriteXml(writer);
                        writer.Close();
                        FillMenu();
                        position = 0;
                        break;
                    }

                    case 3:
                    {
                        if (File.Exists("Save.xml"))
                        {
                            File.Delete("Save.xml");
                        }
                        SerializedGame game   = new SerializedGame(true);
                        XmlWriter      writer = XmlWriter.Create("Save.xml");
                        game.WriteXml(writer);
                        writer.Close();
                        rootConsole.Close();
                        break;
                    }
                    }
                }
            }
        }
Beispiel #19
0
        private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e)
        {
            // draw the console that we setup

            //Write this code at the start too check if your console update method has actually worked first
            //_rootConsole.Print(10, 10, "It worked", RLColor.Green);

            bool       didPlayerAct = false;
            RLKeyPress keyPress     = _rootConsole.Keyboard.GetKeyPress();

            if (commandSystem.IsPlayerTurn)
            {
                //if you have pressed a key
                if (keyPress != null)
                {
                    //checks what key you have pressed if it was up down left or right and depending on the key
                    //uses the command system class too find you new position on the map
                    if (keyPress.Key == RLKey.Up)
                    {
                        didPlayerAct = commandSystem.MovePlayer(Direction.Up);
                    }
                    else if (keyPress.Key == RLKey.Down)
                    {
                        didPlayerAct = commandSystem.MovePlayer(Direction.Down);
                    }
                    else if (keyPress.Key == RLKey.Left)
                    {
                        didPlayerAct = commandSystem.MovePlayer(Direction.Left);
                    }
                    else if (keyPress.Key == RLKey.Right)
                    {
                        didPlayerAct = commandSystem.MovePlayer(Direction.Right);
                    }
                    else if (keyPress.Key == RLKey.Escape)
                    {
                        _rootConsole.Close();
                    }

                    //if player is on a stairs going down cell and presses period it will create a new map and message log and
                    //command system it will increase the map level and show it and change player act too true
                    else if (keyPress.Key == RLKey.Period)
                    {
                        if (DungeonMap.CanMoveDownToNextLevel())
                        {
                            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, ++_mapLevel);
                            DungeonMap         = mapGenerator.CreateMap();
                            messageLog         = new MessageLog();
                            commandSystem      = new CommandSystem();
                            _rootConsole.Title = $"RougeSharp - Level {_mapLevel}";
                            didPlayerAct       = true;

                            player.MaxHealth += 5;
                            player.Health     = player.MaxHealth;

                            player.Gold += 20;
                        }
                    }
                }
            }
            if (didPlayerAct)
            {
                //counts the steps player took
                //messageLog.Add($"Step # {++_steps}");

                _renderRequired = true;
                commandSystem.EndPlayerTurn();
            }
            else
            {
                commandSystem.ActivateMonsters();
                _renderRequired = true;
            }


            //set the background color and text for each console except the map and message consoles
            //_messageConsole.SetBackColor(0, 0, _messageWidth, _messageHeight, RLColor.Red);

            //_statConsole.SetBackColor(0, 0, _statWidth, _statHeight, RLColor.Red);
            //_statConsole.Print(1, 1, "Stats", Colors.TextHeading);

            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, RLColor.Cyan);
            _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);
        }
Beispiel #20
0
        protected override void DisplayInternal(RLConsole console, IDataRogueControl control, ISystemContainer systemContainer, List <MapCoordinate> playerFov)
        {
            var display = control as IDataRogueInfoControl;

            console.Print(control.Position.X, control.Position.Y, display.Parameters, display.Color.ToRLColor(), display.BackColor.ToRLColor());
        }
Beispiel #21
0
 public void DrawLoot(RLConsole inventoryConsole)
 {
     inventoryConsole.Print(1, 3, $"Zloto: {Gold}", Colors.Gold);
     inventoryConsole.Print(1, 5, $"Klejnoty: {Gems}", Colors.BeholderColor);
 }
Beispiel #22
0
        private void DrawMountsListing(RLConsole console, int x, int y)
        {
            console.Print(x, y++, "####################", RLColor.White);
            console.Print(x, y++, "#  MOUNTS LISTING  #", RLColor.White);
            console.Print(x, y++, "####################", RLColor.White);

            foreach (var entry in this.mountsDict)
            {
                console.Print(x, y, "#                  #", RLColor.White);
                console.Print(x + 2, y++, entry.Key.ToString(), RLColor.White);
                console.Print(x, y++, "#------------------#", RLColor.White);

                foreach (var mount in entry.Value)
                {
                    var    mountedEntity = mount.Item2.GetComponentOfType <Component_AttachPoint>().InspectAttachedEntity();
                    string mountedString;
                    if (mountedEntity != null)
                    {
                        mountedString = mountedEntity.ToString();
                    }
                    else
                    {
                        mountedString = "";
                    }

                    console.Print(x, y, "+                  +", RLColor.White);
                    console.Print(x + 5, y++, mount.Item2.ToString(), RLColor.White);
                    console.Print(x, y++, "| " + mount.Item1 + ") ^             |", RLColor.White);
                    console.Print(x, y, "+                  +", RLColor.White);
                    console.Print(x + 5, y++, mountedString, RLColor.White);
                    console.Print(x, y++, "|------------------|", RLColor.White);
                }
            }
        }
Beispiel #23
0
 public override void Draw(RLConsole console, int x, int y)
 {
     console.Set(x, y, Color, null, Symbols[0]);
     console.Print(x + 1, y, $" - {EffectCode}", Colors.Text);
 }
Beispiel #24
0
        // Event handler for RLNET's Update event
        private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e)
        {
            bool       didPlayerAct = false;
            RLKeyPress keyPress     = _rootConsole.Keyboard.GetKeyPress();

            if (CommandSystem.IsPlayerTurn)
            {
                if (keyPress != null)
                {
                    if (keyPress.Key == RLKey.Up)
                    {
                        didPlayerAct = CommandSystem.MovePlayer(Direction.Up);
                    }
                    else if (keyPress.Key == RLKey.Down)
                    {
                        didPlayerAct = CommandSystem.MovePlayer(Direction.Down);
                    }
                    else if (keyPress.Key == RLKey.Left)
                    {
                        didPlayerAct = CommandSystem.MovePlayer(Direction.Left);
                    }
                    else if (keyPress.Key == RLKey.Right)
                    {
                        didPlayerAct = CommandSystem.MovePlayer(Direction.Right);
                    }
                    else if (keyPress.Key == RLKey.Escape)
                    {
                        _rootConsole.Close();
                    }
                    else if (keyPress.Key == RLKey.Period)
                    {
                        if (DungeonMap.CanMoveDownToNextLevel())
                        {
                            MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, ++_mapLevel);
                            DungeonMap         = mapGenerator.CreateMap();
                            MessageLog         = new MessageLog();
                            CommandSystem      = new CommandSystem();
                            _rootConsole.Title = $"RougeSharp RLNet Tutorial - Level {_mapLevel}";
                            didPlayerAct       = true;
                        }
                    }
                }

                if (didPlayerAct)
                {
                    _renderRequired = true;
                    CommandSystem.EndPlayerTurn();
                }
            }
            else
            {
                CommandSystem.ActivateMonsters();
                _renderRequired = true;
            }


            //Set background color andd text for our consoles
            //this is temporary, btw
            _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, Colors.FloorBackground);
            _mapConsole.Print(1, 1, "Map", Colors.TextHeading);

            _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Swatch.DbWood);
            _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);
        }
 internal static void PrintStat(RLConsole statsConsole, int x, int y, string statName, string value, RLColor color)
 {
     statsConsole.Print(x, y, $"{statName}: {value}", color);
 }
Beispiel #26
0
        public void Update(RLConsole console, RLConsole statsConsole)
        {
            var posBit     = (int)Core.ComponentTypes.Position;
            var rendBit    = (int)Core.ComponentTypes.Render;
            int statBit    = (int)Core.ComponentTypes.Health;
            int detailsBit = (int)Core.ComponentTypes.CreatureDetails;
            int yPos       = 16;
            int xPos       = 2;

            Dictionary <int, int> ents = EntityManager.EntityBitLookUp;

            foreach (KeyValuePair <int, int> pair in ents)
            {
                int eid          = pair.Key;
                int furnitureRes = (int)Core.ComponentTypes.Furniture & pair.Value;
                if (furnitureRes > 0)
                {
                    Components.RenderComp   rc = (Components.RenderComp)EntityManager.GetSingleComponentByID(eid, Core.ComponentTypes.Render);
                    Components.PositionComp pc = (Components.PositionComp)EntityManager.GetSingleComponentByID(eid, Core.ComponentTypes.Position);
                    console.Set(pc.X, pc.Y, rc.Colour, Core.Colours.FloorBackground, rc.Glyph);
                }
            }

            foreach (KeyValuePair <int, int> pair in ents)
            {
                int res    = posBit & pair.Value;
                int res2   = rendBit & pair.Value;
                int actRes = (int)Core.ComponentTypes.Actor & pair.Value;

                char    renderChar = 'X';
                RLColor c          = RLColor.White;

                List <Components.Component> comps = EntityManager.GetCompsByID(pair.Key);

                if ((res > 0 && res2 > 0) && (actRes == 0))
                {
                    Components.RenderComp rendComp
                        = (Components.RenderComp)comps.Find(s => s.CompType == Core.ComponentTypes.Render);

                    Components.PositionComp posComp =
                        (Components.PositionComp)comps.Find(s => s.CompType == Core.ComponentTypes.Position);

                    if (rendComp != null && posComp != null)
                    {
                        console.Set(posComp.X, posComp.Y, rendComp.Colour,
                                    Core.Colours.FloorBackground, rendComp.Glyph);
                    }
                    if (rendComp != null)
                    {
                        renderChar = rendComp.Glyph;
                        c          = rendComp.Colour;
                    }
                }

                //draw stats
            }
            foreach (KeyValuePair <int, int> pair in ents)
            {
                // draw only actors on top
                if ((pair.Value & (int)Core.ComponentTypes.Actor) > 0)
                {
                    List <Components.Component> comps = EntityManager.GetCompsByID(pair.Key);

                    Components.RenderComp rendComp = (Components.RenderComp)comps.Find(s => s.CompType == Core.ComponentTypes.Render);

                    Components.PositionComp posComp =
                        (Components.PositionComp)comps.Find(s => s.CompType == Core.ComponentTypes.Position);
                    Components.AIComp aiComp = (Components.AIComp)comps.Find(x => x.CompType == Core.ComponentTypes.AI);

                    RLColor rColor;

                    if (aiComp.Fleeing)
                    {
                        rColor = RLColor.Red;
                    }
                    else
                    {
                        rColor = rendComp.Colour;
                    }

                    if (rendComp != null && posComp != null)
                    {
                        console.Set(posComp.X, posComp.Y, rColor,
                                    Core.Colours.FloorBackground, rendComp.Glyph);
                    }

                    int res3 = statBit & pair.Value;
                    if (res3 > 0)
                    {
                        Components.HealthComp healthStat =
                            (Components.HealthComp)comps.Find(s => s.CompType == Core.ComponentTypes.Health);

                        Components.CreatureDetailsComp detailsComp =
                            (Components.CreatureDetailsComp)comps.Find(x => x.CompType == Core.ComponentTypes.CreatureDetails);

                        Components.InventoryComp invComp = (Components.InventoryComp)comps.Find(x => x.CompType == Core.ComponentTypes.Inventory);

                        if (healthStat != null && detailsComp != null)
                        {
                            statsConsole.Print(xPos, yPos, detailsComp.PersonalName + " the " + detailsComp.Name, rendComp.Colour);
                            yPos++;
                            statsConsole.Print(xPos, yPos, rendComp.Glyph.ToString(), rendComp.Colour);
                            int width
                                = Convert.ToInt32(((double)healthStat.Health / (double)healthStat.MaxHealth) * 16);
                            int remainingWidth = 16 - width;
                            statsConsole.SetBackColor(xPos + 2, yPos, width, 1, Core.Swatch.Primary);
                            statsConsole.SetBackColor(xPos + 2 + width, yPos, remainingWidth, 1, Core.Swatch.PrimaryDarkest);
                            statsConsole.Print(xPos + 2, yPos, $": {healthStat.Health.ToString()}", Core.Swatch.DbLight);
                            yPos++;
                            if (invComp != null)
                            {
                                statsConsole.Print(xPos, yPos, $"Carrying {invComp.Treasure.Count.ToString()} Gold", rendComp.Colour);
                            }
                            yPos = yPos + 2;
                        }
                    }
                }
            }
            // stats console
            int count = 0;

            for (int yp = 0; yp < EntityManager.GetHeight(); yp++)
            {
                for (int xp = 0; xp < EntityManager.GetWidth(); xp++)
                {
                    if (EntityManager.Positions[yp, xp].Count > 0)
                    {
                        HashSet <int> ent = EntityManager.Positions[yp, xp];

                        foreach (int indvID in ent)
                        {
                            List <Components.Component> inner = EntityManager.Entities[indvID];
                            foreach (Components.Component ec in inner)
                            {
                                if (ec.CompType == Core.ComponentTypes.Collectable)
                                {
                                    count++;
                                }
                            }
                        }
                    }
                }
            }

            statsConsole.Print(1, 1, $"collectables=: {count.ToString()}", Core.Colours.TextHeading);
        }
Beispiel #27
0
 public void Blit(RLConsole console)
 {
     console.SetBackColor(0, 0, console.Width, console.Height, RLColor.Black);
     console.Print(console.Width / 2 - 4, console.Height / 2 - 1, "YOU DIED", RLColor.White);
     console.Print(console.Width / 2 - 11, console.Height / 2 + 1, "You made it to level " + this.level, RLColor.White);
 }
Beispiel #28
0
        private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e)
        {
            bool       didUnitAct    = false;
            bool       didPlayerAct  = false;
            bool       didMenuUpdate = false;
            RLKeyPress keyPress      = _rootConsole.Keyboard.GetKeyPress();

            if (_currentState == _gameStates.MainMenu)
            {
                _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, RLColor.Black);
                _mapConsole.Print(1, 1, "Press G to start a new game", Colors.TextHeading);
                renderRequired = true;

                if (keyPress != null)
                {
                    if (keyPress.Key == RLKey.G)
                    {
                        _currentState = _gameStates.InGame;
                        //on a state change we need to redraw the interface
                        guiRedraw = true;
                    }
                }

                //draw menu
            }
            else if (_currentState == _gameStates.InGame)
            {
                //handle player input when we're ingame

                if (CommandSystem.isPlayerTurn)
                {
                    if (keyPress != null)
                    {
                        switch (keyPress.Key)
                        {
                        case RLKey.Up:
                            didPlayerAct = CommandSystem.MovePlayer(Directions.Up);
                            break;

                        case RLKey.Down:
                            didPlayerAct = CommandSystem.MovePlayer(Directions.Down);
                            break;

                        case RLKey.Left:
                            didPlayerAct = CommandSystem.MovePlayer(Directions.Left);
                            break;

                        case RLKey.Right:
                            didPlayerAct = CommandSystem.MovePlayer(Directions.Right);
                            break;

                        case RLKey.Escape:
                            _rootConsole.Close();
                            break;
                        }

                        if (didPlayerAct)
                        {
                            renderRequired = true;
                            mapRedraw      = true;
                            CommandSystem.EndPlayerTurn();
                        }
                    }
                }
                else if (!CommandSystem.isPlayerTurn)
                {
                    CommandSystem.ActivateMonsters();
                    renderRequired = true;
                }

                //draw gui if not drawn
                if (guiRedraw)
                {
                    _mapConsole.Clear();
                    _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, Colors.FloorBackground);
                    mapRedraw = true;

                    _messageConsole.Clear();
                    _messageConsole.SetBackColor(0, 0, _messageWidth, _messageHeight, Swatch.DbDeepWater);


                    _statConsole.Clear();
                    _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, Swatch.DbOldStone);

                    _inventoryConsole.Clear();
                    _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Swatch.DbWood);
                    _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading);

                    renderRequired = true;
                    guiRedraw      = false;
                }

                if (mapRedraw)
                {
                    MessageLog.Draw(_messageConsole);
                    DungeonMap.Draw(_mapConsole, _statConsole);
                    Player.Draw(_mapConsole, DungeonMap);
                    Player.DrawStats(_statConsole);
                    renderRequired = true;
                    mapRedraw      = false;
                }
            }
        }
Beispiel #29
0
 public virtual void Draw(RLConsole console, int x, int y)
 {
     console.Set(x, y, Color, null, Symbols[0]);
     console.Print(x + 1, y, $" - {Quantity}", Colors.Text);
 }
        public void DrawStats(RLConsole statConsole)
        {
            statConsole.Print(1, 1, $"Title:  {Name}", Colors.Text);
            int healthWidth = Convert.ToInt32(((double)Health / (double)MaxHealth) * 16.0);

            int remainingHealthWidth = 16 - healthWidth;

            if (Status == "Poisoned")
            {
                statConsole.SetBackColor(1, 3, healthWidth, 1, RLColor.LightGreen);
            }
            else
            {
                statConsole.SetBackColor(1, 3, healthWidth, 1, RLColor.LightRed);
            }
            if (Status == "Poisoned")
            {
                statConsole.SetBackColor(1 + healthWidth, 3, remainingHealthWidth, 1, Colors.PoisonBacking);
            }
            else
            {
                statConsole.SetBackColor(1 + healthWidth, 3, remainingHealthWidth, 1, Colors.HPBacking);
            }
            if (Status == "Poisoned")
            {
                statConsole.Print(1, 3, $"HP:      {Health}/{MaxHealth}", RLColor.Green);
            }
            else
            {
                statConsole.Print(1, 3, $"HP:      {Health}/{MaxHealth}", RLColor.Red);
            }
            int manaWidth          = Convert.ToInt32(((double)Mana / (double)MaxMana) * 16.0);
            int remainingManaWidth = 16 - manaWidth;

            statConsole.SetBackColor(1, 5, manaWidth, 1, RLColor.LightBlue);
            statConsole.SetBackColor(1 + manaWidth, 5, remainingManaWidth, 1, Colors.MPBacking);
            statConsole.Print(1, 5, $"MP:      {Mana}/{MaxMana}", RLColor.Blue);

            statConsole.Print(1, 7, $"Attack:  {Attack} ({AttackChance}%)", RLColor.LightRed);
            statConsole.Print(1, 9, $"Defense: {Defense} ({DefenseChance}%)", RLColor.LightBlue);
            statConsole.Print(1, 11, $"Level:   {Level} ", RLColor.LightGreen);
            statConsole.Print(1, 13, $"To next: {Experience}", RLColor.LightGreen);
            if (Status == "Dead")
            {
                statConsole.Print(1, 15, $"Status:  {Status}", Swatch.DbBlood);
            }
            else if (Status == "Poisoned")
            {
                statConsole.Print(1, 15, $"Status:  {Status}", RLColor.Green);
            }
            else if (Status == "Stuck")
            {
                statConsole.Print(1, 15, $"Status:  {Status}", Swatch.DbBlood);
            }
            else if (Status == "Starving")
            {
                statConsole.Print(1, 15, $"Status:  {Status}", Swatch.DbBlood);
            }
            else if (Status == "Starving")
            {
                statConsole.Print(1, 15, $"Status:  {Status}", Swatch.DbBlood);
            }
            else
            {
                statConsole.Print(1, 15, $"Status:  {Status}", Colors.Gold);
            }
            statConsole.Print(1, 17, $"Gold:    {Gold}", Colors.Gold);
        }