private void UpdateArcCap()
        {
            int currentTiming = ArcGameplayManager.Instance.Timing;
            int duration      = arc.EndTiming - arc.Timing;
            int offset        = ArcAudioManager.Instance.AudioOffset;

            if (duration == 0)
            {
                EnableArcCap = false;
                return;
            }

            if (arc.Timing + offset < currentTiming && arc.EndTiming + offset >= currentTiming)
            {
                EnableArcCap         = true;
                ArcCapRenderer.color = new Color(1, 1, 1, arc.IsVoid ? 0.5f : 1f);
                ArcCap.localScale    = new Vector3(arc.IsVoid ? 0.21f : 0.35f, arc.IsVoid ? 0.21f : 0.35f);

                foreach (var s in segments)
                {
                    if (s.FromTiming + offset < currentTiming && s.ToTiming + offset >= currentTiming)
                    {
                        float t = (s.FromPos.z - arc.Position / 1000f) / (s.FromPos.z - s.ToPos.z);
                        ArcCap.position = new Vector3(s.FromPos.x + (s.ToPos.x - s.FromPos.x) * t,
                                                      s.FromPos.y + (s.ToPos.y - s.FromPos.y) * t);
                        if (!arc.IsVoid)
                        {
                            ArcArcManager.Instance.ArcJudgePos += ArcCap.position.x;
                        }
                        break;
                    }
                }
            }
            else if (arc.Timing + offset >= currentTiming && IsHead && !arc.IsVoid)
            {
                float p     = 1 - Mathf.Abs(arc.Position) / 100000;
                float scale = 0.35f + 0.5f * (1 - p);
                EnableArcCap         = true;
                ArcCapRenderer.color = new Color(1, 1, 1, p);
                ArcCap.localScale    = new Vector3(scale, scale);
                ArcCap.position      = new Vector3(ArcAlgorithm.ArcXToWorld(arc.XStart), ArcAlgorithm.ArcYToWorld(arc.YStart));
            }
            else
            {
                EnableArcCap = false;
            }
        }
예제 #2
0
        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 = (segSize == 0 ? 0 : duration / segSize) + 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)) / 1000f);
                segments[i].BuildSegment(start, end, arc.IsVoid ? OffsetVoid : OffsetNormal, arc.Timing + segSize * i, arc.Timing + segSize * (i + 1), startHeight, endHeight);
            }

            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) / 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));
        }
        public void BuildHead()
        {
            Vector3 pos    = new Vector3(ArcAlgorithm.ArcXToWorld(arc.XStart), ArcAlgorithm.ArcYToWorld(arc.YStart));
            float   offset = arc.IsVoid ? OffsetVoid : OffsetNormal;

            Vector3[] vertices  = new Vector3[4];
            Vector2[] uv        = new Vector2[4];
            Vector2[] uv2       = new Vector2[4];
            int[]     triangles = new int[] { 0, 2, 1, 0, 3, 2, 0, 1, 2, 0, 2, 3 };

            vertices[0] = pos + new Vector3(0, offset / 2, 0);
            uv[0]       = new Vector2(0, 0);
            uv2[0]      = new Vector2(arc.YStart, 0);
            vertices[1] = pos + new Vector3(offset, -offset / 2, 0);
            uv[1]       = new Vector2(1, 0);
            uv2[1]      = new Vector2(arc.YStart, 0);
            vertices[2] = pos + new Vector3(0, -offset / 2, offset / 2);
            uv[2]       = new Vector2(1, 1);
            uv2[2]      = new Vector2(arc.YStart, 0);
            vertices[3] = pos + new Vector3(-offset, -offset / 2, 0);
            uv[3]       = new Vector2(1, 1);
            uv2[3]      = new Vector2(arc.YStart, 0);

            Destroy(HeadFilter.sharedMesh);
            HeadFilter.sharedMesh = new Mesh()
            {
                vertices  = vertices,
                uv        = uv,
                uv2       = uv2,
                triangles = triangles.Take(6).ToArray()
            };

            Destroy(HeadCollider.sharedMesh);
            HeadCollider.sharedMesh = new Mesh()
            {
                vertices  = vertices,
                uv        = uv,
                triangles = triangles
            };

            HeadRenderer.sharedMaterial = arcMaterial;
        }
 public void BuildHeightIndicator()
 {
     if (arc.IsVoid)
     {
         EnableHeightIndicator = false;
         return;
     }
     HeightIndicatorRenderer.transform.localPosition = new Vector3(ArcAlgorithm.ArcXToWorld(arc.XStart), 0, 0);
     HeightIndicatorRenderer.transform.localScale    = new Vector3(2.34f, 100 * (ArcAlgorithm.ArcYToWorld(arc.YStart) - OffsetNormal / 2), 1);
     HeightIndicatorRenderer.color = Color.Lerp(arc.Color == 1 ? ArcRedLow : arc.Color == 0 ? ArcBlueLow : ArcGreenLow, arc.Color == 1 ? ArcRedHigh : arc.Color == 0 ? ArcBlueHigh : ArcGreenHigh, arc.YStart);
 }