public AudioChannelManager(Transform root, int sfxChannelCount, int bgmChannelCount, float fadeDuration) { sfxChannels = new AudioSource[sfxChannelCount]; for (int sfxChannelIndex = 0; sfxChannelIndex < sfxChannelCount; sfxChannelIndex++) { GameObject channelBody = new GameObject(); channelBody.name = "SfxChan_" + sfxChannelIndex; channelBody.transform.parent = root; sfxChannels[sfxChannelIndex] = channelBody.AddComponent <AudioSource>() as AudioSource; sfxChannels[sfxChannelIndex].gameObject.SetActive(false); sfxChannels[sfxChannelIndex].playOnAwake = false; } inherentSfxClipVolumes = new float[sfxChannelCount]; bgmChannels = new AudioSource[bgmChannelCount]; for (int bgmChannelIndex = 0; bgmChannelIndex < bgmChannelCount; bgmChannelIndex++) { GameObject channelBody = new GameObject(); channelBody.name = "BgmChan_" + bgmChannelIndex; channelBody.transform.parent = root; bgmChannels[bgmChannelIndex] = channelBody.AddComponent <AudioSource>() as AudioSource; bgmChannels[bgmChannelIndex].gameObject.SetActive(false); bgmChannels[bgmChannelIndex].playOnAwake = false; fadeTimer = new CountdownTimer(NopactUtility.GenerateId(), fadeDuration, CountdownScope.Menu, true, (s) => OnFadeTimerComplete(s), (t, p) => OnFadeTimerPercentage(t, p)); } onCompleteRegistry = new Action[sfxChannels.Length + bgmChannelCount]; onDelayedCompleteTimes = new float[sfxChannels.Length]; }
// Use this method for timescale-independent timers. // e.g. timers that you want to tick even if the game is paused. public string RegisterScaleIndependentTimer(float duration, CountdownScope scope, Action <string> callback, Action <string, float> percentCallback = null) { CountdownTimer timer = new CountdownTimer(NopactUtility.GenerateId(), duration, scope, false, callback, percentCallback); realTimers.Add(timer); return(timer.Id); }
protected GameScreenFlow(string cameraPositionKey, Transform cameraTarget, Ease cameraEase, float cameraMotionDelay, Dictionary <string, Transform> gamePlayCameraPositions, Action onDone, Action onActivateUI) { CameraPositionKey = cameraPositionKey; CameraTarget = cameraTarget; CameraEase = cameraEase; CameraMotionDuration = cameraMotionDelay; GamePlayCameraPositions = gamePlayCameraPositions; OnDone = onDone; OnActivateUI = onActivateUI; FlowTimer = new CountdownTimer(NopactUtility.GenerateId(), 0.0f, Commons.Domain.Enum.CountdownScope.Game, true, (id) => OnFlowTimerComplete(id), null); }