コード例 #1
0
        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);
        }
コード例 #2
0
        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));
            }
        }
コード例 #3
0
 public void DoCreatureMove(int creatureId, FDMovePath movePath)
 {
 }
コード例 #4
0
 public CreatureMovePack(int creatureId, FDMovePath movePath)
 {
     this.Type       = PackType.CreatureMove;
     this.CreatureId = creatureId;
     this.MovePath   = movePath;
 }
コード例 #5
0
ファイル: IGameAction.cs プロジェクト: Toneyisnow/windingtale
 public SingleWalkAction(int creatureId, FDPosition position, int delayUnits = 0)
 {
     this.CreatureId = creatureId;
     this.MovePath   = FDMovePath.Create(position);
     this.DelayUnits = delayUnits;
 }
コード例 #6
0
ファイル: IGameAction.cs プロジェクト: Toneyisnow/windingtale
 public SingleWalkAction(int creatureId, FDMovePath movePath, int delayUnits = 0)
 {
     this.CreatureId = creatureId;
     this.MovePath   = movePath;
     this.DelayUnits = delayUnits;
 }
コード例 #7
0
 public CreatureMoveActivity(int creaId, FDMovePath path)
 {
     this.CreatureId = creaId;
     this.MovePath   = path;
     currentVertex   = 0;
 }