示例#1
0
    private IEnumerator Animate(float zPos)
    {
        if (Utility.Approximately(leftDoor.transform.localPosition.z, zPos, .001f))
        {
            yield break;
        }

        animatingState = state;

        yield return(new WaitForSeconds(state.Equals(SlidingDoorState.Close) ? delay / 2 : delay));

        if (IE_RightDoor != null)
        {
            StopCoroutine(IE_RightDoor);
        }
        if (IE_LeftDoor != null)
        {
            StopCoroutine(IE_LeftDoor);
        }

        IE_RightDoor = Move(rightDoor, -zPos);
        IE_LeftDoor  = Move(leftDoor, zPos);

        PlaySound(state.Equals(SlidingDoorState.Open) ? openSFX : closeSFX);

        StartCoroutine(IE_RightDoor);
        StartCoroutine(IE_LeftDoor);


        while (animating)
        {
            yield return(null);
        }
    }
示例#2
0
 public override void Break()
 {
     broken = true;
     transform.localPosition = endPos.localPosition;
     enabled = false;
     base.Break();
     slidingDoorState = SlidingDoorState.OPENED;
 }
示例#3
0
 public override void Reset()
 {
     base.Reset();
     timeFadeRTPC = 0.0f;
     slideRtpc    = 0.0f;
     startRtpc    = 0.0f;
     AkSoundEngine.SetRTPCValue(rtpcName, 0.0f);
     //isActivated = false;
     isActivating = false;
     forcedState  = false;
     AkSoundEngine.PostEvent(stopDoorMoveSound, gameObject);
     if (isBroken)
     {
         Break();
     }
     else
     {
         transform.localPosition = startPosition.localPosition;
         slidingDoorState        = SlidingDoorState.CLOSED;
     }
 }
示例#4
0
 public void Close()
 {
     state = SlidingDoorState.Close;
     StartAnimating();
 }
示例#5
0
 public void Open()
 {
     state = SlidingDoorState.Open;
     StartAnimating();
 }
示例#6
0
 private void Update()
 {
     if (broken)
     {
         return;
     }
     update_state();
     if (slidingDoorState == SlidingDoorState.GOING_UP)
     {
         distance = endPos.localPosition.y - transform.localPosition.y;
         if (distance > 0.01f)
         {
             if (!isPlayingSound)
             {
                 isPlayingSound = true;
                 AkSoundEngine.PostEvent(playDoorMoveSound, gameObject);
                 startRtpc    = slideRtpc;
                 timeFadeRTPC = fadeRTPCDuration * (startRtpc / maxSlidingRTPC);
             }
             if (timeFadeRTPC < fadeRTPCDuration)
             {
                 timeFadeRTPC += Time.deltaTime;
                 slideRtpc     = (timeFadeRTPC / fadeRTPCDuration) * maxSlidingRTPC;
                 AkSoundEngine.SetRTPCValue(rtpcName, slideRtpc);
             }
             else
             {
                 timeFadeRTPC = fadeRTPCDuration;
                 slideRtpc    = maxSlidingRTPC;
                 AkSoundEngine.SetRTPCValue(rtpcName, slideRtpc);
             }
             transform.localPosition += (transform.up) * Time.deltaTime * moveUpSpeed;
         }
         else
         {
             transform.localPosition = endPos.localPosition;
             AkSoundEngine.PostEvent(stopDoorMoveSound, gameObject);
             AkSoundEngine.PostEvent(playDoorHitsWallSound, gameObject);
             isPlayingSound   = false;
             slidingDoorState = SlidingDoorState.OPENED;
         }
     }
     else if (slidingDoorState == SlidingDoorState.GOING_DOWN)
     {
         distance = transform.localPosition.y - startPosition.localPosition.y;
         if (distance > 0.01f)
         {
             if (!isPlayingSound)
             {
                 isPlayingSound = true;
                 AkSoundEngine.PostEvent(playDoorMoveSound, gameObject);
                 startRtpc    = slideRtpc;
                 timeFadeRTPC = fadeRTPCDuration * (Mathf.Abs(startRtpc - minSlidingRTPC) / (maxSlidingRTPC - minSlidingRTPC));
             }
             if (timeFadeRTPC < fadeRTPCDuration)
             {
                 timeFadeRTPC += Time.deltaTime;
                 slideRtpc     = Mathf.Lerp(startRtpc, minSlidingRTPC, timeFadeRTPC);
             }
             else
             {
                 timeFadeRTPC = fadeRTPCDuration;
                 slideRtpc    = minSlidingRTPC;
                 AkSoundEngine.SetRTPCValue(rtpcName, slideRtpc);
             }
             transform.localPosition += (transform.up * -1) * Time.deltaTime * moveDownSpeed;
         }
         else
         {
             transform.localPosition = startPosition.localPosition;
             AkSoundEngine.PostEvent(stopDoorMoveSound, gameObject);
             AkSoundEngine.PostEvent(playDoorHitsWallSound, gameObject);
             isPlayingSound   = false;
             slidingDoorState = SlidingDoorState.CLOSED;
         }
     }
 }
示例#7
0
 public override void Desactivate()
 {
     slidingDoorState = SlidingDoorState.GOING_DOWN;
     AkSoundEngine.PostEvent(stopDoorMoveSound, gameObject);
     isPlayingSound = false;
 }
示例#8
0
 public void Resume()
 {
     slidingDoorState = saveState;
 }
示例#9
0
 public void Stop()
 {
     saveState        = slidingDoorState;
     slidingDoorState = SlidingDoorState.CLOSED;
 }