public static bool Load(string filePath, bool loop = false) { if (soundMgr == null) { soundMgr = GameMain.Instance.SoundMgr; } Debug.Log("LoadAndPlayAudioClip" + filePath); string extension = Path.GetExtension(filePath); if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath) || (extension != ".ogg" && extension != ".wav")) { if (!string.IsNullOrEmpty(filePath)) { Console.WriteLine(string.Format("{0}または{1}ファイルを指定してください。{2}", ".ogg", ".wav", filePath)); } return(false); } isLoaded = false; using (WWW www = new WWW("file:///" + filePath)) { int num = 0; while (!www.isDone) { Thread.Sleep(100); num += 100; if (30000 < num) { Console.WriteLine("音声読込タイムアウトのため処理を中止します。"); return(false); } } AudioClip audioClip = www.GetAudioClip(); if (audioClip.loadState == AudioDataLoadState.Loaded) { if (audiosource != null) { GameMain.Destroy(audiosource); audiosource = null; } if (audiosource == null) { audiosource = GameMain.Instance.MainCamera.gameObject.AddComponent <AudioSource>(); } if (audiosource != null) { audiosource.clip = audioClip; audiosource.loop = loop; isLoaded = true; } } } return(isLoaded); }
public void SetupInfoUI(bool bLocal, long coin, string name = "", uint faceId = 0, string url = "") { Transform tfm; if (!string.IsNullOrEmpty(url) || faceId != 0) { tfm = m_InfoUI.Find("left/Head/HeadMask/ImageHead"); tfm.GetComponent <Image>().sprite = GameMain.hall_.GetIcon(url, GameMain.hall_.GetPlayerId(), (int)faceId); } if (!string.IsNullOrEmpty(name)) { tfm = m_InfoUI.Find("left/TextName"); tfm.GetComponent <Text>().text = name; } m_nTotalCoin = coin; m_InfoUI.Find("left/ImageBG/ImageBG_own").gameObject.SetActive(bLocal); m_InfoUI.Find("left/ImageBG/ImageBG_other").gameObject.SetActive(!bLocal); Transform tfmOwnCoin = m_InfoUI.Find("right/Own/Image_coinframe"); tfmOwnCoin.gameObject.SetActive(bLocal); Transform tfmOtherCoin = m_InfoUI.Find("left/Image_coinframe"); tfmOtherCoin.gameObject.SetActive(!bLocal); if (bLocal) { tfm = m_InfoUI.Find("right/Own/Image_DiamondFrame/Text_Diamond"); tfm.GetComponent <Text>().text = GameMain.hall_.GetPlayerData().GetDiamond().ToString(); tfmOwnCoin.GetComponentInChildren <Text>().text = m_nTotalCoin.ToString(); tfm = m_InfoUI.Find("Middle/Anime"); GameObject obj = (GameObject)GameBase.FishingAssetBundle.LoadAsset("Anime_Sit"); obj = GameMain.Instantiate(obj); obj.transform.SetParent(tfm, false); obj.GetComponent <DragonBones.UnityArmatureComponent>() .animation.Play(m_nIndex > 1 ? "weizhi_up" : "weizhi_do"); GameMain.Destroy(obj, 5f); } else { tfmOtherCoin.GetComponentInChildren <Text>().text = m_nTotalCoin.ToString(); } ShowPlayerInfo(); }
public void LeaveSit() { if (m_nSrvSit >= CGame_Fishing.PlayerNum) { return; } OnLockFishLost(); LockUI.gameObject.SetActive(false); m_eLockState = LockFishState.LFS_None; Transform tfm = m_InfoUI.Find("Middle/Anime"); foreach (Transform child in tfm) { GameMain.Destroy(child.gameObject); } GameObject.Destroy(m_Cannon.gameObject); ShowPlayerInfo(false); m_nSrvSit = RoomInfo.NoSit; m_nTotalCoin = 0; }
public static bool Load(string filePath, bool loop = false) { // MyUtill.EvaluateRelativePath(Environment.CurrentDirectory, filePath); MyLog.Log("LoadAndPlayAudioClip", filePath); string extension = Path.GetExtension(filePath); if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath) || (extension != ".ogg" && extension != ".wav")) { if (!string.IsNullOrEmpty(filePath)) { Console.WriteLine(string.Format("{0}または{1}ファイルを指定してください。{2}", ".ogg", ".wav", filePath)); } return(false); } string s = Path.GetPathRoot(filePath); if (s.Equals('/') || s.Equals(string.Empty)) { filePath = Path.Combine(Environment.CurrentDirectory, filePath); } MyLog.Log("LoadAndPlayAudioClip", filePath); isLoaded = false; using (WWW www = new WWW("file:///" + filePath)) { MyLog.LogDebug("WWW", www.url); int num = 0; while (!www.isDone) { Thread.Sleep(100); num += 100; if (30000 < num) { Console.WriteLine("音声読込タイムアウトのため処理を中止します。"); return(false); } } AudioClip audioClip = www.GetAudioClip(); if (audioClip.loadState == AudioDataLoadState.Loaded) { if (audiosource != null) { GameMain.Destroy(audiosource); audiosource = null; } if (audiosource == null) { //AudioSourceMgr[] componentsInChildren = GameMain.Instance.MainCamera.gameObject.GetComponentsInChildren<AudioSourceMgr>(); //audioMgr = componentsInChildren.FirstOrDefault((AudioSourceMgr a) => a.SoundType == AudioSourceMgr.Type.Bgm); audiosource = GameMain.Instance.MainCamera.gameObject.AddComponent <AudioSource>(); //audiosource = audioMgr.audiosource; } if (audiosource != null) { audiosource.clip = audioClip; audiosource.loop = loop; isLoaded = true; } } } if (soundMgr == null) { soundMgr = GameMain.Instance.SoundMgr; } return(isLoaded); }