Exemple #1
0
    private void ChooseBehaviour()
    {
        if (GetComponent <SleepingBehaviour>() != null)
        {
            return;
        }

        GameObject danger = locator.LocateByTag("Zombie", dangerRange);

        if (danger != null)
        {
            move.Flee            = true;
            move.TargetTransform = danger.transform;
            eating.Target        = null;
            return;
        }
        move.Flee            = false;
        move.TargetTransform = null;

        if (ShouldReproduce())
        {
            GameObject mate = locator.LocateByTag("Carnivore", reproductionRange);
            if (mate != null)
            {
                reproduce.Reproduce();
                move.TargetTransform = null;
            }
            else
            {
                move.TargetTransform = LocatorBehaviour.GetClosest(transform, carnivores);
            }
        }
        else if (IsHungry())
        {
            GameObject food = locator.LocateByTag("Herbivore", eatRange);
            if (food != null)
            {
                eating.Target        = food.transform;
                move.TargetTransform = null;
            }
            else
            {
                move.TargetTransform = LocatorBehaviour.GetClosest(transform, herbivores);
            }
        }
        else
        {
            GameObject mate = locator.LocateByTag("Carnivore", reproductionRange);
            if (mate == null)
            {
                move.TargetTransform = LocatorBehaviour.GetClosest(transform, carnivores);
            }
        }
    }
Exemple #2
0
    private void ChooseBehaviour()
    {
        if (!isZombie)
        {
            return;
        }

        if (GetComponent <SleepingBehaviour>() != null)
        {
            return;
        }

        GameObject target = locator.LocateByTag("Carnivore", eatRange);

        if (target != null)
        {
            eating.Target = target.transform;
        }
        else
        {
            move.TargetTransform = LocatorBehaviour.GetClosest(transform, carnivores);
        }
    }