Пример #1
0
    public override void vivre()
    {
        Animal animal = (Animal)agent;

        if (animal.estMort())
        {
            animal.meurt();
            if (animal.quantiteDeViande <= 0)
            {
                Vector2 positionDuParadis = new Vector2(-5000, -5000);
                animal.transform.position = positionDuParadis;
            }
            return;
        }

        animal.hideStaticEmoticon();
        animal.resetAgentToDontDodge();
        animal.fd(0);


        if (agent.DEBUG)
        {
            Debug.Log("** Action en cours : " + actionList.getActualAction());
        }

        //Gestion des reflexes, fuite automatique
        if (animal.peutAvoirPeur && animal.besoinDeFuir())
        {
            actionList.addAction(new A_Fuite(animal.shoutSound));
        }

        //Gestion des bruits qui interpellent l'agent.
        if (animal.perceptHearing != null)
        {
            List <SoundPercepted>   sounds             = animal.perceptHearing.getSounds();
            List <SoundInformation> sonQuiInterpellent = animal.getSonsInterpellant();
            if (sounds.Count > 0)
            {
                for (int i = 0; i < sounds.Count; ++i)
                {
                    if (animal.getSonsInterpellant().Contains(sounds[i].soundInformation))
                    {
                        actionList.addAction(new A_RegarderVersLeBruit(sounds[i].identity));
                    }
                }
            }
        }

        actionList.execute(Time.deltaTime);
    }