Пример #1
0
        public static BaseBehaviorNode Getbehavior(string behaviorName)
        {
            Type rootBehaviorType = Type.GetType(behaviorName);

            ConstructorInfo  constructor   = rootBehaviorType.GetConstructor(new Type[] { });
            BaseBehaviorNode finalBehavior = constructor.Invoke(new object[] { }) as BaseBehaviorNode;

            return(finalBehavior);
        }
Пример #2
0
 public override void AddChild(BaseBehaviorNode behavior)
 {
     if (childBehaviorList.Count == 0)
     {
         base.AddChild(behavior);
     }
     else
     {
         Debug.unityLogger.LogError("ConditionNode", "ConditionNode只允许有一个子节点");
     }
 }
Пример #3
0
        private void LoadBehaviorTreeInfo()
        {
            string    xmlStr = AssetLoader.GetText(behaviorTreeInfoBundlePath, behaviorTreeInfoName).text;
            XDocument xDoc   = XDocument.Parse(xmlStr);

            string rootBehaviorName = xDoc.Root.Name.LocalName;

            rootBehavior      = BaseBehaviorNode.Getbehavior(rootBehaviorName);
            rootBehavior.root = this;
            LoadBehaviorList(xDoc.Root, rootBehavior);
        }
Пример #4
0
        private void LoadBehaviorTreeInfo()
        {
            string    xmlStr = ResourcesLoaderHelper.Instance.LoadTextAsset(behaviorTreeInfoPath).text;
            XDocument xDoc   = XDocument.Parse(xmlStr);

            string rootBehaviorName = xDoc.Root.Name.LocalName;

            rootBehavior      = BaseBehaviorNode.Getbehavior(rootBehaviorName);
            rootBehavior.root = this;
            LoadBehaviorList(xDoc.Root, rootBehavior);
        }
Пример #5
0
        private void LoadBehaviorList(XElement parentEl, BaseBehaviorNode parentBehavior)
        {
            if (!parentEl.HasElements)
            {
                return;
            }

            BaseBehaviorNode childBehavior;

            foreach (XElement el in parentEl.Elements())
            {
                childBehavior = BaseBehaviorNode.Getbehavior(el.Name.LocalName);
                parentBehavior.AddChild(childBehavior);

                if (el.HasElements)
                {
                    LoadBehaviorList(el, childBehavior);
                }
            }
        }
Пример #6
0
 public sealed override void DeleteChild(BaseBehaviorNode behavior)
 {
     Debug.logger.LogError("添加子节点", "行为节点不能有子节点");
 }
Пример #7
0
 public sealed override void AddChild(BaseBehaviorNode behavior)
 {
     Debug.unityLogger.LogError("添加子节点", "行为节点不能有子节点");
 }
Пример #8
0
 public virtual void DeleteChild(BaseBehaviorNode behavior)
 {
     behavior.parent = null;
     childBehaviorList.Remove(behavior);
 }
Пример #9
0
 public virtual void AddChild(BaseBehaviorNode behavior)
 {
     behavior.parent = this;
     childBehaviorList.Add(behavior);
     behavior.root = root;
 }