Example #1
0
    protected override bool onUpdate(float deltaTime)
    {
        if (getAnimal().DEBUG)
        {
            Debug.Log("A_RejoindreTroupe ...");
        }
        GameObject obj = GameObject.Find("LoupAlpha");

        if (obj == null)
        {
            getAnimal().fd(0);
            return(true);
        }

        LoupAlpha     alpha    = obj.GetComponent <LoupAlpha>();
        PerceptView   percepts = getAnimal().perceptView;
        List <Living> list     = percepts.getLiving();

        if (!diriged)
        {
            diriged = true;
            MemoryBloc memBlock = getAnimal().GetComponent <Memory>().getMemoryForIdentity(alpha.getIdentity());
            if (memBlock != null)
            {
                getAnimal().faceTo(memBlock.getLastPosition());
                getAnimal().fd(0.01f);
            }
            return(true);
        }

        getAnimal().displayStaticEmoticon(getAnimal().questionEmoticonSprite);

        if (list.Contains(alpha))
        {
            getAnimal().hideStaticEmoticon();


            getActionPendlingList().removeAction(this);
            return(true);
        }

        MemoryBloc mem = getAnimal().GetComponent <Memory>().getMemoryForIdentity(alpha.getIdentity());

        if (mem != null)
        {
            getAnimal().faceTo(mem.getLastPosition());
            getAnimal().wiggle(getAnimal().vitesse * 3f, 2);
        }
        else
        {
            getAnimal().rt(5);
            getAnimal().fd(0.001f, false, false);
        }

        getActionPendlingList().removeAction(this);
        return(true);
    }
Example #2
0
    protected override bool onUpdate(float deltaTime)
    {
        GameObject obj = GameObject.Find("LoupAlpha");

        if (obj == null)
        {
            return(true);
        }
        LoupAlpha alpha = obj.GetComponent <LoupAlpha>();

        if (!diriged)
        {
            diriged = true;
            MemoryBloc memBlock = getAnimal().GetComponent <Memory>().getMemoryForIdentity(alpha.getIdentity());
            if (memBlock != null)
            {
                getAnimal().faceTo(memBlock.getLastPosition());
                getAnimal().fd(0.01f, false, false);
            }
            return(true);
        }

        PerceptView   percepts = getAnimal().perceptView;
        List <Living> list     = percepts.getLiving();

        if (list.Contains(alpha))
        {
            if (Vector2.Distance(alpha.GetComponent <Transform>().position, getAnimal().GetComponent <Transform>().position) > 1)
            {
                getAnimal().setAgentToDontDodge(alpha);
                getAnimal().faceTo(alpha);
                getAnimal().wiggle(getAnimal().vitesse * 1.1f, 2);
                return(true);
            }

            getAnimal().emoticonSystem.displayAnimatedEmoticon(getAnimal().heartEmoticonSprite);
            getAnimal().lt(180);
            getActionPendlingList().removeAction(this);
            if (getAnimal() as LoupBeta != null)
            {
                LoupBeta beta = (LoupBeta)getAnimal();
                beta.threat -= Mathf.Min(beta.THREAT_MAX * .65f, beta.threat);
            }
            return(false);
        }

        MemoryBloc mem = getAnimal().GetComponent <Memory>().getMemoryForIdentity(alpha.getIdentity());

        if (mem != null)
        {
            getAnimal().faceTo(mem.getLastPosition());
            getAnimal().wiggle(getAnimal().vitesse, 2);
        }
        else
        {
            getAnimal().rt(1);
            getAnimal().fd(0.0001f, false, false);
        }

        return(true);
    }