public void DialIn(PlotManager.PhoneCall phone) { targetPhoneCall = phone; _previousPage = _ps.GetCurrentState(); _ps.ChangeGameState("Phone_DemonCall"); var waitTime = 15f; _phoneRelatedCoroutine.Add(CoroutineManager.DoDelayCertainSeconds( Hang, waitTime)); }
public void DialOut(PlotManager.PhoneCall phone = null) { targetPhoneCall = phone; _previousPage = _ps.GetCurrentState(); _ps.ChangeGameState("Phone_OnCall"); var waitTime = 0f; if (phone == null) { waitTime = 15f; } else { waitTime = Random.Range(0f, 13f); } _phoneRelatedCoroutine.Add(CoroutineManager.DoDelayCertainSeconds( PhonePutThrough, waitTime)); }
public void PhonePutThrough() { //clear coroutine foreach (var coroutine in _phoneRelatedCoroutine) { CoroutineManager.StopCoroutine(coroutine); } _phoneRelatedCoroutine.Clear(); //plot mark targetPhoneCall?.OnCallPutThrough(); //change visual //TODO visual logic _ps.ChangeGameState("Phone_OnCall"); //start phone call audioclip if (targetPhoneCall != null) { _targetCallAudioPiece = new AudioPiece(targetPhoneCall.callContent, -1); } else { var audio = Services.audioManager.GetAudioClip("NoResponse", "PhoneCall/"); _targetCallAudioPiece = new AudioPiece(audio, -1); } _targetCallAudioPiece.onAudioFinished += () => { _ps.ChangeGameState(_previousPage); _previousPage = null; targetPhoneCall?.ChangePlotState(PlotManager.PlotState.Finished); targetPhoneCall = null; }; _targetCallAudioPiece.Play(); }
public void Hang() { //visually return if (!ReferenceEquals(_previousPage, null)) { _ps.ChangeGameState(_previousPage); _previousPage = null; } //if the phone hasn't put through yet, then it's broken if (_targetCallAudioPiece == null) { targetPhoneCall?.ChangePlotState(PlotManager.PlotState.Broke); targetPhoneCall = null; return; } else { //if(!_targetCallAudioPiece.audioSource.isPlaying) if (targetPhoneCall != null) { var timeRatio = _targetCallAudioPiece.audioSource.time / targetPhoneCall.callContent.length; if (timeRatio > 0.9f) { targetPhoneCall?.ChangePlotState(PlotManager.PlotState.Finished); } else { targetPhoneCall?.ChangePlotState(PlotManager.PlotState.Broke); } targetPhoneCall = null; } _targetCallAudioPiece.Stop(); _targetCallAudioPiece = null; } }