void Update() { signal = serialcontroller.ReadData(); //1か0の文字列 now += Time.deltaTime; //現在の時刻取得 GameObject.Find("Timer").GetComponent <Text>().text = now.ToString("F2"); //時刻ひょうじ //Debug.Log(now); //Debug.Log(_notesCount); if (now >= _start[_notesCount] && now <= _end[_notesCount]) { ScoreI(); } else { ScoreD(); } if (GameObject.Find("Comment").GetComponent <Text>().text == "Good") { float px = Random.Range(-6.0f, 6.0f); float py = Random.Range(-6.0f, 6.0f); azisai = Instantiate(flower, new Vector3(px, py, 0), Quaternion.identity) as GameObject;//Goodでゲームオブジェクトフェードイン } if (now > _end[_notesCount]) { _notesCount += 1; } }
void Update() { if (_isPlaying) { GameObject.Find("Timer").GetComponent <Text>().text = GetMusicTime().ToString("F2"); CheckNextNotes(); Debug.Log(serialcontroller.ReadData()); if (serialcontroller.ReadData() == "1") { //押し始め判定 { if (GetMusicTime() - _start[_begin] >= -0.4f && GetMusicTime() - _start[_begin] <= 0.4f) { score += 100f; GameObject.Find("Comment").GetComponent <Text>().text = "Great"; GameObject.Find("ScoreText").GetComponent <Text>().text = score.ToString("F0"); Instantiate(great, new Vector3(_posx1[_begin], _posy1[_begin], 0), Quaternion.identity); serialcontroller.Write("0"); Great++; _begin++; } else if (GetMusicTime() - _start[_begin] >= -0.3f && GetMusicTime() - _start[_begin] <= 0.3f) { score += 50f; GameObject.Find("Comment").GetComponent <Text>().text = "Good"; GameObject.Find("ScoreText").GetComponent <Text>().text = score.ToString("F0"); Instantiate(good, new Vector3(_posx1[_begin], _posy1[_begin], 0), Quaternion.identity); serialcontroller.Write("0"); Good++; _begin++; } else if (GetMusicTime() - _start[_begin] >= -0.9f && GetMusicTime() - _start[_begin] <= 0.9f) { score += 10; GameObject.Find("Comment").GetComponent <Text>().text = "Bad"; GameObject.Find("ScoreText").GetComponent <Text>().text = score.ToString("F0"); Instantiate(bad, new Vector3(_posx1[_begin], _posy1[_begin], 0), Quaternion.identity); serialcontroller.Write("1"); Bad++; _begin++; } else { } _isHold = true; } } if (serialcontroller.ReadData() == "1") { if (_isHold) { if (GetMusicTime() - _end[_release] >= -0.1f && GetMusicTime() - _end[_release] <= 0.1f) { score += 100f; GameObject.Find("Comment").GetComponent <Text>().text = "Great"; GameObject.Find("ScoreText").GetComponent <Text>().text = score.ToString("F0"); //パスの終わりにエフェクトを入れたい 保持リストを作っていないので別途読み込み serialcontroller.Write("0"); Great++; _release++; } else if (GetMusicTime() - _end[_release] >= -0.15f && GetMusicTime() - _end[_release] <= 0.15f) { score += 50f; GameObject.Find("Comment").GetComponent <Text>().text = "Good"; GameObject.Find("ScoreText").GetComponent <Text>().text = score.ToString("F0"); serialcontroller.Write("0"); Good++; _release++; } else if (GetMusicTime() - _end[_release] >= -0.6f && GetMusicTime() - _end[_release] <= 0.6f) { GameObject.Find("Comment").GetComponent <Text>().text = "Bad"; GameObject.Find("ScoreText").GetComponent <Text>().text = score.ToString("F0"); serialcontroller.Write("1"); Bad++; _release++; } else { } _isHold = false; } } } //scoreText.text = _score.ToString(); }