Esempio n. 1
0
        public override void Run(IReGoapAction <string, object> previous, IReGoapAction <string, object> next,
                                 ReGoapState <string, object> settings, ReGoapState <string, object> goalState,
                                 Action <IReGoapAction <string, object> > done, Action <IReGoapAction <string, object> > fail)
        {
            base.Run(previous, next, settings, goalState, done, fail);

            //record what food you have
            food = pickedFood.GetComponent <DetsFood>();

            //run code to make food destroy itself
            pickedFood.GetComponent <DetsFood>().PickedUp();

            //move to child
            doneCallback(this);
        }
Esempio n. 2
0
        protected override void Awake()
        {
            base.Awake();
            Name = "actionMoveToFood";
            preconditions.Set("childHungry", true);
            preconditions.Set("foundFood", true);
            preconditions.Set("move", false);
            preconditions.Set("hasFood", true);
            preconditions.Set("nearChild", true);
            
            effects.Set("foundFood", false);
            effects.Set("hasFood", false);
            effects.Set("childHungry", true);

            food = GetComponent<ActionPickUpFood>().food;
            child = GameObject.FindWithTag("child");

        }
Esempio n. 3
0
        public void FoundSomething()
        {
            pause = true;
            DetsFood foodFound = foundObj.GetComponent <DetsFood>();

            //check if you found food
            if (foodFound == null)
            {
                //if no, pause ends
                pause = false;
            }
            else
            {
                //food was food
                if (foodFound.useable == false)
                {
                    //you cant reach this food, ignore it
                    pause = false;
                }
                else
                {
                    //add food to the necessary ground
                    if (child.hungry == foodFound.hunger)
                    {
                        foodWanted.Add(foodFound);                                   //add to middle list
                    }
                    if (child.hungry < foodFound.hunger)
                    {
                        foodAbove.Add(foodFound);                                  //add to above list
                    }
                    if (child.hungry > foodFound.hunger)
                    {
                        foodBelow.Add(foodFound);                                  //add to under list
                    }
                    pause = false;
                }
            }
        }