예제 #1
0
        public void DoTasks(float dT)
        {
            if (CurrentTask == null)
            {
                if (Tasks.Count > 0)
                {
                    if (GameScenes.MainGame.DebugKeyDown)
                    {
                    }
                    StartTask(Tasks.Dequeue());
                }
                return;
            }
            if (this.CurrentTask.Description != null)
            {
                this.Description = this.CurrentTask.Description;
                if (this.CurrentTask as Components.Tasks.ComplexTask != null && (this.CurrentTask as Components.Tasks.ComplexTask).CurrentTask != null)
                {
                    this.Description += ": " + (this.CurrentTask as Tasks.ComplexTask).CurrentTask.Description ?? "unspecified work";
                }
            }

            switch (CurrentTask.State)
            {
            case TaskState.Complete:
            {
                Console.Write(this.Name + " completed " + this.CurrentTask.Description + ".");
                CurrentTask.CompletedAction?.Invoke();
                CurrentTask = null;
                if (Tasks.Count > 0)
                {
                    StartTask(Tasks.Dequeue());
                }
                break;
            }

            case TaskState.InProgress:
            {
                CurrentTask.Progress(dT);
                break;
            }

            case TaskState.Suspended:
            {
                CurrentTask.State = TaskState.Enqueued;
                //
                CurrentTask.Actor = null;
                Console.Write(this.Name + " cancels " + this.CurrentTask.Description + ": " + CurrentTask.SuspendReason);
                //CurrentTask.SuspendReason = "";
                ParentMap.AvailableTasks.Add(CurrentTask);
                CurrentTask = null;
                break;
            }
            }
        }
예제 #2
0
        public void StartTask(ITask task)
        {
            //TODO: add code to actually check if a task can be done at all
            if (task.SuspendReason != null)
            {
            }
            CurrentTask = task;
            task.State  = TaskState.InProgress;

            task.Initialize();
            int a = 1;
        }
예제 #3
0
 public Interfaces.ITask GetTask(Interfaces.IActor actor)
 {
     Interfaces.ITask result = null;
     foreach (Interfaces.ITask task in AvailableTasks)
     {
         if (actor.CanDo(task))
         {
             if (result == null || result.Priority < task.Priority)
             {
                 result = task;
             }
         }
     }
     AvailableTasks.Remove(result);
     return(result);
 }
예제 #4
0
 public void DeleteTask(Interfaces.ITask task)
 {
     ((AdTask)task).Delete();
 }
예제 #5
0
        public void UpdateTask(Interfaces.ITask task)
        {
            AdTask t = (AdTask)task;

            _Service.Save(t.GetUpdate());
        }
예제 #6
0
 public void DeleteTask(Interfaces.ITask task)
 {
     _Service.RemoveElement((XmlTask)task);
 }
예제 #7
0
 public void UpdateTask(Interfaces.ITask task)
 {
     _Service.Save((XmlTask)task);
 }
예제 #8
0
 internal Task(Interfaces.ITask task, Application parent)
     : this(task)
 {
     Parent = parent;
 }
예제 #9
0
 internal Task(Interfaces.ITask task)
 {
     Instance = task;
 }