Пример #1
0
        public override bool Tick(TimeSpan deltaTime)
        {
            if (!(CurrentMovingTask.Tick(deltaTime) && (CurrentDestroyingTask?.Tick(deltaTime) ?? true)))
            {
                return(false);
            }

            var nearestEnemy =
                Army.World.FindNearestBuilding(
                    Army.Position,
                    Range,
                    b => b?.Owner == Enemy &&
                    Army.Constants.DestroyedBuilding != b?.Prototype);

            if (nearestEnemy == null)
            {
                return(true);
            }

            if (nearestEnemy.Position == Army.Position)
            {
                CurrentDestroyingTask = new DestroyingTask {
                    Army = Army,
                };
            }
            else
            {
                CurrentMovingTask = new MovingTask {
                    Army = Army, To = nearestEnemy.Position,
                };
            }

            return(Tick(deltaTime));
        }
Пример #2
0
 public LootTask(Army army, Vector to, int range)
 {
     CurrentMovingTask = new MovingTask {
         Army = army, To = to,
     };
     Army  = army;
     Range = range;
     Enemy = army.World.GetBuilding(to).Owner;
 }