Exemplo n.º 1
0
        public BehaviourLooper CreateSubLooper()
        {
            var looper = new BehaviourLooper(Runner);

            looper.Parent = this;
            return(looper);
        }
Exemplo n.º 2
0
 private AssetBinder(AssetBinder parent)
 {
     mRunner    = parent.mRunner;
     mAssetDeep = parent.mAssetDeep + 1;
     mLooper    = new BehaviourLooper(mRunner);
     mSubAssets = new List <AssetBinder>();
 }
Exemplo n.º 3
0
 private AssetBinder(BehaviourTreeRunner runner)
 {
     mRunner    = runner;
     mAssetDeep = 1;
     mLooper    = new BehaviourLooper(runner);
     mSubAssets = new List <AssetBinder>();
 }
Exemplo n.º 4
0
 public override void SetChild(int index, BTNodeBase node)
 {
     base.SetChild(index, node);
     if (node != null)
     {
         mLoopers[index] = new BehaviourLooper(node);
     }
 }
Exemplo n.º 5
0
 protected override void OnVisit(BehaviourTreeRunner behaviourTree)
 {
     State = ChildLength > 0 ? EBTTaskState.running : EBTTaskState.success;
     for (int i = 0; i < mLoopers.Length; i++)
     {
         if (mLoopers[i] != null)
         {
             mLoopers[i].Reset();
         }
     }
     if (mMainTaskIndex < mLoopers.Length && mMainTaskIndex >= 0)
     {
         mMainLooper = mLoopers[mMainTaskIndex];
     }
 }
Exemplo n.º 6
0
        public override void OnInitData(BehaviourTreeRunner btree, string jsonData)
        {
            JObject obj = JsonConvert.DeserializeObject <JObject>(jsonData);

            mAssetPath = obj.Value <string>("asset");

            BehaviourTreeAsset asset = Resources.Load <BehaviourTreeAsset>(mAssetPath);

            if (!asset)
            {
                Debug.LogError("Can't load behaviour asset: " + mAssetPath);
                return;
            }
            BTNodeBase tree = asset.CreateBehaviourTree(btree);

            mLooper = new BehaviourLooper(tree);
        }
Exemplo n.º 7
0
 public void SetAsset(BehaviourTreeAsset behaviourAsset)
 {
     if (behaviourAsset == mAsset)
     {
         return;
     }
     mAsset = behaviourAsset;
     if (mAsset != null)
     {
         mRootNode = mAsset.CreateBehaviourTree(this);
         mLooper   = new BehaviourLooper(mRootNode);
     }
     else
     {
         mRootNode = null;
         mLooper   = null;
     }
 }
Exemplo n.º 8
0
            public void Dispose()
            {
                Cleanup();
                var tmp = mSubAssets;

                mSubAssets = null;
                for (int i = 0; i < tmp.Count; i++)
                {
                    tmp[i].mParent = null;
                }
                if (mParent != null && mParent.mSubAssets != null)
                {
                    mParent.mSubAssets.Remove(this);
                    mParent = null;
                }
                if (mLooper != null)
                {
                    mLooper.Dispose();
                }
                mLooper = null;
                mRunner = null;
            }