예제 #1
0
        private TreeDecision <GOAPAction> BuildPlansToAction(GOAPAction action)
        {
            var tree = new TreeDecision <GOAPAction>();

            tree.AddToRoot(action);

            var needConditions = new List <KeyValuePair <string, GOAPState> >();

            foreach (var condition in action.Preconditions)
            {
                if (!_context.Contains(condition))
                {
                    needConditions.Add(condition);
                }
            }

            if (needConditions.Count == 0)
            {
                return(tree);
            }

            foreach (var condition in needConditions)
            {
                TreeDecision <GOAPAction> conditionTree = BuildPlansToGoal(condition);

                if (conditionTree == null)
                {
                    return(null);
                }

                tree.AddToLeafs(conditionTree);
            }

            return(tree);
        }
예제 #2
0
 public void ReadXML(XElement xMainElement)
 {
     foreach (var xElement in xMainElement.Elements())
     {
         var action = new GOAPAction("Temporary Name");
         action.ReadXML(xElement);
         Add(action);
     }
 }