예제 #1
0
    public bool canRequestIdleInteractable(AnimalAI animal)
    {
        InteractableZone zone = findMyZone(animal);

        if (zone != null)
        {
            Interactable interactable = zone.getAvailableRallySpot();
            if (interactable != null)
            {
                return(true);
            }
        }
        return(false);
    }
예제 #2
0
    public Interactable requestIdleInteractable(AnimalAI animal)
    {
        InteractableZone zone = findMyZone(animal);

        if (zone != null)
        {
            Interactable interactable = zone.getAvailableRallySpot();
            if (interactable != null)
            {
                interactable.reserve(animal);
                return(interactable);
            }
        }
        return(null);
    }
예제 #3
0
    public bool shouldGoToRally(Scorer scorer)
    {
        scorer.score = animalConfig.rallyScore;

        InteractableZone zone = zoneManager.findMyZone(this);

        if (zone != null && zone.type == InteractableZone.ZoneType.Rally)
        {
            return(false);
        }

        Scorer dummy = new Scorer();

        return(!isFar(dummy) || perception.hasNoFlock);
    }
예제 #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);
        }
    }
예제 #5
0
    public Transform findRallyZone(AnimalAI animal)
    {
        InteractableZone candidate = null;
        int bestCount                 = 0;
        int currentCount              = 0;
        int leastOccupiedZone         = int.MaxValue;
        InteractableZone clearestZone = null;

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

            if (currentCount > bestCount)
            {
                bestCount = currentCount;
                candidate = zone;
            }

            int animalCount = zone.getAllAnimalCount();
            if (animalCount <= leastOccupiedZone)
            {
                leastOccupiedZone = animalCount;
                clearestZone      = zone;
            }
        }

        if (candidate == null)
        {
            return(clearestZone.transform);
        }
        else
        {
            return(candidate.transform);
        }
    }