Ejemplo n.º 1
0
 public PlannerNode(PlannerNode parent, float runningCost, HashSet <KeyValuePair <string, object> > state, GOAPAction action)
 {
     Parent      = parent;
     RunningCost = runningCost;
     _state      = state;
     Action      = action;
 }
Ejemplo n.º 2
0
 public GOAPAction GetAction(GOAPAction action)
 {
     foreach (GOAPAction a in _availableActions)
     {
         if (a.GetType().Equals(action.GetType()))
         {
             return(a);
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// create a subset of actions excluding the removeMe one. Creates a new set
        /// </summary>
        /// <param name="actions"></param>
        /// <param name="removeMe"></param>
        /// <returns></returns>
        private HashSet <GOAPAction> ActionSubset(HashSet <GOAPAction> actions, GOAPAction removeMe)
        {
            HashSet <GOAPAction> subset = new HashSet <GOAPAction>();

            foreach (GOAPAction a in actions)
            {
                if (!a.Equals(removeMe))
                {
                    subset.Add(a);
                }
            }

            return(subset);
        }
Ejemplo n.º 4
0
        public bool MoveAgent(GOAPAction nextAction)
        {
            Debug.Log("Moving");

            float step = moveSpeed * Time.deltaTime;

            gameObject.transform.position = Vector3.MoveTowards(gameObject.transform.position, nextAction.Target.transform.position, step);

            if (gameObject.transform.position.Equals(nextAction.Target.transform.position))
            {
                nextAction.IsInRange = true;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
 public void PlanAborted(GOAPAction aborter)
 {
 }
Ejemplo n.º 6
0
 public void RemoveAction(GOAPAction action)
 {
     _availableActions.Remove(action);
 }
Ejemplo n.º 7
0
 public void AddAction(GOAPAction action)
 {
     _availableActions.Add(action);
 }