Ejemplo n.º 1
0
 public void CurrentExecute(BaseTask task)
 {
     if (_receivers.ContainsKey(task.GetType()))
     {
         _receivers[task.GetType()].Handle(task);
     }
 }
Ejemplo n.º 2
0
 public void Update()
 {
     if (currentTask != null && currentTask.GetType() == typeof(BaseTask))
     {
         currentTask = null;                                                                  //TODO;
     }
     if (currentTask == null)
     {
         if (awaitingTasks.Count == 0)
         {
             //Laze around
         }
         else
         {
             UpdateQueue();
             StartTask(awaitingTasks[0]);
         }
     }
     else
     {
         UpdateQueue();
         currentTask.OnUpdate();
         if (currentTask.failed || currentTask.completed)
         {
             if (awaitingTasks.Count > 0)
             {
                 StartTask(awaitingTasks[0]);
             }
             else
             {
                 currentTask = null;
             }
         }
     }
 }
Ejemplo n.º 3
0
 public void Execute()
 {
     if (_tasks.Count > 0)
     {
         BaseTask task = _tasks.Dequeue();
         _receivers[task.GetType()].Handle(task);
     }
 }
Ejemplo n.º 4
0
        public void CreateTask(BaseTask baseTask)
        {
            XmlSerializer xs   = default(XmlSerializer);
            string        path = $"..\\Db\\tasks\\";

            if (baseTask.GetType() == typeof(MarketPlaceTask))
            {
                xs    = new XmlSerializer(typeof(MarketPlaceTask));
                path += "MarketPlaceTask\\";
            }
            else if (baseTask.GetType() == typeof(OrganizationTask))
            {
                xs    = new XmlSerializer(typeof(OrganizationTask));
                path += "OrganizationTask\\";
            }

            Directory.CreateDirectory(Path.GetDirectoryName(path));
            StreamWriter txtWriter = new StreamWriter($"{path}task_{baseTask.TaskId}.xml");

            xs.Serialize(txtWriter, baseTask);
            txtWriter.Close();
        }
Ejemplo n.º 5
0
    public virtual void Update()
    {
        for (int i = 0; i < m_Tasks.Count; ++i)
        {
            BaseTask current = m_Tasks[i];
            if (current.IsDone() == false)
            {
                current.Update();
            }
        }

        for (int i = m_Tasks.Count - 1; i >= 0; --i)
        {
            BaseTask current = m_Tasks[i];
            if (current.IsDone() == true)
            {
                // Task complete, remove from list.
                Debug.Log("Task " + current.GetType() + " complete, removing from task list.");
                m_Tasks.RemoveAt(i);
            }
        }
    }