Ejemplo n.º 1
0
 private bool Normal(RLKey key)
 {
     if (IsPressed(RLKey.Keypad5))
     {
         ISelfAction action = (ISelfAction)player.Actions.Find(x => x.Name == "Wait");
         return(action.Execute());
     }
     else if (MovementPressed())
     {
         return(CheckMovement());
     }
     else if (IsPressed(RLKey.Comma))
     {
         Item item = GameController.CurrentMap.GetItemAt(player.X, player.Y);
         GameController.CurrentMap.RemoveItem(item);
         GameController.InventorySystem.AddItem(item);
     }
     else if (IsPressed(RLKey.I))
     {
         InventoryScreen inventoryScreen = new InventoryScreen(false, true, _rootConsole);
         inventoryScreen.Init();
         Game.GameStack.Push(inventoryScreen);
     }
     SystemKeys(key);
     return(false);
 }
Ejemplo n.º 2
0
 private bool MediumAttack(RLKey key)
 {
     if (IsPressed(RLKey.Keypad5))
     {
         ISelfAction action = (ISelfAction)player.Actions.Find(x => x.Name == "Wait");
         return(action.Execute());
     }
     else if (MovementPressed())
     {
         ICellAction action = (ICellAction)player.Actions.Find(x => x.Name == "Slash");
         return(action.Execute(map.GetCell(player.X, player.Y), lastDirection));
     }
     return(false);
 }
Ejemplo n.º 3
0
        public bool Act(Monster monster)
        {
            Initialize();

            monsterFov.ComputeFov(monster.X, monster.Y, monster.Awareness, true);
            if (monsterFov.IsInFov(player.X, player.Y))
            {
                if (path == null)
                {
                    GameController.MessageLog.Add($"{monster.Name} is eager to fight {player.Name}");
                }
                path = CreatePath(monster);
            }
            else if (!TurnsSincePF.HasValue)
            {
                path = CreatePath(monster);
            }

            if (path != null)
            {
                try
                {
                    ICell currentCell = dungeonMap.GetCell(monster.X, monster.Y);
                    if (path.Length == 2)
                    {
                        ICellAction action = (ICellAction)monster.Actions.Find(x => x.Tags.Any(y => y == ActionTag.Melee));
                        action.Execute(currentCell, dungeonMap.GetDirection(currentCell, path.StepForward()));
                    }
                    else
                    {
                        ICellAction action = (ICellAction)monster.Actions.Find(x => x.Name == "Walk");
                        action.Execute(path.StepForward());
                    }
                }
                catch (NoMoreStepsException)
                {
                    ISelfAction action = (ISelfAction)monster.Actions.Find(x => x.Tags.Any(y => y == ActionTag.Pass));
                    action.Execute();
                }
            }
            TurnsSincePF++;
            if (TurnsSincePF > resetTime)
            {
                TurnsSincePF = null;
            }

            return(true);
        }
Ejemplo n.º 4
0
        private Path CreatePath(Monster monster)
        {
            Path path = null;

            try
            {
                path = GetPath(monster.X, monster.Y, player.X, player.Y);
            }
            catch (PathNotFoundException)
            {
                ISelfAction action = (ISelfAction)monster.Actions.Find(x => x.Tags.Any(y => y == ActionTag.Pass));
                action.Execute();
            }
            TurnsSincePF = 0;
            return(path);
        }
        public bool Act(Monster monster)
        {
            Initialize();
            // If the monster has not been alerted, compute a field-of-view
            // Use the monster's Awareness value for the distance in the FoV check
            // If the player is in the monster's FoV then alert it
            // Add a message to the MessageLog regarding this alerted status
            if (!monster.TurnsAlerted.HasValue)
            {
                monsterFov.ComputeFov(monster.X, monster.Y, monster.Awareness, true);
                if (monsterFov.IsInFov(player.X, player.Y))
                {
                    GameController.MessageLog.Add($"{monster.Name} is eager to fight {player.Name}");
                    monster.TurnsAlerted = 1;
                }
            }

            if (monster.TurnsAlerted.HasValue)
            {
                try
                {
                    path = GetPath(monster.X, monster.Y, player.X, player.Y);
                }
                catch (PathNotFoundException)
                {
                    ISelfAction action = (ISelfAction)monster.Actions.Find(x => x.Tags.Any(y => y == ActionTag.Pass));
                    action.Execute();
                }

                // In the case that there was a path, tell the monster to move
                if (path != null)
                {
                    try
                    {
                        if (path.Length == 2)
                        {
                            ICellAction action = (ICellAction)monster.Actions.Find(x => x.Tags.Any(y => y == ActionTag.Melee));
                            action.Execute(path.StepForward());
                        }
                        else
                        {
                            ICellAction action = (ICellAction)monster.Actions.Find(x => x.Name == "Walk");
                            action.Execute(path.StepForward());
                        }
                    }
                    catch (NoMoreStepsException)
                    {
                        GameController.MessageLog.Add($"{monster.Name} growls in frustration");
                    }
                }

                monster.TurnsAlerted++;

                // Lose alerted status every 15 turns.
                // As long as the player is still in FoV the monster will stay alert
                // Otherwise the monster will quit chasing the player.
                if (monster.TurnsAlerted > 15)
                {
                    monster.TurnsAlerted = null;
                }
            }
            return(true);
        }