Esempio n. 1
0
        private void GenerateTags()
        {
            if (IsGlutenFree)
            {
                FoodTags.Add(new FoodTagDocument("Senza glutine", "Gluten free"));
            }

            if (!IsVeg && IsNonVeg)
            {
                FoodTags.Add(new FoodTagDocument("Cibo non vegano", "Non-Veg"));
            }

            if (!IsNonVeg && IsVeg)
            {
                FoodTags.Add(new FoodTagDocument("Cibo vegano", "Vegan"));
            }
        }
Esempio n. 2
0
 //stays in place until time is up, returns to village
 protected int Gather(GameObject targetObject)
 {
     if (!human.IsWithinReach(targetObject))
     {
         human.targetObject = null;
         human.UpdateDecision();
         return(0);
     }
     foreach (Transform t in targetObject.transform)
     {
         if (FoodTags.Contains(t.tag))
         {
             prop["food"] = Mathf.Max(Convert.ToSingle(prop["food"]) + 1, Convert.ToSingle(prop["foodLimit"]));                 //milliseconds
             targetObject.SendMessage("EatBerries");
             human.hasFood = true;
             human.UpdateDecision();
             return(0);
         }
     }
     return(0);
 }
Esempio n. 3
0
    //stays in place until time is up, returns to village
    protected int Gather(GameObject targetObject)
    {
        if (!human.IsWithinReach(targetObject))
        {
            human.targetObject = null;
            human.UpdateDecision();
            return(0);
        }
        if (targetObject.tag == "AnimalMeat")
        {
            prop["food"]       = Mathf.Max(Convert.ToSingle(prop["foodLimit"]), Convert.ToSingle(targetObject.GetComponent <PropertyTracker>()["size"]) + Convert.ToSingle(prop["food"]));      //milliseconds
            human.hasFood      = true;
            human.targetObject = null;
            human.UpdateDecision();
            Debug.Log(this + "'s food is now: " + prop["food"]);
            return(0);
        }
        bool attacked = false;

        movement.PathTo(targetObject.transform.position);
        foreach (Transform t in targetObject.transform)
        {
            if (FoodTags.Contains(t.tag))
            {
                human.Attack(targetObject.GetComponent <Animal>());
                attacked = true;
                break;
            }
        }
        if (!attacked)
        {
            human.UpdateDecision();
        }


        return(0);
    }
Esempio n. 4
0
    // Update is called once per frame
    public override void Update()
    {
        base.Update();
        switch (state)
        {
        case States.Searching: {
            GameObject check = CheckForFood();
            if (check != null && IsInSight(check))
            {
                UpdateDecision();
            }
            else
            {
                target = Wander();
                movement.PathTo(target);
            }
            break;
        }

        case States.Seeking: {
            if (targetObject == null)
            {
                targetObject = CheckForFood();
            }
            int result = SeekFood(targetObject);
            if (result == 2 && targetObject.GetComponent <Player>() == null)
            {
                foreach (Transform t in targetObject.transform)
                {
                    if (FoodTags.Contains(t.tag))
                    {
                        state = States.Gathering;
                    }
                }
                if (state != States.Gathering)
                {
                    UpdateDecision();
                }
            }
            else if (result == 0 && targetObject == null || targetObject.GetComponent <Player>() == null)
            {
                UpdateDecision();
            }
            else
            {
                if (FoodTags.Contains(targetObject.tag))
                {
                    targetObject.GetComponent <Collider>().isTrigger = true;
                }
            }

            break;
        }

        case States.Gathering: {
            if (targetObject != null)
            {
                Gather(targetObject);
            }
            else
            {
                UpdateDecision();
            }
            break;
        }

        case States.Returning: Return(); break;
        }

        this.gameObject.SendMessage("SetDebugMessage", "State: " + state);
    }