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); }
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); }
private bool CheckMovement() { ICellAction action = (ICellAction)player.Actions.Find(x => x.Name == "Walk"); ICell cell = map.GetAdjacentCell(player.X, player.Y, lastDirection); bool succ = action.Execute(cell); if (succ) { if (GameController.CurrentMap.CanMoveDownToNextLevel()) { GameController.ChangeLevel(true); succ = false; } else if (GameController.CurrentMap.CanMoveUpToPreviousLevel()) { GameController.ChangeLevel(false); succ = false; } } return(succ); }
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); }