Ejemplo n.º 1
0
        public override bool PerformTask(double gameTimeInSeconds)
        {
            if (_currentTask.PerformTask(gameTimeInSeconds))
            {
                _currentTaskIndex++;
                if (_currentTaskIndex == _tasks.Count)
                    _currentTaskIndex = 0;

                _currentTask = _tasks[_currentTaskIndex];
            }

            return false;
        }
Ejemplo n.º 2
0
 public virtual void Update(double totalGameSeconds)
 {
     if (_currentTask != null)
     {
         var completedTask = _currentTask.PerformTask(totalGameSeconds);
         if (completedTask)
             _currentTask = null;
     }
     else
     {
         if (Tasks.Count == 0)
             return;
         _currentTask = Tasks.Dequeue();
     }
 }
Ejemplo n.º 3
0
        public MoveResourcesTask(Worker worker, Hex resourceSourceTile, Hex resourceDestinationTile, ResourceType shippedResourceType)
            : base(worker)
        {
            _resourceSourceTile = resourceSourceTile;
            _resourceDestinationTile = resourceDestinationTile;

            var moveToResourceSourceTileTask = new MoveToHexTask(worker, _resourceSourceTile);
            var moveToDestinationTileTask = new MoveToHexTask(worker, _resourceDestinationTile);
            var pickUpResourceTask = new PickUpResourcesTask(worker, shippedResourceType);
            var dropResourceTask = new DropResourcesTask(worker);

            _tasks = new List<Task>()
            {
                moveToResourceSourceTileTask,
                pickUpResourceTask,
                moveToDestinationTileTask,
                dropResourceTask
            };
            _currentTask = _tasks[0];
            _currentTaskIndex = 0;
        }