示例#1
0
        //将XBTNodeMono转换成XBTNode
        public static XBTNode ParseMono(XBTNodeMono mono, XBTNode parent = null)
        {
            var node = new XBTNode();

            node.parent        = parent;
            node.taskClassName = mono.className;
            var variables = mono.GetComponent <XMonoVariables>();

            if (variables != null)
            {
                node.variables = XMonoVariableUtility.ConvertToDict(variables.values);
            }
            var trans = mono.transform;
            int count = trans.childCount;

            if (count > 0)
            {
                node.children = new List <XBTNode>();
                for (int i = 0; i < count; ++i)
                {
                    var child = trans.GetChild(i).GetComponent <XBTNodeMono>();
                    if (child == null)
                    {
                        continue;
                    }
                    node.children.Add(ParseMono(child, node));
                }
            }
            return(node);
        }
示例#2
0
 public void Stop(object obj)
 {
     if (m_node == null)
     {
         return;
     }
     if (m_status == EnumTaskStatus.Running)
     {
         m_task.Leave(obj);
     }
     XBTClassFactory.Free(m_task);
     m_task   = null;
     m_node   = null;
     m_status = EnumTaskStatus.None;
 }
示例#3
0
 public void Start(XBTNode node, object obj)
 {
     if (m_status == EnumTaskStatus.Running)
     {
         m_task.Leave(obj);
     }
     if (m_node == null || m_node != node)
     {
         if (m_task != null)
         {
             XBTClassFactory.Free(m_task);
             m_task = null;
         }
         m_task = XBTClassFactory.Alloc <IXBTTask>(node.taskClassName);
         m_task.SetNode(node);
         m_node = node;
     }
     m_task.Enter(obj);
     m_status = EnumTaskStatus.Running;
 }
示例#4
0
 public virtual void SetNode(XBTNode node)
 {
     m_node = node;
 }
示例#5
0
 public XBTBehavior()
 {
     m_node   = null;
     m_task   = null;
     m_status = EnumTaskStatus.None;
 }