Exemple #1
0
        //当前任务执行
        private void ExecuteCurrentTask()
        {
            _currentContent.OnExecute();

            Main.m_Event.Throw(this, Main.m_ReferencePool.Spawn <EventTaskContentExecute>().Fill(_currentContent));
            _currentContent = null;

            if (AllUndoneTaskContentCount > 0)
            {
                if (IsAutoChangeNext)
                {
                    if (_currentContentIndex < ContentAsset.Content.Count - 1)
                    {
                        _currentContentIndex += 1;
                    }
                    else
                    {
                        _currentContentIndex = 0;
                    }
                    BeginCurrentTask();
                }
            }
            else
            {
                End();
            }
        }
Exemple #2
0
        /// <summary>
        /// 当前任务完成
        /// </summary>
        private void CompleteCurrentTask()
        {
            _currentContent.OnComplete();

            Main.m_Event.Throw(Main.m_ReferencePool.Spawn <EventTaskContentComplete>().Fill(_currentContent));
            _currentContent = null;

            if (AllUncompleteTaskCount > 0)
            {
                if (IsAutoChangeState)
                {
                    if (_currentContentIndex < ContentAsset.Content.Count - 1)
                    {
                        _currentContentIndex += 1;
                    }
                    else
                    {
                        _currentContentIndex = 0;
                    }
                    BeginCurrentTask();
                }
            }
            else
            {
                End();
            }
        }
Exemple #3
0
        private void DeletePoint(TaskContentBase content)
        {
            int index = content.Points.IndexOf(this);

            for (int i = 0; i < content.Depends.Count; i++)
            {
                if (content.Depends[i].OriginalPoint == index || content.Depends[i].DependPoint == index)
                {
                    content.Depends.RemoveAt(i);
                    i -= 1;
                }
                else
                {
                    if (content.Depends[i].OriginalPoint > index)
                    {
                        content.Depends[i].OriginalPoint -= 1;
                    }
                    if (content.Depends[i].DependPoint > index)
                    {
                        content.Depends[i].DependPoint -= 1;
                    }
                }
            }

            TaskContentBase.DestroySerializeSubObject(this, content);
            content.Points.Remove(this);
        }
Exemple #4
0
        //当前任务开始
        private void BeginCurrentTask()
        {
            _currentContent = ContentAsset.Content[_currentContentIndex];
            _currentContent.OnStart();

            Main.m_Event.Throw(this, Main.m_ReferencePool.Spawn <EventTaskContentStart>().Fill(_currentContent));
        }
        /// <summary>
        /// 绘制工具栏
        /// </summary>
        /// <returns>绘制高度</returns>
        private int OnToolbarGUI(TaskContentAsset asset, TaskContentBase content)
        {
            int height = 0;

            GUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            GUIContent gUIContent = new GUIContent();

            gUIContent.image   = EditorGUIUtility.IconContent("d_editicon.sml").image;
            gUIContent.tooltip = "Edit Point Script";
            if (GUILayout.Button(gUIContent, "InvisibleButton", GUILayout.Width(20), GUILayout.Height(20)))
            {
                MonoScript monoScript = MonoScript.FromScriptableObject(this);
                AssetDatabase.OpenAsset(monoScript);
            }

            gUIContent.image   = EditorGUIUtility.IconContent("TreeEditor.Trash").image;
            gUIContent.tooltip = "Delete";
            if (GUILayout.Button(gUIContent, "InvisibleButton", GUILayout.Width(20), GUILayout.Height(20)))
            {
                if (EditorUtility.DisplayDialog("Delete Task Point", "Are you sure you want to delete task point [" + Name + "]?", "Yes", "No"))
                {
                    DeletePoint(asset, content);
                    GUI.changed = true;
                }
            }

            GUILayout.EndHorizontal();

            height += 20;

            return(height);
        }
