Example #1
0
 public int FindEarlierIncompleteTaskIndex(int taskIndex)
 {
     for (int i = taskIndex - 1; i >= 0; i--)
     {
         PowerTask task = this.m_tasks[i];
         if (!task.IsCompleted())
         {
             return(i);
         }
     }
     return(-1);
 }
Example #2
0
    public void DoTasks(int startIndex, int count, CompleteCallback callback, object userData)
    {
        bool flag           = false;
        int  taskStartIndex = -1;
        int  taskEndIndex   = Mathf.Min((int)((startIndex + count) - 1), (int)(this.m_tasks.Count - 1));

        for (int i = startIndex; i <= taskEndIndex; i++)
        {
            PowerTask task = this.m_tasks[i];
            if (!task.IsCompleted())
            {
                if (taskStartIndex < 0)
                {
                    taskStartIndex = i;
                }
                if (ZoneMgr.IsHandledPower(task.GetPower()))
                {
                    flag = true;
                    break;
                }
            }
        }
        if (taskStartIndex < 0)
        {
            taskStartIndex = startIndex;
        }
        if (flag)
        {
            ZoneChangeCallbackData data = new ZoneChangeCallbackData {
                m_startIndex       = startIndex,
                m_count            = count,
                m_taskListCallback = callback,
                m_taskListUserData = userData
            };
            this.m_zoneChangeList = ZoneMgr.Get().AddServerZoneChanges(this, taskStartIndex, taskEndIndex, new ZoneMgr.ChangeCompleteCallback(this.OnZoneChangeComplete), data);
            if (this.m_zoneChangeList != null)
            {
                return;
            }
        }
        if (Gameplay.Get() != null)
        {
            Gameplay.Get().StartCoroutine(this.WaitForGameStateAndDoTasks(taskStartIndex, taskEndIndex, startIndex, count, callback, userData));
        }
        else
        {
            this.DoTasks(taskStartIndex, taskEndIndex, startIndex, count, callback, userData);
        }
    }