public override bool UseTactic(IGameEngineCore engine, Monster monster) { if (IsPlayerVisible(engine, monster)) { List<Point> pathToPlayer = GetPathToPlayer(engine, monster); if (IsNextToPlayer(engine, pathToPlayer)) { if (AttackPlayer(engine, monster)) return true; } if (HasPathToPlayer(engine, pathToPlayer)) { if (MoveOnPath(engine, pathToPlayer, monster)) return true; } } else { if (WalkTowardsLastKnownPosition(engine, monster)) return true; } WanderRandomly(engine, monster); // We have nothing else to do, so wander return true; }
protected int GetPathToPlayerLength(IGameEngineCore engine, Monster monster) { List<Point> pathToPlayer = GetPathToPlayer(engine, monster); if (pathToPlayer == null) return -1; return pathToPlayer.Count; }
public override bool UseTactic(IGameEngineCore engine, Monster monster) { bool usedSkill = engine.MonsterSkillEngine.UseSkill(monster, MonsterSkillType.SlingStone, engine.Player.Position); if (usedSkill) UsedCooldown(monster, CooldownName, CooldownAmount); return usedSkill; }
private bool MoveCore(IGameEngineCore engine, Direction direction, Monster monster) { if (engine.Move(monster, direction)) return true; Point position = PointDirectionUtils.ConvertDirectionToDestinationPoint(monster.Position, direction); if (monster.Intelligent && engine.Operate(monster, position)) return true; return false; }
public override bool CouldUseTactic(IGameEngineCore engine, Monster monster) { if (CanUseCooldown(monster, CooldownName)) { int range = GetPathToPlayer(engine, monster).Count; if (range > 2) return true; } return false; }
public override bool CouldUseTactic(IGameEngineCore engine, Monster monster) { // If see an ally who's wounded (I have something to do) List<Character> nearbyAllies = OtherNearbyEnemies(engine, monster); foreach (Character allyNeedingHealing in nearbyAllies.Where(x => x.CurrentHP < x.MaxHP).OrderBy(x => x.CurrentHP)) { List<Point> pathToAlly = GetPathToCharacter(engine, monster, allyNeedingHealing); if (pathToAlly != null && pathToAlly.Count > 1) return true; } return false; }
public override bool CouldUseTactic(IGameEngineCore engine, Monster monster) { List<Character> nearbyAllies = OtherNearbyEnemies(engine, monster); if (nearbyAllies.Count > 0 && CanUseCooldown(monster, CooldownName)) { foreach (Character allyNeedingHealing in nearbyAllies.Where(x => x.CurrentHP < x.MaxHP).OrderBy(x => x.CurrentHP)) { List<Point> pathToAlly = GetPathToCharacter(engine, monster, allyNeedingHealing); if (pathToAlly != null && pathToAlly.Count <= 1) return true; } } return false; }
protected bool WalkTowardsLastKnownPosition(IGameEngineCore engine, Monster monster) { if (monster.PlayerLastKnownPosition == Point.Invalid) return false; List<Point> pathTowards = engine.PathToPoint(monster, monster.PlayerLastKnownPosition, monster.Intelligent, false, true); if (pathTowards == null || pathTowards.Count == 0) { monster.PlayerLastKnownPosition = Point.Invalid; return false; } else { return MoveOnPath(engine, pathTowards, monster); } }
public override bool UseTactic(IGameEngineCore engine, Monster monster) { List<Character> nearbyAllies = OtherNearbyEnemies(engine, monster); if (nearbyAllies.Count > 0 && CanUseCooldown(monster, CooldownName)) { foreach (Character allyNeedingHealing in nearbyAllies.Where(x => x.CurrentHP < x.MaxHP).OrderBy(x => x.CurrentHP)) { List<Point> pathToAlly = GetPathToCharacter(engine, monster, allyNeedingHealing); if (pathToAlly != null && pathToAlly.Count <= 1) { engine.MonsterSkillEngine.UseSkill(monster, MonsterSkillType.FirstAid, allyNeedingHealing.Position); UsedCooldown(monster, CooldownName, CooldownAmount); return true; } } } return false; }
public override bool UseTactic(IGameEngineCore engine, Monster monster) { if (s_random.Chance(50)) return MoveTowardsPlayer(engine, monster); return false; }
protected bool MoveOnPath(IGameEngineCore engine, List<Point> path, Monster monster) { Direction nextPosition = PointDirectionUtils.ConvertTwoPointsToDirection(monster.Position, path[0]); return MoveCore(engine, nextPosition, monster); }
public abstract bool UseTactic(IGameEngineCore engine, Monster monster);
protected bool MoveTowardsPlayer(IGameEngineCore engine, Monster monster) { return MoveOnPath(engine, GetPathToPlayer(engine, monster), monster); }
protected bool AreOtherNearbyEnemies(IGameEngineCore engine, Monster monster) { return OtherNearbyEnemies(engine, monster).Count() > 1; }
public override bool CouldUseTactic(IGameEngineCore engine, Monster monster) { return GetPathToPlayerLength(engine, monster) == 2; }
public EffectEngine(IGameEngineCore engine) { m_engine = engine; }
public override bool UseTactic(IGameEngineCore engine, Monster monster) { if (AreOtherNearbyEnemies(engine, monster)) return MoveAwayFromPlayer(engine, monster); return false; }
protected bool IsNextToPlayer(IGameEngineCore engine, Monster monster) { return GetPathToPlayerLength(engine, monster) == 1; }
protected List<Point> GetPathToPlayer(IGameEngineCore engine, Monster monster) { return engine.PathToPoint(monster, engine.Player.Position, monster.Intelligent, false, true); }
protected bool WanderRandomly(IGameEngineCore engine, Monster monster) { foreach (Direction d in DirectionUtils.GenerateRandomDirectionList()) { if (engine.Move(monster, d)) return true; } // If nothing else, 'wait' engine.Wait(monster); return false; }
protected bool IsPlayerVisible(IGameEngineCore engine, Monster monster) { return engine.FOVManager.VisibleSingleShot(engine.Map, monster.Position, monster.Vision, engine.Player.Position); }
public override bool CouldUseTactic(IGameEngineCore engine, Monster monster) { return IsNextToPlayer(engine, monster); }
protected bool MoveAwayFromPlayer(IGameEngineCore engine, Monster monster) { Direction directionTowardsPlayer = PointDirectionUtils.ConvertTwoPointsToDirection(monster.Position, engine.Player.Position); if (MoveCore(engine, PointDirectionUtils.GetDirectionOpposite(directionTowardsPlayer), monster)) return true; foreach (Direction attemptDirection in PointDirectionUtils.GetDirectionsOpposite(directionTowardsPlayer)) { if (MoveCore(engine, attemptDirection, monster)) return true; } return false; }
protected bool HasPathToPlayer(IGameEngineCore engine, List<Point> pathToPlayer) { return pathToPlayer != null && pathToPlayer.Count > 0; }
public override bool UseTactic(IGameEngineCore engine, Monster monster) { return engine.MonsterSkillEngine.UseSkill(monster, MonsterSkillType.Rush, engine.Player.Position); }
protected bool AttackPlayer(IGameEngineCore engine, Monster monster) { if (engine.Attack(monster, engine.Player.Position)) return true; return false; }
protected bool IsNextToPlayer(IGameEngineCore engine, List<Point> pathToPlayer) { return pathToPlayer != null && pathToPlayer.Count == 1; }
protected List<Character> OtherNearbyEnemies(IGameEngineCore engine, Monster monster) { return engine.MonstersInCharactersLOS(monster).Where(x => PointDirectionUtils.NormalDistance(x.Position, engine.Player.Position) < 4).OfType < Character>().ToList(); }
public override bool CouldUseTactic(IGameEngineCore engine, Monster monster) { return true; }
protected void UpdateKnownPlayerLocation(IGameEngineCore engine) { PlayerLastKnownPosition = engine.Player.Position; }