Exemple #6
0
 /// <summary>
 /// 标题GUI
 /// </summary>
 private new void OnTitleGUI()
 {
     GUILayout.BeginHorizontal(EditorStyles.toolbar);
     if (GUILayout.Button(_asset.name, EditorStyles.toolbarButton))
     {
         Selection.activeObject = _asset;
         EditorGUIUtility.PingObject(_asset);
     }
     _isShowContent  = GUILayout.Toggle(_isShowContent, "Task Content", EditorStyles.toolbarButton);
     _isShowProperty = GUILayout.Toggle(_isShowProperty, "Property", EditorStyles.toolbarButton);
     GUILayout.FlexibleSpace();
     if (GUILayout.Button("ReSet", EditorStyles.toolbarButton))
     {
         for (int i = 0; i < _asset.Content.Count; i++)
         {
             TaskContentBase taskContent = _asset.Content[i];
             taskContent.ReSet();
             for (int j = 0; j < taskContent.Points.Count; j++)
             {
                 taskContent.Points[j].ReSet();
             }
         }
     }
     if (GUILayout.Button("About", EditorStyles.toolbarButton))
     {
     }
     GUILayout.EndHorizontal();
 }
        /// <summary>
        /// 删除任务点
        /// </summary>
        private void DeletePoint(TaskContentAsset asset, TaskContentBase content)
        {
            int index = content.Points.IndexOf(this);

            for (int i = 0; i < content.Depends.Count; i++)
            {
                TaskDepend depend = content.Depends[i];
                if (depend.OriginalPoint == index || depend.DependPoint == index)
                {
                    content.Depends.RemoveAt(i);
                    i -= 1;
                }
                else
                {
                    if (depend.OriginalPoint > index)
                    {
                        depend.OriginalPoint -= 1;
                    }
                    if (depend.DependPoint > index)
                    {
                        depend.DependPoint -= 1;
                    }
                }
            }

            content.Points.Remove(this);
            TaskContentAsset.DestroySerializeSubObject(this, asset);
        }
Exemple #8
0
        internal void OnEditorGUI(TaskContentBase taskContent)
        {
            if (!IsEnable)
            {
                GUI.backgroundColor = Color.gray;
            }
            else if (IsDone)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = _isSelected ? Color.yellow : Color.white;
            }

            GUILayout.BeginArea(Anchor, Name, "Window");

            GUI.backgroundColor = Color.white;

            _height = 25;

            _height += OnDependGUI(taskContent);

            _height += OnPropertyGUI();

            Anchor.height = _height;

            GUILayout.EndArea();

            OnWired();
        }
Exemple #9
0
        /// <summary>
        /// 结束任务流程
        /// </summary>
        public void End()
        {
            _currentContentIndex = 0;
            _currentContent      = null;
            _running             = false;

            Main.m_Event.Throw <EventTaskEnd>();
        }
Exemple #10
0
        /// <summary>
        /// 结束任务流程
        /// </summary>
        public void End()
        {
            _currentContentIndex = 0;
            _currentContent      = null;
            _running             = false;

            Main.m_Event.Throw(this, Main.m_ReferencePool.Spawn <EventTaskEnd>());
        }
        /// <summary>
        /// 克隆任务点
        /// </summary>
        private void ClonePoint(TaskContentBase content, TaskPointBase point, Vector2 pos)
        {
            TaskPointBase taskPoint = point.Clone();

            taskPoint.Anchor        = new Rect(pos.x, pos.y, 0, 0);
            taskPoint.GUID          = Target.TaskPointIDName + Target.TaskPointIDSign.ToString();
            Target.TaskPointIDSign += 1;
            content.Points.Add(taskPoint);

            TaskContentAsset.GenerateSerializeSubObject(taskPoint, Target);
        }
