Ejemplo n.º 1
0
        public static BTEditorTreeConfig CreateEditorTreeConfigFromRootEditorNode(BTNodeDesigner _rootEditorNode)
        {
            TreeConfig         _treeConfig       = BTFactory.CreateConfigFromBTreeRoot(_rootEditorNode.mEditorNode.mNode);
            BTEditorTreeConfig _treeEditorConfig = new BTEditorTreeConfig(_treeConfig);
            int index = 0;

            CreateEditorNodeConfigFromRootEditorNode(_rootEditorNode, ref _treeEditorConfig.mEditorNodes, ref index);

            return(_treeEditorConfig);
        }
Ejemplo n.º 2
0
 public static BTEditorNode[] CreateBTreeEditorNode(BTEditorTreeConfig _config)
 {
     BTNode[]       _btreeNodes  = BTFactory.CreateBTreeFromConfig(_config);
     BTEditorNode[] _editorNodes = new BTEditorNode[_btreeNodes.Length];
     for (int i = 0; i < _editorNodes.Length; i++)
     {
         _editorNodes[i]          = new BTEditorNode(_btreeNodes[i]);
         _editorNodes[i].mPos     = new Vector2(_config.mEditorNodes[i].mPosX, _config.mEditorNodes[i].mPosY);
         _editorNodes[i].mDisable = _config.mEditorNodes[i].mDisable;
     }
     return(_editorNodes);
 }
Ejemplo n.º 3
0
        public static void Init()
        {
            for (int i = 0; i < 4; i++)
            {
                Assembly assembly = null;
                try
                {
                    switch (i)
                    {
                    case 0:
                        assembly = Assembly.Load("Assembly-CSharp");
                        break;

                    case 1:
                        assembly = Assembly.Load("Assembly-CSharp-firstpass");
                        break;

                    case 2:
                        assembly = Assembly.Load("Assembly-UnityScript");
                        break;

                    case 3:
                        assembly = Assembly.Load("Assembly-UnityScript-firstpass");
                        break;
                    }
                }
                catch (Exception)
                {
                    assembly = null;
                }
                if (assembly != null)
                {
                    Type[] types = assembly.GetTypes();
                    for (int j = 0; j < types.Length; j++)
                    {
                        if (!types[j].IsAbstract)
                        {
                            if (types[j].IsSubclassOf(typeof(BTAction)))
                            {
                                BTFactory.RegisterActionType(types[j]);
                            }
                            else if (types[j].IsSubclassOf(typeof(BTPrecondition)))
                            {
                                BTFactory.RegisterPreconditionType(types[j]);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
    public static void Init()
    {
        BTFactory.RegisterActionType(typeof(ActionIdle));
        BTFactory.RegisterActionType(typeof(ActionMoveToPoint));
        BTFactory.RegisterActionType(typeof(ActionAttack));
        BTFactory.RegisterActionType(typeof(ActionFindTarget));
        BTFactory.RegisterActionType(typeof(ActionFollowTarget));
        BTFactory.RegisterActionType(typeof(ActionDie));

        BTFactory.RegisterPreconditionType(typeof(IsArriveCondition));
        BTFactory.RegisterPreconditionType(typeof(IsAttackingCondition));
        BTFactory.RegisterPreconditionType(typeof(IsAttackRangeCondition));
        BTFactory.RegisterPreconditionType(typeof(HasAttackCondition));
        BTFactory.RegisterPreconditionType(typeof(HasTargetCondition));
        BTFactory.RegisterPreconditionType(typeof(IsDeadCondition));
        BTFactory.RegisterPreconditionType(typeof(IsTurningCondition));
        BTFactory.RegisterPreconditionType(typeof(IsMovingCondition));
    }
Ejemplo n.º 5
0
        public static TreeConfig CreateTreeConfigFromBTreeGraphDesigner(BTGraphDesigner _graphDesigner)
        {
            BTNode _root = _graphDesigner.mRootNode.mEditorNode.mNode;

            return(BTFactory.CreateConfigFromBTreeRoot(_root));
        }
Ejemplo n.º 6
0
        public void InitXML(byte[] data)
        {
            var _config = BTSerialization.ReadXML(data);

            mTreeRoot = BTFactory.CreateBTreeRootFromConfig(_config);
        }