private TaikoNote Spawn() { if (this.waited.Count == 0) { ExpandPool(); } TaikoNote target = this.waited [0].GetComponent <TaikoNote>(); this.spawned.Add(target.gameObject); this.waited.RemoveAt(0); return(target); }
private void JudgeChannelRightClick() { if (this.onPlay == null) { return; } // use channels [1] TaikoNote target = GetNearestGlobal(); if (target == null || (target != null && target.IsJudged)) { return; } JudgeTouch(target, 1, true); @as.Play(); }
private void JudgeChannelLeftClick() { if (this.onPlay == null) { return; } // use channels [0] TaikoNote target = GetNearestGlobal(); if (target == null || (target != null && target.IsJudged)) { return; } JudgeTouch(target, 0); if (@as.isPlaying) { @as.Stop(); } }
private TaikoNote GetNearestGlobal() { TaikoNote n0 = channels[0].GetNearest(); TaikoNote n1 = channels[1].GetNearest(); if (n0 == null && n1 != null) { return(n1); } else if (n1 == null && n0 != null) { return(n0); } else if (n0 != null && n1 != null) { return((Vector3.Distance(n0.transform.position, JudgePoint.position) < Vector3.Distance(n1.transform.position, JudgePoint.position))? n0 : n1); } else { return(null); } }
public void OnUpdate(float velocity) { float current = SoundModule.Instance.BGM.time; for (int i = 0; i < data.Count; i++) { if (((float)data[0].timing / 1000.0f - SoundModule.Instance.GetTiming) * velocity >= 1) { break; } TaikoNote note = SpawnNote(); note.transform.SetParent(this.spawnPoint); note.Init(data[0], bar.rect.width, onMiss, () => { DespawnNote(note.gameObject); }, this.cid); data.RemoveAt(0); } foreach (Transform n in spawnPoint) { if (n.gameObject.activeSelf) { n.GetComponent <TaikoNote>().OnUpdate(velocity); } } }
private void JudgeTouch(TaikoNote target, int targetChannel, bool changeText = false) { float distance = Vector3.Distance(target.transform.position, JudgePoint.position); Debug.Log(distance); if (distance >= GameConstant.JUDGE_OFFSET_ENTRY) { // not reached judge entry return; } else if (distance >= GameConstant.JUDGE_OFFSET_NORMAL) { // miss target.SetJudged(); target.PlayMissTouchEffect(); this.Life = Mathf.Max(0.0f, this.life - GameConstant.JUDGE_MISS_LIFE_PENALTY); GameUI.Instance.UpdateJudgeText("Miss!"); return; } else { if (target.channel != targetChannel) { // miss target.SetJudged(); target.PlayMissTouchEffect(); this.Life = Mathf.Max(0.0f, this.life - GameConstant.JUDGE_MISS_LIFE_PENALTY); GameUI.Instance.UpdateJudgeText("Miss!"); return; } if (distance >= GameConstant.JUDGE_OFFSET_EXACT) { // normal touch target.SetJudged(); target.PlayNormalTouchEffect(); this.Score += GameConstant.JUDGE_SCORE_0; this.Life = Mathf.Min(1.0f, this.life + GameConstant.JUDGE_SUCCESS_LIFE_PRICE); GameUI.Instance.UpdateJudgeText("Good!"); if (changeText) { target.ChangeText(); } return; } else if (distance <= GameConstant.JUDGE_OFFSET_EXACT) { //exact touch target.SetJudged(); target.PlayExactTouchEffect(); this.Score += GameConstant.JUDGE_SCORE_1; this.Life = Mathf.Min(1.0f, this.life + GameConstant.JUDGE_SUCCESS_LIFE_PRICE); GameUI.Instance.UpdateJudgeText("Exact!"); if (changeText) { target.ChangeText(); } return; } } //Despawn (target.gameObject); }