Exemple #12
0
 /// <summary>
 /// 完成指定的任务内容,任务内容未完成的任务点会根据依赖关系依次调用自动完成
 /// </summary>
 public void CompleteTaskContent(string id)
 {
     if (_running)
     {
         TaskContentBase taskContent = GetTaskContent(id);
         if (taskContent != null)
         {
             taskContent.OnAutoComplete();
         }
     }
 }
 /// <summary>
 /// 重置状态
 /// </summary>
 private void ReSet()
 {
     for (int i = 0; i < _asset.Content.Count; i++)
     {
         TaskContentBase taskContent = _asset.Content[i];
         taskContent.ReSet();
         for (int j = 0; j < taskContent.Points.Count; j++)
         {
             taskContent.Points[j].ReSet();
         }
     }
 }
        /// <summary>
        /// 新增任务点
        /// </summary>
        private void AddPoint(Type type, Vector2 position)
        {
            TaskPointBase taskPoint = CreateInstance(type) as TaskPointBase;

            taskPoint.Anchor        = new Rect(position.x, position.y, 200, 85);
            taskPoint.GUID          = _asset.TaskPointIDName + _asset.TaskPointIDSign.ToString();
            taskPoint.Details       = taskPoint.Name = "New Task Point " + _asset.TaskPointIDSign.ToString();
            _asset.TaskPointIDSign += 1;
            _currentContent.Points.Add(taskPoint);

            TaskContentBase.GenerateSerializeSubObject(taskPoint, _asset);
        }
 /// <summary>
 /// 选中连线任务点
 /// </summary>
 private bool ChoosePoint(Vector2 mousePosition, TaskContentBase content, out int index)
 {
     for (int i = 0; i < content.Points.Count; i++)
     {
         if (content.Points[i].Anchor.Contains(mousePosition))
         {
             index = i;
             return(true);
         }
     }
     index = -1;
     return(false);
 }
Exemple #16
0
        /// <summary>
        /// 新增任务点
        /// </summary>
        private void AddPoint(Type type, Vector2 position)
        {
            TaskPointAttribute tpa       = type.GetCustomAttribute <TaskPointAttribute>();
            TaskPointBase      taskPoint = CreateInstance(type) as TaskPointBase;

            taskPoint.Anchor        = new Rect(position.x, position.y, 200, 85);
            taskPoint.GUID          = _asset.TaskPointIDName + _asset.TaskPointIDSign.ToString();
            taskPoint.Name          = (tpa != null ? tpa.GetLastName() : "New Task Point ") + _asset.TaskPointIDSign.ToString();
            _asset.TaskPointIDSign += 1;
            _currentContent.Points.Add(taskPoint);

            TaskContentBase.GenerateSerializeSubObject(taskPoint, _asset);
        }
Exemple #17
0
        /// <summary>
        /// 新增任务点
        /// </summary>
        private void AddPoint(TaskContentBase content, Type type, Vector2 pos)
        {
            TaskPointAttribute attribute = type.GetCustomAttribute <TaskPointAttribute>();
            TaskPointBase      taskPoint = CreateInstance(type) as TaskPointBase;

            taskPoint.Anchor = new Rect(pos.x, pos.y, 0, 0);
            taskPoint.GUID   = _contentAsset.TaskPointIDName + _contentAsset.TaskPointIDSign.ToString();
            taskPoint.Name   = (attribute != null ? attribute.GetLastName() : "New Task Point ") + _contentAsset.TaskPointIDSign.ToString();
            _contentAsset.TaskPointIDSign += 1;
            content.Points.Add(taskPoint);

            TaskContentAsset.GenerateSerializeSubObject(taskPoint, _contentAsset);
        }
        /// <summary>
        /// 新增任务内容
        /// </summary>
        private void AddContent(Type type)
        {
            TaskContentBase taskContent = CreateInstance(type) as TaskContentBase;

            taskContent.GUID    = _asset.TaskIDName + _asset.TaskIDSign.ToString();
            taskContent.Details = taskContent.Name = "New Task " + _asset.TaskIDSign.ToString();
            _asset.TaskIDSign  += 1;
            _asset.Content.Add(taskContent);
            _taskContentList.index = _asset.Content.Count - 1;
            _currentContent        = taskContent;

            TaskContentBase.GenerateSerializeSubObject(taskContent, _asset);
        }
        /// <summary>
        /// 删除任务内容
        /// </summary>
        private void DeleteContent(int taskIndex)
        {
            for (int i = 0; i < _asset.Content[taskIndex].Points.Count; i++)
            {
                TaskContentBase.DestroySerializeSubObject(_asset.Content[taskIndex].Points[i], _asset);
            }
            TaskContentBase.DestroySerializeSubObject(_asset.Content[taskIndex], _asset);

            _asset.Content[taskIndex].Depends.Clear();
            _asset.Content[taskIndex].Points.Clear();
            _asset.Content.RemoveAt(taskIndex);
            _taskContentList.index = -1;
            _currentContent        = null;
        }
