public override void TakeAction() { if (this.NeedAndCanRecover()) { this.GameAction.DoCreatureRest(this.Creature.CreatureId); return; } // Get target FDCreature target = this.LookForAggressiveTarget(); // According to the target, find the nearest position within the Move scope, and get the path to that position FDMovePath movePath = this.DecidePositionAndPath(target.Position); // Do the walk this.GameAction.CreatureWalk(new SingleWalkAction(this.Creature.CreatureId, movePath)); FDPosition destination = movePath.Desitination ?? this.Creature.Position; AttackItemDefinition item = this.Creature.Data.GetAttackItem(); if (item != null) { FDSpan span = item.AttackScope; DirectRangeFinder finder = new DirectRangeFinder(this.GameAction.GetField(), destination, span.Max, span.Min); FDRange range = finder.CalculateRange(); if (range.Contains(target.Position)) { // If in attack range, attack the target this.GameAction.DoCreatureAttack(this.Creature.CreatureId, target.Position); } } this.GameAction.DoCreatureRest(this.Creature.CreatureId); }
public override StateOperationResult OnSelectPosition(FDPosition position) { // If position is in range if (moveRange.Contains(position)) { ClearRangePack clear = new ClearRangePack(); SendPack(clear); FDMovePath movePath = moveRange.GetPath(position); gameAction.CreatureWalk(new SingleWalkAction(creature.CreatureId, movePath)); var nextState = new MenuActionState(gameAction, creature.CreatureId, position); return(new StateOperationResult(StateOperationResult.ResultType.Push, nextState)); } else { // Cancel return(new StateOperationResult(StateOperationResult.ResultType.Pop)); } }
public void DoCreatureMove(int creatureId, FDMovePath movePath) { }
public CreatureMovePack(int creatureId, FDMovePath movePath) { this.Type = PackType.CreatureMove; this.CreatureId = creatureId; this.MovePath = movePath; }
public SingleWalkAction(int creatureId, FDPosition position, int delayUnits = 0) { this.CreatureId = creatureId; this.MovePath = FDMovePath.Create(position); this.DelayUnits = delayUnits; }
public SingleWalkAction(int creatureId, FDMovePath movePath, int delayUnits = 0) { this.CreatureId = creatureId; this.MovePath = movePath; this.DelayUnits = delayUnits; }
public CreatureMoveActivity(int creaId, FDMovePath path) { this.CreatureId = creaId; this.MovePath = path; currentVertex = 0; }