示例#1
0
    public static TaskBundle CreateABundleInstance()
    {
        TaskBundle ret = new TaskBundle();

        TaskBundleHelper.TryInitalizeBundleInstance(ret);
        return(ret);
    }
示例#2
0
    public void AddTask()
    {
        Debug.LogWarning("AddTask");

        if (null == m_AddTaskInterfaceHelper)
        {
            return;
        }

        {
            TaskBundle bundle = TaskBundleHelper.CopyFromAddTaskInterfaceHelper(m_AddTaskInterfaceHelper);
            // prepare bundle to upload string
            TaskAddRequest req = new TaskAddRequest();
            req.RequestSerial = m_RequestSerial++;
            req.UpdateSerial  = TaskMauerStaticData.GetUpdateSerial();
            req.ProjectKey    = m_ProjectKey;
            req.Task          = bundle;

            m_RequestList.Add(m_RequestSerial, req);

            StartCoroutine(StartRequestTaskAdd(req));
        }

        m_AddTaskInterfaceHelper.gameObject.SetActive(false);
    }
示例#3
0
    public void ConfirmModifyTask()
    {
        Debug.LogWarning("ConfirmModifyTask");
        if (null == m_ModifyTaskInterfaceHelper)
        {
            return;
        }

        TaskBundle bundle = TryFindTaskData(m_SelectedObjTaskID);

        if (null != bundle)
        {
            // uploading apply change to task
            TaskBundle modifyBundle = TaskBundleHelper.CopyFromModifyTaskInterfaceHelper(m_ModifyTaskInterfaceHelper, bundle);

            TaskAddRequest fetchReq = new TaskAddRequest();
            fetchReq.UpdateSerial = TaskMauerStaticData.GetUpdateSerial();
            fetchReq.ProjectKey   = m_ProjectKey;
            fetchReq.Task         = modifyBundle;

            StartCoroutine(StartRequestModifyTask(fetchReq));
        }

        HideModifyTaskInterface();
    }
示例#4
0
    void SetTaskVisual3DFromBundle(GameObject obj, TaskBundle bundle)
    {
        if (null == obj)
        {
            return;
        }

        if (null == bundle)
        {
            return;
        }


        if (bundle.Relation.ParentID != 0)
        {
            TaskVisualObj visualParent = TryFindTaskVisual(bundle.Relation.ParentID);
            if (null != visualParent)
            {
                obj.transform.SetParent(visualParent.m_3DObj.transform);
            }
        }

        if (bundle.Visual.PositionStr != string.Empty)
        {
            obj.transform.localPosition = TaskBundleHelper.ParsePositionStr(bundle.Visual.PositionStr);
        }
    }
