Exemple #1
0
    void Update()
    {
        if (ajar)
        {
            doorOpen = doorState.Closing;
            anim.Play(openClipName, defIndex, ajarPercentage);
            anim.speed = speedZero;
        }

        if (blocked || (PauseScript.a != null && PauseScript.a.paused))
        {
            Blocked();
        }
        else
        {
            if (PauseScript.a != null && !PauseScript.a.paused)
            {
                Unblocked();
            }
        }

        if (debugging)
        {
            Debug.Log("doorOpen state = " + doorOpen.ToString());
        }

        AnimatorStateInfo asi          = anim.GetCurrentAnimatorStateInfo(defIndex);
        float             playbackTime = asi.normalizedTime;

        //if (anim.GetCurrentAnimatorStateInfo(defIndex).IsName(idleClosedClipName))
        if (doorOpen == doorState.Closing && playbackTime > 0.95f)
        {
            doorOpen = doorState.Closed;              // Door is closed
        }
        //if (anim.GetCurrentAnimatorStateInfo(defIndex).IsName(idleOpenClipName))
        if (doorOpen == doorState.Opening && playbackTime > 0.95f)
        {
            doorOpen = doorState.Open;             // Door is open
        }
        if (Time.time > waitBeforeClose)
        {
            if ((doorOpen == doorState.Open) && (!stayOpen))
            {
                CloseDoor();
            }
        }

        if (lasersFinished < Time.time)
        {
            for (int i = defIndex; i < laserLines.Length; i++)
            {
                laserLines[i].SetActive(true);
            }
        }
    }