public void selectMusic() { Collider2D col = Physics2D.OverlapPoint( new Vector2(selectObject.transform.localPosition.x * selectObject.transform.root.localScale.x, selectObject.transform.localPosition.y * selectObject.transform.root.localScale.y)); if (col != null) { Global.currentSelectMusic = Int32.Parse(col.name); if (Global.musicInfo.ContainsKey(Global.currentSelectMusic)) { Debug.Log(Global.musicInfo[Global.currentSelectMusic].titleName + " Selected."); // 미리듣기, 타이틀 파일 로드 RSC.LoadSprite(Global.songPath + "/" + Global.pngPath + "/" + Global.musicInfo[Global.currentSelectMusic].pngName); RSC.LoadAudio(Global.songPath + "/" + Global.prevPath + "/" + Global.musicInfo[Global.currentSelectMusic].prevName); // 배경 영상 정지 RSC.GetVideo(Global.modeVideoName[(int)Global.currentSelectMode]).GetComponent <MediaPlayerCtrl>().Stop(); SceneManager.LoadScene("Ready"); } } }
void loadMusicInfo() { string readingNode; string readingAttr; do { TextAsset txt = Resources.Load(Global.musicInfoPath) as TextAsset; XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(txt.text); readingNode = "MusicData"; XmlNodeList tmpNodeList = xmldoc.SelectNodes(readingNode); if (tmpNodeList == null || tmpNodeList.Count <= 0) { Debug.Log("Node not found : " + readingNode); break; } tmpNodeList = tmpNodeList[0].ChildNodes; Global.musicInfo = new Dictionary <int, MusicInfo>(); for (int i = 0; i < tmpNodeList.Count; ++i) { MusicInfo tmpMusicInfo = new MusicInfo(); readingAttr = "id"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.id = XmlConvert.ToInt32(tmpNodeList[i].Attributes[readingAttr].Value); readingAttr = "title"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.titleName = tmpNodeList[i].Attributes[readingAttr].Value; readingAttr = "maker"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.makerName = tmpNodeList[i].Attributes[readingAttr].Value; readingAttr = "bpm"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.bpm = XmlConvert.ToSingle(tmpNodeList[i].Attributes[readingAttr].Value); readingAttr = "ez"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.easyDiff = XmlConvert.ToInt32(tmpNodeList[i].Attributes[readingAttr].Value); readingAttr = "nm"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.normalDiff = XmlConvert.ToInt32(tmpNodeList[i].Attributes[readingAttr].Value); readingAttr = "hd"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.hardDiff = XmlConvert.ToInt32(tmpNodeList[i].Attributes[readingAttr].Value); readingAttr = "omp"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.ompName = tmpNodeList[i].Attributes[readingAttr].Value; readingAttr = "mp3"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.mp3Name = tmpNodeList[i].Attributes[readingAttr].Value; readingAttr = "png"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.pngName = tmpNodeList[i].Attributes[readingAttr].Value; readingAttr = "mpng"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.mpngName = tmpNodeList[i].Attributes[readingAttr].Value; readingAttr = "bga"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.bgaName = tmpNodeList[i].Attributes[readingAttr].Value + ".mp4"; readingAttr = "jam"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.jamName = tmpNodeList[i].Attributes[readingAttr].Value; readingAttr = "prev"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.prevName = tmpNodeList[i].Attributes[readingAttr].Value; readingAttr = "sort"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.sort = XmlConvert.ToInt32(tmpNodeList[i].Attributes[readingAttr].Value); readingAttr = "pay"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.pay = (PaymentType)XmlConvert.ToInt32(tmpNodeList[i].Attributes[readingAttr].Value); readingAttr = "cost"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.cost = XmlConvert.ToInt32(tmpNodeList[i].Attributes[readingAttr].Value); readingAttr = "lock"; if (tmpNodeList[i].Attributes[readingAttr] == null) { Debug.Log("Attribute not found : " + readingAttr); break; } tmpMusicInfo.isLocked = XmlConvert.ToInt32(tmpNodeList[i].Attributes[readingAttr].Value); Global.musicInfo[tmpMusicInfo.id] = tmpMusicInfo; } readingNode = null; } while (false); if (readingNode != null) { Debug.Log("Failed to reading XML Node : " + readingNode); return; } // 썸네일, 타이틀 로드 List <MusicInfo> tmpMusicInfoList = Global.musicInfo.Values.ToList(); for (int i = 0; i < tmpMusicInfoList.Count; ++i) { RSC.LoadSprite(Global.songPath + "/" + Global.mpngPath + "/" + tmpMusicInfoList[i].mpngName); RSC.LoadSprite(Global.songPath + "/" + Global.pngPath + "/" + tmpMusicInfoList[i].pngName); } }