Beispiel #1
0
        internal void Attack(Actor attacker, Actor defender)
        {
            // Roll to hit
            int attackRoll = GoRogue.DiceNotation.Dice.Roll("1d20");

            if (attackRoll > 5) // TODO: make this a value based on the defender's AC
            {
                int damageRoll = GoRogue.DiceNotation.Dice.Roll("1d6");
                defender.Energy.ConsumeEnergy(damageRoll); // Damage is dealt to energy
                if (!defender.Energy.HasEnergy())
                {
                    logger.LogMessage($"Hit for {damageRoll} damage, defeating the enemy!");
                }
                else
                {
                    logger.LogMessage($"Hit for {damageRoll} damage!");
                }
            }
            else
            {
                logger.LogMessage($"Your attack missed!");
            }
        }
Beispiel #2
0
        private static void Init()
        {
            Console messageConsole = new Console(
                DisplayWidth - BottomConsoleWidth,
                BottomConsoleHeight);

            messageConsole.Position = new Point(BottomConsoleWidth, DisplayHeight - BottomConsoleHeight);

            GameMessageLogger logger        = new GameMessageLogger(messageConsole);
            EntityManager     entityManager = new EntityManager();
            Console           parentConsole = new Console(DisplayWidth, DisplayHeight);

            // Generate a map
            int mapWidth = DisplayWidth * 2, mapHeight = DisplayHeight * 2;

            map = new Level(mapWidth, mapHeight, logger, entityManager);

            levelConsole = new Console(
                mapWidth,
                mapHeight,
                Global.FontDefault,
                new Rectangle(0, 1, DisplayWidth, DisplayHeight - BottomConsoleHeight),
                map.GetCells());

            parentConsole.Children.Add(levelConsole);

            energyConsole = new Console(
                BottomConsoleWidth,
                BottomConsoleHeight);
            energyConsole.Position = new Point(0, DisplayHeight - BottomConsoleHeight);
            parentConsole.Children.Add(energyConsole);

            RenderPlayerEnergy();

            parentConsole.Children.Add(messageConsole);

            // Set the player
            levelConsole.Children.Add(entityManager);
            levelConsole.CenterViewPortOnPoint(map.Player.RenderEntity.Position);

            // Set our new console as the thing to render and process
            SadConsole.Global.CurrentScreen = parentConsole;

            logger.LogMessage("Tread lightly.");
        }