Exemple #20
0
        /// <summary>
        /// 新增任务内容
        /// </summary>
        private void AddContent(Type type)
        {
            TaskContentAttribute tca         = type.GetCustomAttribute <TaskContentAttribute>();
            TaskContentBase      taskContent = CreateInstance(type) as TaskContentBase;

            taskContent.GUID   = _asset.TaskIDName + _asset.TaskIDSign.ToString();
            taskContent.Name   = (tca != null ? tca.GetLastName() : "New Task  ") + _asset.TaskIDSign.ToString();
            _asset.TaskIDSign += 1;
            _asset.Content.Add(taskContent);
            _taskContentList.index = _asset.Content.Count - 1;
            _currentContent        = taskContent;

            TaskContentBase.GenerateSerializeSubObject(taskContent, _asset);
        }
        /// <summary>
        /// 当前任务内容完成
        /// </summary>
        private void CompleteCurrentTask()
        {
            _currentTaskContent.Complete();
            _currentTaskContent = null;

            _currentTaskContentIndex += 1;
            if (_currentTaskContentIndex < _taskContentsList.Count)
            {
                BeginCurrentTask();
            }
            else
            {
                End();
            }
        }
        /// <summary>
        /// 克隆任务内容
        /// </summary>
        private void CloneContent(TaskContentBase content)
        {
            TaskContentBase taskContent = content.Clone();

            taskContent.Points.Clear();
            for (int i = 0; i < content.Points.Count; i++)
            {
                ClonePoint(taskContent, content.Points[i], content.Points[i].Anchor.position);
            }
            taskContent.GUID   = Target.TaskIDName + Target.TaskIDSign.ToString();
            Target.TaskIDSign += 1;
            Target.Content.Add(taskContent);

            TaskContentAsset.GenerateSerializeSubObject(taskContent, Target);
        }
Exemple #23
0
        /// <summary>
        /// 开始任务流程
        /// </summary>
        public void Begin()
        {
            if (!ContentAsset || ContentAsset.Content.Count <= 0 || _taskContents.Count <= 0)
            {
                throw new HTFrameworkException(HTFrameworkModule.TaskEditor, "任务控制者:当前无法开始任务流程,请重新编译任务内容 RecompileTaskContent!");
            }

            _currentContentIndex = 0;
            _currentContent      = null;
            _running             = true;

            Main.m_Event.Throw(this, Main.m_ReferencePool.Spawn <EventTaskBegin>());

            BeginCurrentTask();
        }
        /// <summary>
        /// 开始任务流程
        /// </summary>
        public void Begin()
        {
            if (!ContentAsset || ContentAsset.Content.Count <= 0 || _taskContentsList.Count <= 0)
            {
                throw new HTFrameworkException(HTFrameworkModule.TaskMaster, "任务控制者:当前无法开始任务流程,请重新编译任务内容 RecompileTaskContent!");
            }

            _currentTaskContentIndex = 0;
            _currentTaskContent      = null;
            _running = true;
            Pause    = false;

            Main.m_Event.Throw <EventTaskBegin>();

            BeginCurrentTask();
        }
Exemple #25
0
        internal void OnPointEventHandle(Event e, TaskContentBase content)
        {
            switch (e.type)
            {
            case EventType.MouseDown:
                if (e.button == 0)
                {
                    if (Anchor.Contains(e.mousePosition))
                    {
                        _isDraging  = true;
                        _isSelected = true;
                        GUI.changed = true;
                        GUI.FocusControl(null);
                    }
                    else
                    {
                        _isSelected    = false;
                        _isEditID      = false;
                        _isEditName    = false;
                        _isEditDetails = false;
                        GUI.changed    = true;
                    }
                }
                else if (e.button == 1)
                {
                    if (_isSelected && Anchor.Contains(e.mousePosition))
                    {
                        RightClickMenu(content);
                        e.Use();
                    }
                }
                break;

            case EventType.MouseUp:
                _isDraging = false;
                break;

            case EventType.MouseDrag:
                if (e.button == 0 && _isDraging)
                {
                    OnDrag(e.delta);
                    e.Use();
                    GUI.changed = true;
                }
                break;
            }
        }
