コード例 #1
0
 void HandleInteractions()
 {
     if (currentAction == CreatureAction.Eating)
     {
         if (foodTarget && hunger > 0)
         {
             float eatAmount = Mathf.Min(hunger, Time.deltaTime * 1 / eatDuration);
             Plant plant     = foodTarget as Plant;
             if (plant != null)
             {
                 eatAmount = plant.Consume(eatAmount);
                 hunger   -= eatAmount;
             }
         }
     }
     else if (currentAction == CreatureAction.Drinking)
     {
         if (thirst > 0)
         {
             thirst -= Time.deltaTime * 1 / drinkDuration;
             thirst  = Mathf.Clamp01(thirst);
         }
     }
 }