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); } }
public override void Break() { broken = true; transform.localPosition = endPos.localPosition; enabled = false; base.Break(); slidingDoorState = SlidingDoorState.OPENED; }
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; } }
public void Close() { state = SlidingDoorState.Close; StartAnimating(); }
public void Open() { state = SlidingDoorState.Open; StartAnimating(); }
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; } } }
public override void Desactivate() { slidingDoorState = SlidingDoorState.GOING_DOWN; AkSoundEngine.PostEvent(stopDoorMoveSound, gameObject); isPlayingSound = false; }
public void Resume() { slidingDoorState = saveState; }
public void Stop() { saveState = slidingDoorState; slidingDoorState = SlidingDoorState.CLOSED; }