Пример #1
0
        /// <summary>
        /// 根据字段获取关联的连线点
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public NodeLineInfor GetNodeLineInforOfField(FieldInfo field)
        {
            NodeLineInfor infor = null;

            if (m_AllNodeLinesInfor.TryGetValue(field, out infor))
            {
                return(infor);
            }
            Debug.LogError("GetNodeLineInforOfField Fail " + field.Name);
            return(null);
        }
Пример #2
0
 /// <summary>
 /// 检测当前连线点是否可以作为连入节点
 /// </summary>
 /// <param name="nodeLinePoint"></param>
 /// <returns></returns>
 public static bool CheckCanLineIn(NodeLineInfor nodeLinePoint)
 {
     //if (nodeLinePoint.m_LineType == NodeInOutEnum.None || nodeLinePoint.m_LineType == NodeInOutEnum.Out)
     //    return false;
     if (nodeLinePoint.m_IsSignalConnected)
     {
         if (nodeLinePoint.m_ConnectNodeLine.Count > 1)
         {
             Debug.LogError("CheckCanLineOut To Much Line COnnect");
             return(false);
         }
         if (nodeLinePoint.m_ConnectNodeLine.Count == 1)
         {
             return(false);  //已经连线了
         }
     }
     return(true);
 }
Пример #3
0
 /// <summary>
 /// 检测当前连线点是否可以作为连出节点
 /// </summary>
 /// <param name="nodeLinePoint"></param>
 /// <returns></returns>
 public static bool CheckCanLineOut(NodeLineInfor nodeLinePoint)
 {
     //if (nodeLinePoint.m_LineType == NodeInOutEnum.None || nodeLinePoint.m_LineType == NodeInOutEnum.In)
     //{
     //    Debug.Log("CheckCanLineOut  False Not Right LineType:" + nodeLinePoint.m_LineType);
     //    return false;
     //}
     if (nodeLinePoint.m_IsSignalConnected)
     {
         if (nodeLinePoint.m_ConnectNodeLine.Count > 1)
         {
             Debug.LogError("CheckCanLineOut To Much Line COnnect");
             return(false);
         }
         if (nodeLinePoint.m_ConnectNodeLine.Count == 1)
         {
             Debug.LogError("CheckCanLineOut Allready Connect");
             return(false);  //已经连线了
         }
     }
     return(true);
 }
Пример #4
0
        public NodeParent(NodeActionParent scriptObj)
        {
            FieldInfo[] allfields = scriptObj.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            foreach (FieldInfo field in allfields)
            {
                NodeAttribute attribute = Attribute.GetCustomAttribute(field, typeof(NodeAttribute)) as NodeAttribute;
                if (attribute != null)
                {
                    object Value = field.GetValue(scriptObj);
                    if (Value == null)
                    {
                        field.SetValue(scriptObj, attribute.DefaultValue);  //如果没有设置默认值则使用特性中定义的默认值
                        //Debug.Log(">>>>  " + field.Name);
                    }

                    if (attribute.InOut != NodeInOutEnum.None)
                    {
                        NodeLineInfor nodeLine = new NodeLineInfor(field, attribute.InOut, attribute.SignalConnect, this);
                        m_AllNodeLinesInfor.Add(field, nodeLine);
                    }//记录所有的节点
                }
            }
        }
Пример #5
0
            public static void  TryAddLineConnect(NodeLineInfor begin, NodeLineInfor end)
            {
                if (begin == null || end == null)
                {
                    //Debug.Log("TryAddLineConnect Fail, " + (begin == null) + " :  " + (end == null));
                    return;
                }

                //if(begin.m_LineType== NodeInOutEnum.None|| begin.m_LineType == NodeInOutEnum.In)
                //    return; //起点不是输出节点
                //if (end.m_LineType != NodeInOutEnum.InOut || end.m_LineType != NodeInOutEnum.In)
                //    return; //起点不是输入节点

                for (int dex = 0; dex < begin.m_ConnectNodeLine.Count; ++dex)
                {
                    if (begin.m_ConnectNodeLine[dex] == end)
                    {
                        return; //已经包含了这个连线
                    }
                }

                for (int dex = 0; dex < end.m_ConnectNodeLine.Count; ++dex)
                {
                    if (end.m_ConnectNodeLine[dex] == begin)
                    {
                        return; //已经包含了这个连线
                    }
                }

                begin.m_ConnectNodeLine.Add(end);
                end.m_ConnectNodeLine.Add(begin);

                LinConnectInfor connected = new LinConnectInfor(begin, end);

                BehaviorTreeEditorMenu.RecordConnectedLine(connected);
            }
Пример #6
0
        /// <summary>
        /// 更新当前节点是否选中/是否选择连线点的状态
        /// </summary>
        /// <param name="mousPos"></param>
        public void UpdateNodeSelectState(Vector2 mousPos, bool isGetStartPoint)
        {
            Rect rect = new Rect(m_Pos.x, m_Pos.y, GetNodeWidth(), GetNodeHeight());

            IsSelectNode = rect.Contains(mousPos);  //是否在节点的显示区域中
            if (IsSelectNode == false)
            {
                return;
            }

            foreach (var item in m_AllLinPoint)
            {
                //Debug.Log("item " + item.Value + " :" + item.Value.Contains(mousPos) + "   mousPos" + mousPos);
                if (item.Value.Contains(mousPos))
                {
                    NodeLineInfor currentNodeLine = GetNodeLineInforOfField(item.Key);

                    #region     获得起点
                    if (isGetStartPoint)
                    {
                        if (m_SelectNodeLineBegin == null)
                        {
                            m_SelectNodeLineEnd = null;
                            if (NodeLineInfor.CheckCanLineOut(currentNodeLine))
                            {
                                m_SelectNodeLineBegin = currentNodeLine;
                                IsSelectNodeLinePoint = true;
                                IsSelectNode          = false; //说明当前选中的是节点的连线点
                                //Debug.Log("Select Lint Point");
                                return;
                            } //当前点可以作为连出节点
                        }
                    }
                    #endregion

                    #region 获取终点
                    if (isGetStartPoint == false)
                    {
                        if (m_SelectNodeLineBegin == null)
                        {
                            return;
                        }

                        if (currentNodeLine.m_BelongNode == m_SelectNodeLineBegin.m_BelongNode)
                        {
                            m_SelectNodeLineEnd = null;
                            return;  //起点和终点不允许是同一个节点
                        }
                        else
                        {
                            if (NodeLineInfor.CheckCanLineIn(currentNodeLine))
                            {
                                m_SelectNodeLineEnd   = currentNodeLine;
                                IsSelectNodeLinePoint = true;
                                IsSelectNode          = false; //说明当前选中的是节点的连线点
                                                               //  Debug.Log("Select Lint Point");
                                return;
                            }//可以作为连入节点
                        }
                    }
                    #endregion
                }
            }//foreach
            IsSelectNodeLinePoint = false;
        }
Пример #7
0
            // public string m_LineID;

            public LinConnectInfor(NodeLineInfor @from, NodeLineInfor @to)
            {
                m_BeginNodeLintPoint = @from;
                m_EndNodeLintPoint   = @to;
                //   m_LineID = @from.NodeLinePointID; //取起点的ID 作为线标识
            }