Exemplo n.º 1
0
        public void EndSfxLoop(string id)
        {
            if (dataManager == null || channelManager == null)
            {
                return;
            }

            float     volume;
            AudioClip clip = dataManager.GetClip(id, out volume);

            if (clip == null)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.AppendFormat("[AudioProducer] Audio Clip \"{0}\" is not found in the database. (maybe you forgot to include?) ", id);

                DebugWrapper.LogError(sb.ToString());
                return;
            }

            int returnCode = channelManager.StopSfxLoop(clip);

            if (returnCode > -1)
            {
                return;
            }

            if (isDebug)
            {
                DebugWrapper.LogWarning("[AudioSystem] Cannot Stop Loop as it is inactive. Audio Clip Name:" + clip.name);
            }
        }
Exemplo n.º 2
0
 protected override void InitializeOnAwake()
 {
     if (appInfo == null)
     {
         DebugWrapper.LogError("npE: AppInfo not provided! Drag'n Drop App/AppInfo.asset in the inspector or create a new info asset.");
         DebugWrapper.Break();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Performs an action if this reference isn't null or prints error in DebugWrapper if it's null
 /// </summary>
 /// <param name="reference">this object reference</param>
 /// <param name="action">Action to perform if reference isn't null</param>
 public static void DoActionWithCheckReference(this Object reference, Action action)
 {
     if (reference != null)
     {
         action.Invoke();
     }
     else
     {
         DebugWrapper.LogError($"{nameof(reference)} is null! Assign the reference!",
                               DebugColors.Red);
     }
 }
Exemplo n.º 4
0
        private BaseWindow GetWindowByType(Type windowType)
        {
            if (!_typeToWindow.ContainsKey(windowType))
            {
                DebugWrapper.LogError($"This window type is not registered: {windowType}");
                return(null);
            }

            var window = _typeToWindow[windowType];

            return(window);
        }
Exemplo n.º 5
0
        private bool RegisterWindowType(BaseWindow window)
        {
            var windowType = window.GetType();

            if (_typeToWindow.ContainsKey(windowType))
            {
                DebugWrapper.LogError($"This window type is already registered: {windowType}");
                return(false);
            }

            _typeToWindow.Add(windowType, window);
            return(true);
        }
Exemplo n.º 6
0
    public static T Load()
    {
        if (File.Exists(Path.Combine(Application.dataPath, $"{typeof(T)}.save")))
        {
            BinaryFormatter bf     = new BinaryFormatter();
            FileStream      stream = new FileStream(Path.Combine(Application.dataPath, $"{typeof(T)}.save"), FileMode.Open);

            T data = bf.Deserialize(stream) as T;
            stream.Close();
            return(data);
        }

        DebugWrapper.LogError($"'{typeof(T)}.save' File Not Exist.");
        return(null);
    }
Exemplo n.º 7
0
        public AudioClip GetClip(string id, out float inherentVolume)
        {
            inherentVolume = 1.0f;

            AudioClipData outClipData;

            if (liveClipData.TryGetValue(id, out outClipData))
            {
                inherentVolume = outClipData.inherentVolume;

                return(outClipData.clip);
            }
            else
            {
                DebugWrapper.LogError("[AudioSystem] Sound id:" + id + " is invalid or you are trying to play it in a wrong load level");
            }

            return(null);
        }
Exemplo n.º 8
0
        public void PlaySfx(string id, float volume = 1.0f, float delay = 0.0f)
        {
            if (dataManager == null || channelManager == null)
            {
                return;
            }

            float     masterVolume;
            AudioClip clip = dataManager.GetClip(id, out masterVolume);

            if (clip == null)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.AppendFormat("[AudioProducer] Audio Clip \"{0}\" is not found in the database. (maybe you forgot to include?) ", id);

                DebugWrapper.LogError(sb.ToString());
                return;
            }
            channelManager.PlaySfxDelayed(delay, clip, volume);
        }
Exemplo n.º 9
0
        public void StartSfxLoop(string obj)
        {
            if (dataManager == null || channelManager == null)
            {
                return;
            }

            float     volume;
            AudioClip clip = dataManager.GetClip(obj, out volume);

            if (clip == null)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.AppendFormat("[AudioProducer] Audio Clip \"{0}\" is not found in the database. (maybe you forgot to include?) ", obj);

                DebugWrapper.LogError(sb.ToString());
                return;
            }

            channelManager.PlaySfxLoop(clip, volume);
        }
