/// <summary> /// 会話 /// </summary> private IEnumerator ChangeMouthForm(MouthFormName _beforeFormName, MouthFormName _nextFormName) { float time = 0.0f; // 短音の場合に加速 float timeRate = (_nextFormName > MouthFormName.O) ? (2.0f) : (1.0f); Vector2 beforeForm = this.GetMouthForm(_beforeFormName); Vector2 nextForm = this.GetMouthForm(_nextFormName); while (time < this.speakInterval) { float r = time / this.speakInterval; float rate = 3 * r * r - 2 * r * r * r; this.settingValues_.form_ = (1.0f - rate) * beforeForm.x + rate * nextForm.x; this.settingValues_.openY_ = (1.0f - rate) * beforeForm.y + rate * nextForm.y; yield return(null); time += timeRate * Time.deltaTime; } // 最終形にする this.settingValues_.form_ = nextForm.x; this.settingValues_.openY_ = nextForm.y; }
// Update is called once per frame public void Update() { if (this.changeMouthForm_ != null) { // 口形変更中 if (!(this.changeMouthForm_.MoveNext())) { // 変更終了 this.currentMouthForm_ = this.nextMouthForm_; this.changeMouthForm_ = null; } } else if (this.speakingList_.Count > 0) { // 次の音があるとき this.nextMouthForm_ = this.speakingList_[0]; this.speakingList_.RemoveAt(0); this.changeMouthForm_ = ChangeMouthForm(this.currentMouthForm_, this.nextMouthForm_); } }
/// <summary> /// 口形情報の取得 /// </summary> /// <param name="_name">口形名</param> /// <returns>口形情報</returns> private Vector2 GetMouthForm(MouthFormName _name) { return(this.mouthFormList_[(int)_name]); }