public void SetSelectedInform(BMSLoader cBMSLoader) { SetSelectedInformText(cBMSLoader.m_cBMSInfo.sTitle, cBMSLoader.m_cBMSInfo.sArtist, cBMSLoader.m_cBMSInfo.sGenre, cBMSLoader.m_nKeyAmount.ToString() + "Key", cBMSLoader.m_cBMSInfo.sPlaylevel, cBMSLoader.m_nLength, cBMSLoader.m_fBPM, cBMSLoader.m_nTotalNote); }
IEnumerator Coroutine_LoadImage(BMSLoader cCurrentBMS) { // set stage file #if UNITY_ANDROID && !UNITY_EDITOR WWW www = new WWW("file://" + Application.dataPath + "/../" + media.m_sPath); #else WWW www = new WWW("file://" + Application.dataPath + "/../" + cCurrentBMS.m_sFolderPath + "/" + cCurrentBMS.m_cBMSInfo.sStagefile); #endif Texture2D texTmp = new Texture2D(4, 4, TextureFormat.DXT1, false); www.LoadImageIntoTexture(texTmp); Sprite sprite = Sprite.Create(texTmp, new Rect(0, 0, texTmp.width, texTmp.height), new Vector2(0.5f, 0.5f)); m_imgStagefile.sprite = sprite; yield return(null); }
public void UpdateInform() { if (m_nCurrentBMSIndex < 0 || m_nCurrentBMSIndex >= DataManager.Instance.m_dicBMS.Count) { return; } cCurrentBMS = DataManager.Instance.m_dicBMS.ElementAt(m_nCurrentBMSIndex).Value[m_nCurrentDifficultyIndex]; StopCoroutine(Coroutine_LoadImage(cCurrentBMS)); StartCoroutine(Coroutine_LoadImage(cCurrentBMS)); /* * // set stage file #if UNITY_ANDROID && !UNITY_EDITOR * WWW www = new WWW("file://" + Application.dataPath + "/../" + media.m_sPath); #else * WWW www = new WWW("file://" + Application.dataPath + "/../" + cCurrentBMS.m_sFolderPath + "/" + cCurrentBMS.m_cBMSInfo.sStagefile); #endif * Texture2D texTmp = new Texture2D(4, 4, TextureFormat.DXT1, false); * www.LoadImageIntoTexture(texTmp); * * Sprite sprite = Sprite.Create(texTmp, new Rect(0, 0, texTmp.width, texTmp.height), new Vector2(0.5f, 0.5f)); * m_imgStagefile.sprite = sprite;*/ // set title with out details char[] seps = new char[] { '[' }; string[] sTitleSplited = cCurrentBMS.m_cBMSInfo.sTitle.Split(seps, 2); m_txtTitle.text = sTitleSplited[0]; // set artist m_txtArtist.text = cCurrentBMS.m_cBMSInfo.sArtist; // set difficulty m_txtDifficulty.text = cCurrentBMS.m_cBMSInfo.sPlaylevel; }
IEnumerator Start() { bmsLoader = GameObject.Find("BMSLoader").GetComponent<BMSLoader>(); bmsLoader.loadBMS(); bms = bmsLoader.bms; yield return new WaitForSeconds(0.1f); Time.timeScale = 0.0f; //set camera variables worldScreenHeight = Camera.main.orthographicSize * 2; worldScreenWidth = worldScreenHeight / Screen.height * Screen.width; if(bms == null) { Debug.Log("Parsing Failed"); } currBpm = bms.info.init_bpm; //get components bgImage = bga.GetComponent<SpriteRenderer>(); layerImage = bgaLayer.GetComponent<SpriteRenderer>(); gstBga = bgaVideo.GetComponent<GstUnityBridgeTexture>(); gstLayer = bgaLayerVideo.GetComponent<GstUnityBridgeTexture>(); //set variables ulong maxSoundObjectId = 0; ulong maxBgaHeaderId = 0; foreach (BmsEvent be in bms.bmsEvents) { if (be.eventType == BMSParser.EventType.NoteEvent && ((NoteEvent)be).id > maxSoundObjectId) maxSoundObjectId = ((NoteEvent)be).id; } foreach (BGAHeader bh in bms.bga.bga_header) { if (bh.id > maxBgaHeaderId) { maxBgaHeaderId = bh.id; } } bgaSprites = new Sprite[maxBgaHeaderId+10]; layerSprites = new Sprite[maxBgaHeaderId+10]; eventLength = bms.bmsEvents.Count; pulseConstant = bms.info.init_bpm * bms.info.resolution / (60 * 4); lastPulse = bms.bmsEvents[bms.bmsEvents.Count - 1].y; resolution = bms.info.resolution; judge = GameObject.Find("Judge"); judgeImage = GameObject.Find("JudgeImage").GetComponent<UnityEngine.UI.Image>(); titleText = GameObject.Find("TitleText").GetComponent<Text>(); subtitleText = GameObject.Find("SubtitleText").GetComponent<Text>(); artistText = GameObject.Find("ArtistText").GetComponent<Text>(); bpmText = GameObject.Find("BpmText").GetComponent<Text>(); bgaText = GameObject.Find("BgaText").GetComponent<Text>(); layerText = GameObject.Find("LayerText").GetComponent<Text>(); pulseText = GameObject.Find("PulseText").GetComponent<Text>(); genreText = GameObject.Find("GenreText").GetComponent<Text>(); timeText = GameObject.Find("TimeText").GetComponent<Text>(); measureText = GameObject.Find("MeasureText").GetComponent<Text>(); totalText = GameObject.Find("TotalText").GetComponent<Text>(); resolutionText = GameObject.Find("ResolutionText").GetComponent<Text>(); soundText = GameObject.Find("SoundCountText").GetComponent<Text>(); comboText = GameObject.Find("ComboText").GetComponent<Text>(); loadingStatusText = GameObject.Find("LoadingStatusText").GetComponent<Text>(); soundObjects = new GameObject[1296]; //set Text titleText.text = "Title: " + bms.info.title; subtitleText.text = "Subtitle: " + bms.info.subtitle; artistText.text = "Artist: " + bms.info.artist; bpmText.text = "Bpm: " + bms.info.init_bpm; genreText.text = "Genre: " + bms.info.genre; totalText.text = "Total: " + bms.info.total; measureText.text = "Measure: 0/" + bms.info.maxMeasure; resolutionText.text = "Resolution: " + bms.info.resolution; loadingStatusText.text = "Loading BGA..."; yield return null; LoadBga(); loadingStatusText.text = "Loading Sound..."; yield return null; LoadSound(bms.info.soundHeaders); loadingStatusText.text = "Drawing Notes..."; yield return null; NotePlacement(); Component[] sources = FindObjectsOfType(typeof(AudioSource)) as Component[]; audioSources = new AudioSource[sources.Length]; sources.CopyTo(audioSources, 0); //Check how many sounds are playing.. InvokeRepeating("CurrentlyPlaying", 1f, 0.5f); DrawBMSGraph dbg = graphPanel.GetComponent<DrawBMSGraph>(); dbg.DrawGraph(bms.bmsEvents); loadingStatusText.text = "Done"; yield return null; loadingScreen.SetActive(false); isLoaded = true; timeOffset = Time.time; dbg.timeOffset = timeOffset; Time.timeScale = 1.0f; }
public void InsertBMS(byte[] hash, string path) { IDbCommand dbcmd = dbconn.CreateCommand(); dbcmd.CommandText = "SELECT * FROM bms WHERE filename='" + path + "'"; int count = Convert.ToInt32(dbcmd.ExecuteScalar()); dbcmd.Dispose(); dbcmd = null; if (count == 0) { // not exist //Debug.Log("not exist"); // load bms BMSLoader bms = new BMSLoader(); bms.Init(null, path); bms.LoadMetaData(); m_dicBMS[bms.m_sFolderPath].Add(bms); // insert db dbcmd = dbconn.CreateCommand(); string sqlQuery = "INSERT INTO bms (ID, PathID, hash, filename, stagefile, acp, title, artist, genre, bpm, player, style, rank, level, bga, difficulty, notes, length, key, foundtime, stamp)" + "VALUES (null,'0',@hash,'" + bms.m_sFilePath + "','" + bms.m_cBMSInfo.sStagefile + "','0',@title,@artist,@genre,'" + bms.m_cBMSInfo.sBpm + "','" + bms.m_cBMSInfo.sPlayer + "','" + "0" + "','" + bms.m_cBMSInfo.sRank + "','" + bms.m_cBMSInfo.sPlaylevel + "','" + "0" + "','" + bms.m_cBMSInfo.sDifficulty + "','" + bms.m_nTotalNote + "','" + bms.m_nLength + "','" + bms.m_nKeyAmount + "','" + "0" + "','" + "0" + "')"; dbcmd.CommandText = sqlQuery; BindByteArray(dbcmd, "@hash", hash); BindString(dbcmd, "@title", bms.m_cBMSInfo.sTitle); BindString(dbcmd, "@artist", bms.m_cBMSInfo.sArtist); BindString(dbcmd, "@genre", bms.m_cBMSInfo.sGenre); // execute query dbcmd.ExecuteNonQuery(); dbcmd.Dispose(); dbcmd = null; } else { // already exist //Debug.Log("already exist"); dbcmd = dbconn.CreateCommand(); dbcmd.CommandText = "SELECT hash FROM bms WHERE filename='" + path + "'"; // execute query IDataReader reader = dbcmd.ExecuteReader(); byte[] value = (byte[])reader[0]; reader.Close(); reader = null; if (value.SequenceEqual(hash) == false) { // file updated //Debug.Log("file updated"); BMSLoader bms = new BMSLoader(); bms.Init(null, path); bms.LoadMetaData(); m_dicBMS[bms.m_sFolderPath].Add(bms); // update db dbcmd = dbconn.CreateCommand(); string sqlQuery = "UPDATE bms SET hash=@hash," + "filename='" + bms.m_sFilePath + "' stagefile='" + bms.m_cBMSInfo.sStagefile + "', title=@title, artist=@artist," + "genre=@genre, bpm='" + bms.m_cBMSInfo.sBpm + "', player='" + bms.m_cBMSInfo.sPlayer + "'," + "style='0', rank='" + bms.m_cBMSInfo.sRank + "', level='" + bms.m_cBMSInfo.sPlaylevel + "', bga='0'," + "difficulty='" + bms.m_cBMSInfo.sDifficulty + "', notes='" + bms.m_nTotalNote + "', length='" + bms.m_nLength + "', key='" + bms.m_nKeyAmount + "'" + " WHERE filename='" + path + "'"; dbcmd.CommandText = sqlQuery; BindByteArray(dbcmd, "@hash", hash); BindString(dbcmd, "@title", bms.m_cBMSInfo.sTitle); BindString(dbcmd, "@artist", bms.m_cBMSInfo.sArtist); BindString(dbcmd, "@genre", bms.m_cBMSInfo.sGenre); // execute query dbcmd.ExecuteNonQuery(); dbcmd.Dispose(); dbcmd = null; } else { // same file dbcmd = dbconn.CreateCommand(); dbcmd.CommandText = "SELECT * FROM bms WHERE filename='" + path + "'"; // execute query reader = dbcmd.ExecuteReader(); while (reader.Read()) { int id = reader.GetInt32(0); int pathId = reader.GetInt32(1); byte[] hashval = (byte[])reader[2]; string filename = reader.GetString(3); string stagefile = reader.GetString(4); int acp = reader.GetInt32(5); string title = reader.GetString(6); string artist = reader.GetString(7); string genre = reader.GetString(8); float bpm = reader.GetFloat(9); string player = reader.GetString(10); string style = reader.GetString(11); string rank = reader.GetString(12); int level = reader.GetInt32(13); string bga = reader.GetString(14); string difficulty = reader.GetString(15); int notes = reader.GetInt32(16); int length = reader.GetInt32(17); int key = reader.GetInt32(18); int foundtime = reader.GetInt32(19); int stamp = reader.GetInt32(20); BMSLoader bms = new BMSLoader(); bms.Init(null, filename); bms.m_cBMSInfo.sStagefile = stagefile; bms.m_cBMSInfo.sTitle = title; bms.m_cBMSInfo.sArtist = artist; bms.m_cBMSInfo.sGenre = genre; bms.m_cBMSInfo.sBpm = bpm.ToString(); bms.m_cBMSInfo.sPlayer = player; bms.m_cBMSInfo.sRank = rank; bms.m_cBMSInfo.sPlaylevel = level.ToString(); bms.m_cBMSInfo.sDifficulty = difficulty; bms.m_nTotalNote = notes; bms.m_nLength = length; bms.m_nKeyAmount = key; bms.m_fBPM = bpm; m_dicBMS[bms.m_sFolderPath].Add(bms); } reader.Close(); reader = null; } dbcmd.Dispose(); dbcmd = null; } }