示例#5
0
    void UpdateTaskBundle(TaskBundle inputBundle)
    {
        if (null == inputBundle)
        {
            return;
        }

        int           taskID           = inputBundle.Data.TaskID;
        TaskBundle    previousBundle   = TryFindTaskData(taskID);
        TaskVisualObj previousVisual   = TryFindTaskVisual(taskID);
        TaskBundle    targetBundleData = null;

        if (null == previousVisual || null == previousBundle)
        {
            if (null != previousVisual || null != previousBundle)
            {
                // fatal error.
                return;
            }
        }

        if (null != previousBundle)
        {
            Debug.LogWarning("null != previousBundle");
            targetBundleData = previousBundle;

            TaskBundleHelper.CopyBundle(inputBundle, targetBundleData);

            // update visual data
            SetTaskVisualDataFromBundle(previousVisual.m_2DHelper, targetBundleData);

            // update position
            SetTaskVisual3DFromBundle(previousVisual.m_3DObj, targetBundleData);
        }
        else
        {
            Debug.LogWarning("new bundle data");

            targetBundleData = TaskBundleHelper.CreateABundleInstance();

            TaskBundleHelper.CopyBundle(inputBundle, targetBundleData);

            CheckAndCreateTaskObj(targetBundleData);
            AddTask(targetBundleData);
            AddTaskCalculatorFromTaskBundle(targetBundleData);
        }
    }
    void CalculateUnAssignedVisualTask()
    {
        // create helper for all tasks.
        m_TaskCalculator.Clear();

        {
            var taskI = m_TaskData.GetEnumerator();
            while (taskI.MoveNext())
            {
                InsertTaskPositionHelper(taskI.Current.Value);
            }
        }

        // calculate the parent depth
        CalculateParentDepth(m_TaskCalculator);

        CalculateXSpaceForAllTasks(m_TaskData, m_TaskCalculator);

        {
            var taskK = m_TaskData.GetEnumerator();
            while (taskK.MoveNext())
            {
                var data = taskK.Current.Value;
                m_TaskCalculator[data.Data.TaskID].IsSetPosition = (data.Visual.PositionStr != string.Empty);
                var visual = TryFindTaskVisual(data.Data.TaskID);
                visual.m_3DObj.transform.localPosition = TaskBundleHelper.ParsePositionStr(data.Visual.PositionStr);
            }
        }

        CheckAllRowIndexArray();

        List <int> parentIDSet = new List <int>();

        // collect parent id
        {
            var taskL = m_TaskData.GetEnumerator();
            while (taskL.MoveNext())
            {
                var data        = taskL.Current.Value;
                int taskParenID = m_TaskCalculator[data.Data.TaskID].Bundle.Relation.ParentID;
                if (taskParenID != 0)
                {
                    if (-1 == parentIDSet.IndexOf(m_TaskCalculator[data.Data.TaskID].Bundle.Relation.ParentID))
                    {
                        parentIDSet.Add(taskParenID);
                    }
                }
            }
        }

        Dictionary <float, List <int> > sortedForEachParent = new Dictionary <float, List <int> >();

        // for each parent id
        {
            var parentIDEnum = parentIDSet.GetEnumerator();
            while (parentIDEnum.MoveNext())
            {
                List <int> taskInTheSameParentID = CreateSortingArrayForParentIDSet(m_TaskData, parentIDEnum.Current);
                sortedForEachParent.Add(parentIDEnum.Current, taskInTheSameParentID);
            }
        }

        // according to each sorted list, assigned position
        foreach (var row in sortedForEachParent.Values)
        {
            SetParentAndLocalPositionInArray(m_TaskData, m_TaskCalculator, row);
        }

        Dictionary <int, List <int> > sortedForEachYRow = new Dictionary <int, List <int> >();

        // for each row index
        {
            var rowIndex = m_RowIndiceSet.GetEnumerator();
            while (rowIndex.MoveNext())
            {
                List <int> taskInTheSameRow = CreateSortingArrayForEachRowIndex(m_TaskData, m_TaskCalculator, rowIndex.Current);
                sortedForEachYRow.Add(rowIndex.Current, taskInTheSameRow);
            }
        }

        float tempY = 0;

        // according to each sorted list, assigned position
        foreach (var row in sortedForEachYRow)
        {
            m_RowToPosY.Add(row.Key, tempY);

            float maxYSpace = 0;
            SetLocalPositionInArray(row.Value, tempY, out maxYSpace);
            tempY += maxYSpace;
        }
        m_RowMaxYNow = tempY;
    }
