示例#1
0
文件: Agent.cs 项目: weichx/SpaceGame
        public void DecideAction()
        {
            //todo -- if time elapsed || activeAction.IsComplete;

            AIAction[] actions = activeBehavior.actions;

            activeAction = null;
            float maxScore = float.MinValue;
            int   length   = actions.Length;

            for (int i = 0; i < length; i++)
            {
                AIAction action = actions[i];
                float    score  = action.Score(activeContext, maxScore);
                if (score > maxScore)
                {
                    maxScore     = score;
                    activeAction = action;
                }
            }

            Debug.Assert(activeAction != null, nameof(activeAction) + " != null");
            activeAction.SetContext(activeContext);
            activeAction.OnSetup();
        }
示例#2
0
 public AIInfo(int entityId)
 {
     this.entityId         = entityId;
     this.lastDecisionTime = 0;
     this.decisionDuration = 0;
     this.action           = null;
     this.decisions        = null;
 }