Esempio n. 1
0
 public void CheckFullness()
 {
     //if dude is full, stop eating
     if (myProperties.getMetabolism() >= Parameters.Dude_StartingMetabolism)
     {
         myProperties.setMetabolism(Parameters.Dude_StartingMetabolism);
         myProperties.setBehavior(DudeBehavior.Idle);
         //release food when dude is done
         if (myProperties.getClaimedFood() != null)
         {
             myProperties.getClaimedFood().GetComponent <FoodController>().setClaimer(null);
         }
         myProperties.setClaimedFood(null);
     }
 }
Esempio n. 2
0
    public void ClaimFood()
    {
        //I don't know why this is happeing so this is a bandaid to avoid it
        //avoid bug of stalling in "looking for food" when food is claimed and in range, comment out this statement to debug
        if (myProperties.getClaimedFood() != null)
        {
            myProperties.getClaimedFood().GetComponent <FoodController>().setClaimer(null);
            myProperties.setClaimedFood(null);
        }

        //find things in eating range
        Collider[] thingsInEatingRange = Physics.OverlapSphere(transform.position, Parameters.Dude_EatingDistance);
        //iterate over list of things in eating range
        foreach (Collider thingInEatingRange in thingsInEatingRange)
        {
            //if the thing it found is food or the guy is really hungry and sees a corpse
            if (thingInEatingRange.gameObject.GetComponent <Attributes>().WhatAmI == ObjectType.FOOD ||
                (myProperties.getMetabolism() < Parameters.Dude_CannibalismThreshold &&
                 thingInEatingRange.gameObject.GetComponent <Attributes>().WhatAmI == ObjectType.CORPSE))
            {
                //if the food isn't already claimed
                if (thingInEatingRange.gameObject.GetComponent <FoodController>().getClaimer() == null)
                {
                    myProperties.setClaimedFood(thingInEatingRange.gameObject);
                    myProperties.getClaimedFood().GetComponent <FoodController>().setClaimer(gameObject);

                    /*Debug.Log("" +
                    *         "my corrdinates: " + transform.position +
                    *         "food coordinates: " + myProperties.getClaimedFood().transform.position
                    *         );
                    *  Debug.Break();*/
                    myProperties.setBehavior(DudeBehavior.Eating);
                    //clear his destination and foodtarget
                    myProperties.unsetDestination();
                    myProperties.setFoodTarget(null);
                    //dude stops checking once he claims food
                    break;
                }
            }
        }
    }