예제 #1
0
 public bool hasNeedsInteractable(Interactable.Type t)
 {
     for (int i = 0; i < needsInteractables.Count; i++)
     {
         if (needsInteractables[i].getType() == t &&
             needsInteractables[i].isAvailable())
         {
             return(true);
         }
     }
     return(false);
 }
예제 #2
0
    public float getConsumption(Interactable.Type type)
    {
        switch (type)
        {
        case Interactable.Type.Food:
            return(animalConfig.hungerRecuperation * Time.deltaTime);

        case Interactable.Type.Rest:
            return(animalConfig.fatigueRecuperation * Time.deltaTime);

        default:
            return(0.0f);
        }
    }
예제 #3
0
    private bool itemFoundImplementation(Interactable.Type desiredType)
    {
        if (blackboard.ContainsKey("InteractableTarget"))
        {
            return(true);
        }

        foreach (Interactable interactable in perception.interactablesInRange)
        {
            if (interactable.type == desiredType && interactable.isAvailable())
            {
                blackboard["InteractableTarget"] = interactable;
                interactable.reserve(this);
                return(true);
            }
        }

        return(false);
    }
예제 #4
0
    public Transform findInteractableZone(AnimalAI animal, Interactable.Type type)
    {
        InteractableZone candidate = null;
        int highestCount           = int.MaxValue;
        int currentCount           = 0;

        float            closestDistance = float.MaxValue;
        InteractableZone closestZone     = needsZones[0];

        foreach (InteractableZone zone in needsZones)
        {
            if (zone.hasNeedsInteractable(type))
            {
                currentCount = zone.getAnimalCount(animal.getSpecies());
                if (zone.isAnimalInZone(animal))
                {
                    currentCount--;
                }

                if (currentCount < highestCount)
                {
                    highestCount = currentCount;
                    candidate    = zone;
                }

                float currentDistance = (zone.transform.position - animal.transform.position).magnitude;
                if (currentDistance <= closestDistance)
                {
                    closestDistance = currentDistance;
                    closestZone     = zone;
                }
            }
        }
        if (candidate == null)
        {
            return(closestZone.transform);
        }
        else
        {
            return(candidate.transform);
        }
    }