コード例 #1
0
    /// <summary>
    /// Tests a set of conditions to ensure that the behavior tree is functional
    /// </summary>
    /// <returns></returns>
    private bool ValidateAndSetRootNode()
    {
        if (runtimeTree == null)
        {
            Debug.LogWarning("runtimeTree is null - Behaviour tree will not run - Add a Behaviour Tree to the RuntimeBehaviourTree Script");
            return(false);
        }

        List <BTRoot> rootNodeList = new List <BTRoot>();

        foreach (Node _node in runtimeTree.nodes)
        {
            BTRoot root = _node as BTRoot;
            if (root != null)
            {
                rootNodeList.Add(root);
            }
        }

        if (rootNodeList.Count != 1)
        {
            Debug.LogWarning("There is no root node or more than 1 root node in this behaviourTree - BehaviourTree will not run - Make sure there is exactly 1 BTRoot node in your graph");
            return(false);
        }
        else
        {
            rootNode = rootNodeList[0];
        }

        return(true);
    }
コード例 #2
0
ファイル: Frog.cs プロジェクト: chickening/TeemoRPG
    protected override void Start()
    {
        base.Start();
        skillReaderList.Add(new SkillReader(SkillManager.FindSkill("FrogGeneralAttack")));
        BT BTAttack = BT.Sequence
                      (
            BT.Call(GeneralAttack)
                      );
        BT BTPatrol = BT.Sequence
                      (
            BT.Success(BT.Call(RandomWayPoint)),
            BT.Success(BT.Call(FindAroundEnemy)),
            BT.Condition(() => { return(!isFoundEnemy); }, BT.Call(Move))
                      );

        AI = BT.Root
             (
            BT.Sequence
            (
                BT.Success(BT.Call(FindAroundEnemy)),
                BT.Selector
                (
                    BT.Condition(() => { return(isFoundEnemy); }, BTAttack),
                    BT.Probability(0.3f * Time.fixedDeltaTime, BTPatrol)
                )
            )
             );
        moveMaxDelay = new Delay();
    }
コード例 #3
0
    /// <summary>
    /// Checks if the connected behavior tree is valid and has a root node
    /// </summary>
    /// <returns></returns>
    private bool ValidateAndSetRootNode()
    {
        if (subTree == null)
        {
            Debug.LogWarning("subTree is null - tree will not run");
            return(false);
        }

        List <BTRoot> rootNodeList = new List <BTRoot>();

        foreach (Node _node in subTree.nodes)
        {
            BTRoot root = _node as BTRoot;
            if (root != null)
            {
                rootNodeList.Add(root);
            }
        }

        if (rootNodeList.Count != 1)
        {
            Debug.LogWarning("There is no root node or more than 1 root node in this subTree - subtree will not run - Make sure there is exactly 1BTRoot node in your graph");
            return(false);
        }
        else
        {
            subTreeRoot = rootNodeList[0];
        }

        return(true);
    }
コード例 #4
0
        public void AddBtRoot(string Id)
        {
            BTRoot bt = new BTRoot();

            bt.Id = Id;
            m_BTRoots.Add(bt);
        }
コード例 #5
0
    void Start()
    {
        attackTimer = unitData.fireRate - 1;

        rootAI = new BTRoot(new List <BTNode>()
        {
            CombatSequence(),
        });
    }
コード例 #6
0
ファイル: HeroLogic.cs プロジェクト: Enanyy/LuaGame-slua
 public void Tick(string config, ref BTInput input)
 {
     if (string.IsNullOrEmpty(config))
     {
         return;
     }
     if (mBattleLogicDic.ContainsKey(config) == false)
     {
         BTRoot root = new BTRoot();
         AIConfig.ReadXML(config, root);
         mBattleLogicDic.Add(config, root);
     }
     mBattleLogicDic[config].Tick(ref input);
 }
コード例 #7
0
ファイル: AIConfig.cs プロジェクト: Enanyy/LuaGame-slua
 public static void ReadXML(string name, BTRoot root)
 {
     /*string assetBundleName = string.Format("assets/assetbundle/config/character/ai/{0}.xml", name.ToLower());
      * AssetCache.LoadAssetAsync<TextAsset>(assetBundleName, assetBundleName, (asset) =>
      * {
      *  if (asset != null)
      *  {
      *
      *      TextAsset text = asset.GetAsset() as TextAsset;
      *
      *      if (text!=null)
      *      {
      *          root.InitXML(text.bytes);
      *      }
      *  }
      * });
      */
 }
コード例 #8
0
        private void InitTextMesh(BTRoot root)
        {
            if (root.GetComponent <TextMeshPro>())
            {
                return;
            }

            var text = root.gameObject.AddComponent <TextMeshPro>();
            var rect = root.GetComponent <RectTransform>();

            rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 2.2f);
            rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 1f);

            text.enableAutoSizing = true;
            text.fontSizeMin      = 0;
            text.fontSizeMax      = 5;
            text.fontStyle        = FontStyles.Bold;
            text.lineSpacing      = -2f;
            text.alignment        = TextAlignmentOptions.Midline;
        }
コード例 #9
0
ファイル: BTActionNode.cs プロジェクト: moto2002/FrameLock
 public BTActionNode(BTRoot ai, BTNodeData config) : base(ai, config)
 {
 }
コード例 #10
0
 protected void PopulateBtNodes(List <BTNode> btNodes)
 {
     rootAI = new BTRoot(btNodes);
 }