private void RenderTapNotes() { ArcTimingManager timing = ArcTimingManager.Instance; int offset = ArcAudioManager.Instance.AudioOffset; foreach (var t in Taps) { if (!timing.ShouldTryRender(t.Timing + offset) || t.Judged) { t.Enable = false; continue; } t.Position = timing.CalculatePositionByTiming(t.Timing + offset); if (t.Position > 100000 || t.Position < -10000) { t.Enable = false; continue; } t.Enable = true; float pos = t.Position / 1000f; t.transform.localPosition = new Vector3(Lanes[t.Track - 1], pos, 0); if (ArcCameraManager.Instance.EditorCamera) { t.transform.localScale = new Vector3(1.53f, 2, 1); } else { t.transform.localScale = new Vector3(1.53f, 2f + 5.1f * pos / 100f, 1); } t.Alpha = pos < 90 ? 1 : (100 - pos) / 10f; } }
private void RenderArcTaps(ArcArc arc) { int timing = ArcGameplayManager.Instance.Timing; ArcTimingManager timingManager = ArcTimingManager.Instance; int offset = ArcAudioManager.Instance.AudioOffset; foreach (ArcArcTap t in arc.ArcTaps) { if (!timingManager.ShouldTryRender(t.Timing + offset, t.TimingGroup) || t.Judged || t.GroupHide()) { t.Enable = false; continue; } float pos = timingManager.CalculatePositionByTiming(t.Timing + offset, t.TimingGroup) / 1000f; if (pos > -100 && pos <= 90) { t.Alpha = 1; t.Enable = true; } else if (pos > 90 && pos <= 100) { t.Enable = true; t.Alpha = (100 - pos) / 10f; } else { t.Enable = false; } } }
private void JudgeTapNotes() { ArcTimingManager timing = ArcTimingManager.Instance; int offset = ArcAudioManager.Instance.AudioOffset; int currentTiming = ArcGameplayManager.Instance.Timing; foreach (var t in Taps) { if (t.Judged) { continue; } if (currentTiming > t.Timing + offset && currentTiming <= t.Timing + offset + 150) { t.Judged = true; if (ArcGameplayManager.Instance.IsPlaying) { ArcEffectManager.Instance.PlayTapNoteEffectAt(new Vector2(Lanes[t.Track - 1], 0)); } } else if (currentTiming > t.Timing + offset + 150) { t.Judged = true; } } }
public void BuildSegments() { if (arc == null) { return; } ArcTimingManager timingManager = ArcTimingManager.Instance; int offset = ArcAudioManager.Instance.AudioOffset; int duration = arc.EndTiming - arc.Timing; int v1 = duration < 1000 ? 14 : 7; float v2 = 1f / (v1 * duration / 1000f); int segSize = (int)(duration * v2); segmentCount = 0; if (segSize != 0) { segmentCount = duration / segSize + (duration % segSize == 0 ? 0 : 1); } if (segmentCount == 0 && (arc.XStart != arc.XEnd || arc.YStart != arc.YEnd)) { segmentCount = 1; } InstantiateSegment(segmentCount); float startHeight = 0; float endHeight = arc.YStart; Vector3 start = new Vector3(); Vector3 end = new Vector3(ArcAlgorithm.ArcXToWorld(arc.XStart), ArcAlgorithm.ArcYToWorld(arc.YStart)); for (int i = 0; i < segmentCount - 1; ++i) { startHeight = endHeight; start = end; endHeight = ArcAlgorithm.Y(arc.YStart, arc.YEnd, (i + 1f) * segSize / duration, arc.LineType); end = new Vector3(ArcAlgorithm.ArcXToWorld(ArcAlgorithm.X(arc.XStart, arc.XEnd, (i + 1f) * segSize / duration, arc.LineType)), ArcAlgorithm.ArcYToWorld(ArcAlgorithm.Y(arc.YStart, arc.YEnd, (i + 1f) * segSize / duration, arc.LineType)), -timingManager.CalculatePositionByTimingAndStart(arc.Timing + offset, arc.Timing + offset + segSize * (i + 1), arc.TimingGroup) / 1000f); segments[i].BuildSegment(start, end, arc.IsVoid ? OffsetVoid : OffsetNormal, arc.Timing + segSize * i, arc.Timing + segSize * (i + 1), startHeight, endHeight); } if (segmentCount > 0) { startHeight = endHeight; start = end; endHeight = arc.YEnd; end = new Vector3(ArcAlgorithm.ArcXToWorld(arc.XEnd), ArcAlgorithm.ArcYToWorld(arc.YEnd), -timingManager.CalculatePositionByTimingAndStart(arc.Timing + offset, arc.EndTiming + offset, arc.TimingGroup) / 1000f); segments[segmentCount - 1].BuildSegment(start, end, arc.IsVoid ? OffsetVoid : OffsetNormal, arc.Timing + segSize * (segmentCount - 1), arc.EndTiming, startHeight, endHeight); } HighColor = (arc.IsVoid ? ArcVoid : (arc.Color == 0 ? ArcBlueHigh : arc.Color == 1 ? ArcRedHigh : ArcGreenHigh)); LowColor = (arc.IsVoid ? ArcVoid : (arc.Color == 0 ? ArcBlueLow : arc.Color == 1 ? ArcRedLow : ArcGreenLow)); }
private void RenderHoldNotes() { ArcTimingManager timing = ArcTimingManager.Instance; int offset = ArcAudioManager.Instance.AudioOffset; foreach (var t in Holds) { int duration = t.EndTiming - t.Timing; if (!timing.ShouldTryRender(t.Timing + offset, duration + 120) || t.Judged) { t.Enable = false; continue; } t.Position = timing.CalculatePositionByTiming(t.Timing + offset); float endPosition = timing.CalculatePositionByTiming(t.EndTiming + offset); if (t.Position > 100000 || endPosition < -10000) { t.Enable = false; continue; } t.Enable = true; float pos = t.Position / 1000f; float length = (endPosition - t.Position) / 1000f; t.transform.localPosition = new Vector3(Lanes[t.Track - 1], pos, 0); t.transform.localScale = new Vector3(1.53f, length / 3.79f, 1); t.boxCollider.center = new Vector3(0, t.boxCollider.size.y / 2); float alpha = 1; if (t.Judging) { t.From = Mathf.Clamp((-pos / length), 0, 1); t.FlashCount = (t.FlashCount + 1) % 4; if (t.FlashCount == 0) { alpha = 0.85f; } t.Highlight = true; } else { t.From = 0; alpha = pos < 0 ? 0.5f : 1; t.Highlight = false; } t.Alpha = alpha * 0.8627451f; t.To = Mathf.Clamp((100 - pos) / length, 0, 1); } }
private void JudgeHoldNotes() { ArcTimingManager timing = ArcTimingManager.Instance; int offset = ArcAudioManager.Instance.AudioOffset; int currentTiming = ArcGameplayManager.Instance.Timing; ArcEffectManager.Instance.ResetHoldNoteEffect(); foreach (var t in Holds) { if (t.NoInput()) { continue; } if (t.Judged) { continue; } if (currentTiming >= t.Timing + offset && currentTiming <= t.EndTiming + offset) { t.Judging = true; if (!t.AudioPlayed) { if (ArcGameplayManager.Instance.IsPlaying && t.ShouldPlayAudio) { ArcEffectManager.Instance.PlayTapSound(); } t.AudioPlayed = true; } ArcEffectManager.Instance.SetHoldNoteEffect(t.Track, true); } else if (currentTiming > t.EndTiming + offset) { t.Judging = false; t.Judged = true; t.AudioPlayed = true; } else { t.ShouldPlayAudio = true; } } }
private void UpdateSegments() { int currentTiming = ArcGameplayManager.Instance.Timing; ArcTimingManager timingManager = ArcTimingManager.Instance; int offset = ArcAudioManager.Instance.AudioOffset; float z = arc.transform.localPosition.z; foreach (ArcArcSegmentComponent s in segments) { if (s.ToTiming + offset < currentTiming) { if (arc.Judging || arc.IsVoid) { s.Enable = false; continue; } else { s.Enable = true; continue; } } if (s.FromTiming + offset < currentTiming && s.ToTiming + offset >= currentTiming) { s.Enable = true; s.CurrentArcMaterial = null; s.CurrentShadowMaterial = null; s.Alpha = currentHighColor.a; if (arc.Judging || arc.IsVoid) { s.From = (z + s.FromPos.z) / (-s.ToPos.z + s.FromPos.z); } else { s.From = 0; } continue; } float pos = -(z + s.FromPos.z); float endPos = -(z + s.ToPos.z); if (pos > 90 && pos < 100) { s.Enable = true; s.CurrentArcMaterial = null; s.CurrentShadowMaterial = null; s.Alpha = currentHighColor.a * (100 - pos) / 10f; s.From = 0; } else if (Mathf.Min(pos, endPos) > 100 || Mathf.Max(pos, endPos) < -100) { s.Enable = false; } else { s.Enable = true; s.Alpha = currentHighColor.a; s.From = 0; s.CurrentArcMaterial = arcMaterial; s.CurrentShadowMaterial = shadowMaterial; } } }
public void CalculateArcRelationship() { ArcTimingManager timing = ArcTimingManager.Instance; foreach (ArcArc arc in Arcs) { arc.ArcGroup = null; arc.RenderHead = true; } foreach (ArcArc a in Arcs) { foreach (ArcArc b in Arcs) { if (a == b) { continue; } if (Mathf.Abs(a.XEnd - b.XStart) < 0.1f && Mathf.Abs(a.EndTiming - b.Timing) <= 9 && a.YEnd == b.YStart) { if (a.Color == b.Color && a.IsVoid == b.IsVoid) { if (b.ArcGroup != null) { a.ArcGroup = b.ArcGroup; } else if (a.ArcGroup != null && b.ArcGroup == null) { b.ArcGroup = a.ArcGroup; } else if (a.ArcGroup == null && b.ArcGroup == null) { a.ArcGroup = b.ArcGroup = new List <ArcArc>(); } } if (a.IsVoid == b.IsVoid) { b.RenderHead = false; } } } } foreach (ArcArc arc in Arcs) { if (arc.ArcGroup == null) { arc.ArcGroup = new List <ArcArc> { arc }; } else { if (!arc.ArcGroup.Contains(arc)) { arc.ArcGroup.Add(arc); } } arc.ArcGroup.Sort((ArcArc a, ArcArc b) => a.Timing.CompareTo(b.Timing)); } foreach (ArcArc arc in Arcs) { arc.CalculateJudgeTimings(); } }
private void RenderArcs() { ArcTimingManager timingManager = ArcTimingManager.Instance; int currentTiming = ArcGameplayManager.Instance.Timing; int offset = ArcAudioManager.Instance.AudioOffset; foreach (var t in Arcs) { RenderArcTaps(t); int duration = t.EndTiming - t.Timing; if (!timingManager.ShouldTryRender(t.Timing + offset, t.TimingGroup, duration) || t.Judged || t.GroupHide()) { t.Enable = false; continue; } t.Position = timingManager.CalculatePositionByTiming(t.Timing + offset, t.TimingGroup); t.EndPosition = timingManager.CalculatePositionByTiming(t.EndTiming + offset, t.TimingGroup); if (Mathf.Min(t.Position, t.EndPosition) > 100000 || Mathf.Max(t.Position, t.EndPosition) < -100000) { t.Enable = false; continue; } t.Enable = true; t.transform.localPosition = new Vector3(0, 0, -t.Position / 1000f); if (!t.IsVoid) { t.arcRenderer.EnableEffect = currentTiming > t.Timing + offset && currentTiming <= t.EndTiming + offset && !t.IsVoid && t.Judging; foreach (var a in t.ArcGroup) { if (!a.Flag) { a.Flag = true; float alpha = 1; if (a.Judging) { a.FlashCount = (a.FlashCount + 1) % 5; if (a.FlashCount == 0) { alpha = 0.85f; } a.arcRenderer.Highlight = true; } else { alpha = 0.65f; a.arcRenderer.Highlight = false; } alpha *= 0.8823592f; a.arcRenderer.Alpha = alpha; } } } else { t.arcRenderer.EnableEffect = false; t.arcRenderer.Highlight = false; t.arcRenderer.Alpha = 0.318627f; } t.arcRenderer.UpdateArc(); } foreach (var t in Arcs) { t.Flag = false; } }
private void Awake() { Instance = this; }
private void RenderHoldNotes() { ArcTimingManager timing = ArcTimingManager.Instance; int offset = ArcAudioManager.Instance.AudioOffset; foreach (var t in Holds) { int duration = t.EndTiming - t.Timing; if (!timing.ShouldTryRender(t.Timing + offset, t.TimingGroup, duration) || t.Judged || t.GroupHide()) { t.Enable = false; continue; } t.Position = timing.CalculatePositionByTiming(t.Timing + offset, t.TimingGroup); float endPosition = timing.CalculatePositionByTiming(t.EndTiming + offset, t.TimingGroup); t.Enable = true; if (t.Judging) { t.Position = 0; } if (endPosition < t.Position) { var p = t.Position; t.Position = endPosition; endPosition = p; } if (t.Position > 100000 || endPosition < -100000) { t.Enable = false; continue; } if (endPosition > 100000) { endPosition = 100000; } if (t.Position < -100000) { t.Position = -100000; } float pos = t.Position / 1000f; float length = (endPosition - t.Position) / 1000f; t.transform.localPosition = new Vector3(Lanes[t.Track - 1], pos, 0); t.transform.localScale = new Vector3(1.53f, length / 3.79f, 1); t.boxCollider.center = new Vector3(0, t.boxCollider.size.y / 2); float alpha = 1; if (t.Judging) { t.FlashCount = (t.FlashCount + 1) % 4; if (t.FlashCount == 0) { alpha = 0.85f; } t.Highlight = true; } else { alpha = t.Timing + offset < ArcGameplayManager.Instance.Timing ? 0.5f : 1; t.Highlight = false; } t.Alpha = alpha * 0.8627451f; } }