示例#7
0
    void InitalizeLocalTestData()
    {
        int id = 0;

        /*
         ### Task1
         ### Task2 Member1
         ### Task3 parent Task2
         ### Task4 relative Task1
         ### Task5 Member2
         ### Task6 Member3
         ### Task7 parent Task3
         ### Task8 PositionStr
         ### Task9 parent Task3 PositionStr
         ### Task10 follow Task4
         ###
         */
        ++id;         // zero is not a valid taskid
        int task1ID = 0;
        int task2ID = 0;
        int task3ID = 0;

        {
            TaskBundle bundleData = TaskBundleHelper.CreateABundleInstance();
            bundleData.Data.TaskID = id++;
            task1ID = bundleData.Data.TaskID;
            bundleData.Data.Title = "Task1";
            bundleData.Data.Link  = "www.google.com.tw";
            bundleData.Data.Type  = (int)TaskType.Art;
            CheckAndCreateTaskObj(bundleData);
            AddTask(bundleData);
        }
        {
            TaskBundle bundleData = TaskBundleHelper.CreateABundleInstance();
            task2ID = bundleData.Data.TaskID = id++;
            bundleData.Data.Title    = "Task2";
            bundleData.Data.Assignee = "Member1";
            bundleData.Data.Link     = "www.google.com.tw";
            bundleData.Data.Type     = (int)TaskType.Art;
            CheckAndCreateTaskObj(bundleData);
            AddTask(bundleData);
        }
        {
            TaskBundle bundleData = TaskBundleHelper.CreateABundleInstance();
            task3ID = bundleData.Data.TaskID = id++;
            bundleData.Data.Title        = "Task3";
            bundleData.Relation.ParentID = task1ID;            // task1
            bundleData.Data.Link         = "www.google.com.tw";
            bundleData.Data.Type         = (int)TaskType.Art;
            CheckAndCreateTaskObj(bundleData);
            AddTask(bundleData);
        }

        {
            TaskBundle bundleData = TaskBundleHelper.CreateABundleInstance();
            bundleData.Data.TaskID = id++;
            bundleData.Data.Title  = "Task4";
            var relatives = new TaskRelative[1];
            relatives[0]    = new TaskRelative();
            relatives[0].ID = 0;
            bundleData.Relation.SetRelatives(relatives);
            bundleData.Data.Link = "www.google.com.tw";
            bundleData.Data.Type = (int)TaskType.Art;
            CheckAndCreateTaskObj(bundleData);
            AddTask(bundleData);
        }
        {
            TaskBundle bundleData = TaskBundleHelper.CreateABundleInstance();
            bundleData.Data.TaskID   = id++;
            bundleData.Data.Title    = "Task5";
            bundleData.Data.Assignee = "Member2";
            bundleData.Data.Link     = "www.google.com.tw";
            bundleData.Data.Type     = (int)TaskType.Art;
            CheckAndCreateTaskObj(bundleData);
            AddTask(bundleData);
        }
        {
            TaskBundle bundleData = TaskBundleHelper.CreateABundleInstance();
            bundleData.Data.TaskID   = id++;
            bundleData.Data.Title    = "Task6";
            bundleData.Data.Assignee = "Member3";
            bundleData.Data.Link     = "www.google.com.tw";
            bundleData.Data.Type     = (int)TaskType.Art;
            CheckAndCreateTaskObj(bundleData);
            AddTask(bundleData);
        }


        {
            TaskBundle bundleData = TaskBundleHelper.CreateABundleInstance();
            bundleData.Data.TaskID       = id++;
            bundleData.Data.Title        = "Task7";
            bundleData.Data.Link         = "www.google.com.tw";
            bundleData.Data.Type         = (int)TaskType.Art;
            bundleData.Relation.ParentID = task3ID;            // task3ID
            CheckAndCreateTaskObj(bundleData);
            AddTask(bundleData);
        }

        {
            TaskBundle bundleData = TaskBundleHelper.CreateABundleInstance();
            bundleData.Data.TaskID        = id++;
            bundleData.Data.Title         = "Task8";
            bundleData.Data.Type          = (int)TaskType.Art;
            bundleData.Visual.PositionStr = "2.0,0.5,0";
            CheckAndCreateTaskObj(bundleData);
            AddTask(bundleData);
        }

        {
            TaskBundle bundleData = TaskBundleHelper.CreateABundleInstance();
            bundleData.Data.TaskID        = id++;
            bundleData.Data.Title         = "Task9";
            bundleData.Data.Type          = (int)TaskType.Art;
            bundleData.Visual.PositionStr = "3.0,0.5,0";
            bundleData.Relation.ParentID  = task2ID;           // task2ID
            CheckAndCreateTaskObj(bundleData);
            AddTask(bundleData);
        }
    }