Exemplo n.º 10
0
        public BaseWindow ShowWindow(Type windowType)
        {
            var window = GetWindowByType(windowType);

            if (window.IsShown)
            {
                DebugWrapper.LogError(
                    $"This window is already shown: {windowType}\n{StackTraceUtility.ExtractStackTrace()}");
            }

            _shownWindows.Add(window);


            OnSomeWindowVisible?.Invoke(window);

            window.OnShow();

            UpdateZOrder(window);

            return(window);
        }
Exemplo n.º 11
0
        private AudioSource GetFreeChannel(bool isBgm, out int chanNr)
        {
            AudioSource[] channelList = isBgm ? bgmChannels : sfxChannels;

            for (int chanIndex = channelList.Length - 1; chanIndex > -1; chanIndex--)
            {
                if (!channelList[chanIndex].gameObject.activeSelf)
                {
                    channelList[chanIndex].volume = 1.0f;
                    channelList[chanIndex].gameObject.SetActive(true);
                    chanNr = chanIndex;
                    return(channelList[chanIndex]);
                }
            }

            string channelType = isBgm ? "BGM" : "SFX";

            DebugWrapper.LogError("[AudioSystem] No free channels. Sound is being dropped for " + channelType + " increase channel count!");
            chanNr = -1;
            return(null);
        }
Exemplo n.º 12
0
    IEnumerator CoLoadSpriteBundle(string filePath, string assetName)
    {
        using (loader = UnityWebRequestAssetBundle.GetAssetBundle(filePath, 0))
        {
            yield return(loader.SendWebRequest());

            if (loader.error != null)
            {
                DebugWrapper.LogError("어셋 번들 로딩 중에 문제가 발생했습니다.");
            }
            else
            {
                AssetBundle assetBundle = DownloadHandlerAssetBundle.GetContent(loader);

                SpriteAtlas atlas = assetBundle.LoadAsset <SpriteAtlas>(assetName);
                for (int i = 0; i < numberSprites.Length; ++i)
                {
                    numberSprites[i] = atlas.GetSprite($"JudgeAtlas_{i + 1}");
                }
            }
        }
    }
Exemplo n.º 13
0
    IEnumerator CoLoadAudioSource(string filePath, Dictionary <string, string> wavData)
    {
        UnityWebRequest www = null;

        foreach (KeyValuePair <string, string> p in wavData)
        {
            string url = Path.Combine(filePath, p.Value);

            AudioType type = AudioType.OGGVORBIS;

            int extensionCompareCount = 0;
            if (File.Exists(url))
            {
                while (extensionCompareCount < GlobalDefine.AVAILABLE_AUDIO_EXTENSIONS.Length)
                {
                    if (Path.GetExtension(url).Equals(GlobalDefine.AVAILABLE_AUDIO_EXTENSIONS[extensionCompareCount]))
                    {
                        break;
                    }
                    extensionCompareCount++;
                }
            }
            else
            {
                DebugWrapper.LogError($"{url} : 해당 경로가 존재하지 않습니다.");
            }

            switch (extensionCompareCount)
            {
            case 0:
                type = AudioType.OGGVORBIS;
                break;

            case 1:
                type = AudioType.WAV;
                break;

            case 2:
                type = AudioType.MPEG;
                break;
            }

            www = UnityWebRequestMultimedia.GetAudioClip(
                "file://" + url, type);

            yield return(www.SendWebRequest());

            if (www.downloadHandler.data.Length != 0)
            {
                AudioClip clip = DownloadHandlerAudioClip.GetContent(www);

                if (clip.LoadAudioData())
                {
                    AudioClipData.Add(p.Key, clip);
                }
            }
        }
        www.Dispose();

        SceneManager.LoadSceneAsync((int)eSceneName.SCENE_MAINGAME, LoadSceneMode.Single);
    }