Exemple #1
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator anim, AnimatorStateInfo stateInfo, int layerIndex)
    {
        cb = anim.GetComponentInParent <script_childBehaviour>();

        rb = anim.GetComponentInParent <Rigidbody>();

        mc = anim.GetComponentInChildren <script_maskController>();
        mc.free();

        rb.isKinematic = false;

        bool cond = cb.asthmatic;

        if (cond)
        {
            nextState = childState.idle;
        }

        switch (nextState)
        {
        case childState.idle:
            anim.SetTrigger("idle");
            break;

        case childState.walk:
            anim.SetTrigger("walk");
            break;

        case childState.run:
            cb.startRunning(true);
            anim.SetTrigger("run");
            break;
        }
    }
Exemple #2
0
    public void spawnManyKids(float number)
    {
        for (int i = 0; i < number; i++)
        {
            GameObject obj = spawnKid();

            script_childBehaviour behaviour = obj.GetComponent <script_childBehaviour>();
            behaviour.init();
            if (i == 0)
            {
                behaviour.setAsthmatic();
                obj.GetComponent <script_audioScript>().startWorking();
            }
            else
            {
                script_audioScript a = obj.GetComponent <script_audioScript>();
                AudioSource        s = obj.GetComponent <AudioSource>();
                if (a)
                {
                    Destroy(a);
                }
                if (s)
                {
                    Destroy(s);
                }
            }

            if (Random.Range(0f, 1f) < pctWalking)
            {
                behaviour.changeState(childState.walk);
            }
        }
        Destroy(generatedObject);
    }
Exemple #3
0
    void outlineHandler()
    {
        if (lastMaterial)
        {
            lastMaterial.SetFloat("Vector1_ADB1664", 0f);
        }
        RaycastHit hit;

        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, rayDistance, layerMask))
        {
            script_childBehaviour behaviour = hit.transform.GetComponent <script_childBehaviour>();
            if (!behaviour.checkedMask)
            {
                actualMaterial = behaviour.outlineMatRef.materials[1];
                actualMaterial.SetFloat("Vector1_ADB1664", 1f);
            }
        }
        if (actualMaterial)
        {
            lastMaterial = actualMaterial;
        }
    }