Example #1
0
 static void RemoveTaskFromPool(string data)
 {
     currentExecutingTask.OnComplete -= RemoveTaskFromPool;
     taskPool.Remove(currentExecutingTask);
     currentExecutingTask = null;
     ExecuteFirstTask();
 }
Example #2
0
 static void Init()
 {
     if (ready)
     {
         return;
     }
     savedTaskes          = new List <SerializedTask>();
     taskPool             = new List <GameTask>();
     currentExecutingTask = null;
     Ready();
 }
Example #3
0
 static void ExecuteFirstTask()
 {
     if (taskPool.Count == 0)
     {
         if (OnScheduleFinished != null)
         {
             OnScheduleFinished.Invoke(currentScheduleID);
         }
         return;
     }
     currentExecutingTask             = taskPool[0];
     currentExecutingTask.OnComplete += RemoveTaskFromPool;
     currentExecutingTask.Execute();
 }
Example #4
0
 public static string Schedule(GameTask task)
 {
     if (!ready)
     {
         Init();
     }
     taskPool.Add(task);
     if (currentExecutingTask == null)
     {
         ExecuteFirstTask();
         currentScheduleID = Guid.NewGuid().ToString();
     }
     return(currentScheduleID);
 }
Example #5
0
        public override void Execute()
        {
            Debug.Log("____ UpdateOfflineTasks: ____");
            Type type = Type.GetType(serializedTask.classType); //target type

            Debug.Log("type: " + type + " - data: " + serializedTask.data);
            object instanceObject = Activator.CreateInstance(type, new object[] { serializedTask.data }); // an instance of target type

            gameTask = (GameTask)instanceObject;

            gameTask.id = serializedTask.id;
            gameTask.SetAdditionalData(serializedTask.additionalData);
            gameTask.executionTime = DateTime.Parse(serializedTask.executionTime);
            gameTask.OnComplete   += MoveNext;
            gameTask.OnError      += RetryTask;
            gameTask.Execute();
        }
Example #6
0
 void SaveTask(GameTask task)
 {
     if (!ready)
     {
         Init();
     }
     Debug.Log("Saving Task");
     if (savedTaskes == null)
     {
         savedTaskes = new List <SerializedTask>();
     }
     savedTaskes.Add(new SerializedTask()
     {
         id             = task.id,
         classType      = task.GetType().FullName,
         data           = task.GetData(),
         additionalData = task.additionalData,
         executionTime  = task.executionTime.ToString(),
     });
     SaveAllTasks(savedTaskes);
 }