示例#1
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);
        }
示例#2
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);
        }
        /// <summary>
        /// 任务点GUI事件处理
        /// </summary>
        private void OnPointEventHandle()
        {
            if (_currentContent != null && Event.current != null)
            {
                Vector2 mousePosition = Event.current.mousePosition;

                switch (Event.current.type)
                {
                case EventType.MouseDown:
                    if (Event.current.button == 1)
                    {
                        GenericMenu gm = new GenericMenu();
                        gm.AddItem(new GUIContent("<New Task Point Script>"), false, () =>
                        {
                            NewTaskPointScript();
                        });
                        List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
                        {
                            return(type.IsSubclassOf(typeof(TaskPointBase)));
                        });
                        for (int i = 0; i < types.Count; i++)
                        {
                            Type               type        = types[i];
                            string             contentName = type.FullName;
                            TaskPointAttribute attri       = type.GetCustomAttribute <TaskPointAttribute>();
                            if (attri != null)
                            {
                                contentName = attri.Name;
                            }
                            gm.AddItem(new GUIContent("Add Task Point/" + contentName), false, () =>
                            {
                                AddPoint(type, mousePosition);
                            });
                        }
                        StringToolkit.BeginNoRepeatNaming();
                        for (int i = 0; i < _currentContent.Points.Count; i++)
                        {
                            TaskPointBase point = _currentContent.Points[i];
                            gm.AddItem(new GUIContent(StringToolkit.GetNoRepeatName("Find Task Point/" + point.Name)), false, () =>
                            {
                                FindPoint(point);
                            });
                        }
                        gm.ShowAsContext();
                    }
                    break;

                case EventType.MouseDrag:
                    if (Event.current.button == 2)
                    {
                        for (int i = 0; i < _currentContent.Points.Count; i++)
                        {
                            _currentContent.Points[i].OnDrag(Event.current.delta);
                        }
                        GUI.changed = true;
                    }
                    break;
                }

                for (int i = 0; i < _currentContent.Points.Count; i++)
                {
                    _currentContent.Points[i].OnPointEventHandle(Event.current, _currentContent);
                }
            }
        }
示例#4
0
        /// <summary>
        /// 任务点GUI事件处理
        /// </summary>
        private void OnPointEventHandle()
        {
            if (_currentContent != null && Event.current != null)
            {
                Vector2 pos = Event.current.mousePosition;

                switch (Event.current.type)
                {
                case EventType.MouseDown:
                    if (Event.current.button == 1)
                    {
                        GenericMenu gm = new GenericMenu();
                        gm.AddItem(new GUIContent(GetWord("Add Task Point") + "/默认"), false, () =>
                        {
                            AddPoint(_currentContent, typeof(TaskPointDefault), pos);
                        });
                        List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
                        {
                            return(type.IsSubclassOf(typeof(TaskPointBase)) && !type.IsAbstract && type != typeof(TaskPointDefault));
                        });
                        for (int i = 0; i < types.Count; i++)
                        {
                            Type               type      = types[i];
                            string             pointName = type.FullName;
                            TaskPointAttribute attribute = type.GetCustomAttribute <TaskPointAttribute>();
                            if (attribute != null)
                            {
                                pointName = attribute.Name;
                            }
                            gm.AddItem(new GUIContent(GetWord("Add Task Point") + "/" + pointName), false, () =>
                            {
                                AddPoint(_currentContent, type, pos);
                            });
                        }
                        StringToolkit.BeginNoRepeatNaming();
                        for (int i = 0; i < _currentContent.Points.Count; i++)
                        {
                            TaskPointBase point = _currentContent.Points[i];
                            gm.AddItem(new GUIContent(StringToolkit.GetNoRepeatName(GetWord("Find Task Point") + "/" + point.Name)), false, () =>
                            {
                                FindPoint(point);
                            });
                        }
                        gm.AddSeparator("");
                        CopyTaskPoint(gm);
                        PasteTaskPoint(gm, pos);
                        gm.AddSeparator("");
                        gm.AddItem(new GUIContent(GetWord("Collapse All")), false, () =>
                        {
                            for (int i = 0; i < _currentContent.Points.Count; i++)
                            {
                                TaskPointBase point = _currentContent.Points[i];
                                point.IsExpand      = false;
                            }
                            GUI.changed = true;
                        });
                        gm.AddItem(new GUIContent(GetWord("Expand All")), false, () =>
                        {
                            for (int i = 0; i < _currentContent.Points.Count; i++)
                            {
                                TaskPointBase point = _currentContent.Points[i];
                                point.IsExpand      = true;
                            }
                            GUI.changed = true;
                        });
                        gm.AddSeparator("");
                        gm.AddItem(new GUIContent(GetWord("Enable All")), false, () =>
                        {
                            for (int i = 0; i < _currentContent.Points.Count; i++)
                            {
                                TaskPointBase point = _currentContent.Points[i];
                                point.IsEnable      = true;
                            }
                            GUI.changed = true;
                        });
                        gm.AddItem(new GUIContent(GetWord("Disable All")), false, () =>
                        {
                            for (int i = 0; i < _currentContent.Points.Count; i++)
                            {
                                TaskPointBase point = _currentContent.Points[i];
                                point.IsEnable      = false;
                            }
                            GUI.changed = true;
                        });
                        gm.AddSeparator("");
                        gm.AddItem(new GUIContent(GetWord("<New Task Point Script>")), false, () =>
                        {
                            NewTaskPointScript();
                        });
                        gm.ShowAsContext();
                    }
                    break;

                case EventType.MouseDrag:
                    if (Event.current.button == 2)
                    {
                        for (int i = 0; i < _currentContent.Points.Count; i++)
                        {
                            _currentContent.Points[i].OnDrag(Event.current.delta);
                        }
                        GUI.changed = true;
                    }
                    break;

                case EventType.KeyDown:
                    switch (Event.current.keyCode)
                    {
                    case KeyCode.LeftAlt:
                    case KeyCode.RightAlt:
                        _isBreakDepend = true;
                        GUI.changed    = true;
                        break;
                    }
                    break;

                case EventType.KeyUp:
                    switch (Event.current.keyCode)
                    {
                    case KeyCode.LeftAlt:
                    case KeyCode.RightAlt:
                        _isBreakDepend = false;
                        GUI.changed    = true;
                        break;
                    }
                    break;
                }

                for (int i = 0; i < _currentContent.Points.Count; i++)
                {
                    _currentContent.Points[i].OnPointEventHandle(Event.current, _contentAsset, _currentContent, _getWord);
                }
            }
        }