public void Load() { TextAsset csvFile = Resources.Load("data") as TextAsset; StringReader reader = new StringReader(csvFile.text); mononokeStart.Clear(); mononokeEnd.Clear(); mononokeInfo.Clear(); while (reader.Peek() > -1) { string[] d = reader.ReadLine().Split(','); if (d.Length != 4) { continue; } MononokeInfo m = new MononokeInfo(); mononokeStart.Add(int.Parse(d[0])); mononokeEnd.Add(int.Parse(d[1])); m.level = int.Parse(d[2]); m.name = d[3]; m.tex = Resources.Load <Texture2D>(d[3]); mononokeInfo.Add(m); } }
private void mononokeOn() { MononokeInfo minfo = mononokeData.GetInfo(mononokeId); float aspect = (float)minfo.tex.width / minfo.tex.height; mononoke.GetComponent <Renderer>().material.mainTexture = minfo.tex; Vector3 scale = mononoke.transform.localScale; scale.x = scale.y * aspect; mononoke.transform.localScale = scale; level.value = minfo.level; mononoke.SetActive(true); vacuumSound.Play(); }
// Update is called once per frame void Update() { Control(); hitCount.Poll(); if (mononokeId < 0) //No valid mononoke in this time { int m = mononokeData.FindStart((int)video.frame); //Here is New Mononoke if (0 <= m) { mononokeId = m; //show mononoke In target indicator MononokeInfo minfo = mononokeData.GetInfo(mononokeId); float aspect = (float)minfo.tex.width / minfo.tex.height; target.GetComponent <UnityEngine.UI.Image>().material.mainTexture = minfo.tex; Vector3 scale = target.transform.localScale; scale.x = scale.y * aspect; target.transform.localScale = scale; target.SetActive(true); } } else { if (mononokeData.IsEnd(mononokeId, (int)video.frame)) //Now disappering { target.SetActive(false); level.value = 0; mononokeId = -1; } else // Mononoke in the House! { if (hitCount.IsDownEdge()) { Debug.Log("HIT!"); hitCount.hitId = mononokeId; mononokeOn(); } } } if (0 <= hitCount.hitId)//Mononoke is being capturerd (do Shake ) { mononokeShake(hitCount.time); if (hitCount.time > 3)//CAPTURED { Debug.Log("SUCESS TO GET"); ///TODO:caputure effect hitCount.hitId = -1; mononokeOff(); } if (hitCount.IsRiseEdge())//CANCEL { Debug.Log("CANCEL BY USER"); hitCount.hitId = -1; mononokeOff(); cancelSound.Play(); } } }
// Update is called once per frame void Update() { int scoreFrame = 2428; hitCount.Poll(); setBigScore(video.frame > scoreFrame); if (hitCount.InDown && video.frame < scoreFrame && hitCount.hitId == -1) { BigText.text = "\n\n\n\nかまえろ!"; } setScore(); //text.text = video.frame.ToString() + "/" + video.frameCount.ToString(); Control(); KickLed(); if (mononokeId < 0) //No valid mononoke in this time { int m = mononokeData.FindStart((int)video.frame); //Here is New Mononoke if (0 <= m) { mononokeId = m; //show mononoke In target indicator MononokeInfo minfo = mononokeData.GetInfo(mononokeId); if (minfo == null) { Debug.LogError("No Data at " + minfo.name); } float aspect = (float)minfo.tex.width / minfo.tex.height; target.GetComponent <UnityEngine.UI.Image>().material.mainTexture = minfo.tex; center.GetComponent <UnityEngine.UI.Image>().material.mainTexture = centerImg[minfo.level - 1]; Debug.Log("LEVEL======" + minfo.level); Vector3 scale = target.transform.localScale; scale.x = scale.y * aspect; target.transform.localScale = scale; target.SetActive(true); levelShow = true; } } else { if (mononokeData.IsEnd(mononokeId, (int)video.frame)) //Now disappering { target.SetActive(false); levelShow = false; level.value = 0; mononokeId = -1; } else // Mononoke in the House! { if (hitCount.IsDownEdge()) { Debug.Log("HIT!"); hitCount.hitId = mononokeId; mononokeOn(); } } } if (0 <= hitCount.hitId)//Mononoke is being capturerd (do Shake ) { mononokeShake(hitCount.time); if (hitCount.time > captureLen)//CAPTURED { Debug.Log("SUCESS TO GET"); int level = mononokeData.GetInfo(hitCount.hitId).level; scoreCount[level - 1]++; ///TODO:caputure effect hitCount.hitId = -1; air(); mononokeOff(); } if (hitCount.IsRiseEdge())//CANCEL { Debug.Log("CANCEL BY USER"); hitCount.hitId = -1; mononokeOff(); cancelSound.Play(); } } center.SetActive(levelShow && (!mononoke.active)); }