Exemple #26
0
        /// <summary>
        /// 粘贴、克隆任务内容
        /// </summary>
        private void PasteCloneTaskContent(GenericMenu gm)
        {
            string assetPath = AssetDatabase.GetAssetPath(_contentAsset);

            TaskContentBase content = null;

            string[] buffers = GUIUtility.systemCopyBuffer.Split('|');
            if (buffers.Length == 3 && buffers[0] == "TaskContent")
            {
                if (buffers[1] == assetPath)
                {
                    content = _contentAsset.Content.Find((s) => { return(s.GUID == buffers[2]); });
                }
                else
                {
                    TaskContentAsset taskContentAsset = AssetDatabase.LoadAssetAtPath <TaskContentAsset>(buffers[1]);
                    if (taskContentAsset)
                    {
                        content = taskContentAsset.Content.Find((s) => { return(s.GUID == buffers[2]); });
                    }
                }
            }

            if (content == null)
            {
                gm.AddDisabledItem(new GUIContent(GetWord("Paste")));
            }
            else
            {
                gm.AddItem(new GUIContent(GetWord("Paste") + " " + content.Name), false, () =>
                {
                    CloneContent(content);
                });
            }

            if (_currentContent == null)
            {
                gm.AddDisabledItem(new GUIContent(GetWord("Clone")));
            }
            else
            {
                gm.AddItem(new GUIContent(GetWord("Clone")), false, () =>
                {
                    CloneContent(_currentContent);
                });
            }
        }
 /// <summary>
 /// 清空所有任务
 /// </summary>
 private void ClearTask()
 {
     for (int i = 0; i < Target.Content.Count; i++)
     {
         EditorUtility.DisplayProgressBar("Clear......", i + "/" + Target.Content.Count, (float)i / Target.Content.Count);
         TaskContentBase content = Target.Content[i];
         for (int j = 0; j < content.Points.Count; j++)
         {
             TaskContentAsset.DestroySerializeSubObject(content.Points[j], Target);
         }
         TaskContentAsset.DestroySerializeSubObject(content, Target);
     }
     Target.Content.Clear();
     HasChanged();
     RefreshCount();
     EditorUtility.ClearProgressBar();
 }
Exemple #28
0
        internal void OnEditorGUI(TaskContentBase taskContent)
        {
            GUI.backgroundColor = _isSelected ? Color.yellow : Color.white;

            GUILayout.BeginArea(Anchor, Name, "Window");

            GUI.backgroundColor = Color.white;

            _height = 25;

            _height += OnDependGUI(taskContent);

            _height += OnPropertyGUI();

            Anchor.height = _height;

            GUILayout.EndArea();
        }
Exemple #29
0
        private void RightClickMenu(TaskContentBase content)
        {
            GenericMenu gm = new GenericMenu();

            gm.AddItem(new GUIContent("Delete " + Name), false, () =>
            {
                if (EditorUtility.DisplayDialog("Delete Task Point", "Are you sure you want to delete task point [" + Name + "]?", "Yes", "No"))
                {
                    DeletePoint(content);
                }
            });
            gm.AddItem(new GUIContent("Edit Point Script"), false, () =>
            {
                MonoScript monoScript = MonoScript.FromScriptableObject(this);
                AssetDatabase.OpenAsset(monoScript);
            });
            gm.ShowAsContext();
        }
Exemple #30
0
        /// <summary>
        /// 开始任务流程
        /// </summary>
        public void Begin()
        {
            if (!ContentAsset || ContentAsset.Content.Count <= 0 || _taskContents.Count <= 0)
            {
                throw new HTFrameworkException(HTFrameworkModule.TaskEditor, "任务控制者:当前无法开始任务流程,请重新编译任务内容 RecompileTaskContent!");
            }

            _currentContentIndex = 0;
            _currentContent      = null;
            _running             = true;

            Main.m_Event.Throw <EventTaskBegin>();

            if (IsAutoChangeState)
            {
                BeginCurrentTask();
            }
        }