Exemplo n.º 1
0
    public void Condition(BiologyAI Ai)
    {
        BiologyAI = Ai;


        for (int i = 0; i < Ai.ConditionList.Count; i++)
        {
            //清空上一個目標與上一個行為
            BiologyAI.Parent.Target = null;
            Target     = null;
            ActionName = null;

            //如果我已經死則清空目標並跳出
            if (BiologyAI.Parent.BiologyAttr.Hp <= 0)
            {
                BiologyAI.Parent.Target = null; return;
            }

            //如果資料庫無此策略跳下一個
            if (Conditions.ContainsKey(Ai.ConditionList[i]) == false)
            {
                continue;
            }

            //如果此策略找不到目標則跳下一個
            //在這裡決定 Target 是誰
            Func <float, bool> f  = Conditions[Ai.ConditionList[i]].Func;
            float cp              = Conditions[Ai.ConditionList[i]].p1;
            bool  ConditionResult = f(cp);
            if (ConditionResult == false)
            {
                continue;
            }

            //取得該策略對應的行為
            ConditionName = Ai.ConditionList[i];
            ActionName    = Ai.ActionList[i];

            //檢查該行為是否可以執行
            if (BiologyAI_Action.Instance.CheckAction(this, Target) == false)
            {
                continue;
            }

            //持續思考(重頭)
            return;
        }
    }
Exemplo n.º 2
0
 private void SetBiologyAI()
 {
     BiologyAI = new BiologyAI(this, Ai);
 }