Beispiel #1
0
        private void LateUpdate_Movement_Linked(Beatmap.Note noteData, Beatmap.Note linkedNote, Vector3 noteWorldPos, Quaternion noteRot, float alpha)
        {
            // Get Basic Linked Data
            if (linkedNote == null || noteData.Time + noteData.Duration > linkedNote.Time)
            {
                return;
            }
            var linkedTrack = Beatmap.Tracks[linkedNote.TrackIndex];

            if (linkedTrack == null || !linkedTrack._Active)
            {
                return;
            }
            var linkedStage = Beatmap.Stages[linkedTrack.StageIndex];

            if (linkedStage == null || !linkedStage._Active)
            {
                return;
            }

            // Get Linked Stage Data
            Vector2 linkedStagePos    = Stage.GetStagePosition(linkedStage, linkedTrack.StageIndex);
            float   linkedStageWidth  = Stage.GetStageWidth(linkedStage);
            float   linkedStageHeight = Stage.GetStageHeight(linkedStage);
            float   linkedStagePivotY = Stage.GetStagePivotY(linkedStage);
            float   linkedStageRotZ   = Stage.GetStageWorldRotationZ(linkedStage);
            float   linkedTrackAngle  = Track.GetTrackAngle(linkedTrack);

            // Movement
            var(zoneMin, zoneMax, zoneSize, _) = ZoneMinMax;
            float gameOffset    = GetGameDropOffset(noteData.TimingID, noteData._SpeedMuti);
            float linkedNoteY01 = linkedNote._NoteDropStart - gameOffset;

            linkedNoteY01 += GetMinHeight(SkinType.Note, noteData.ItemType);
            var linkedZonePos = Track.LocalToZone(
                linkedNote.X,
                linkedNoteY01,
                GetNoteZ(linkedNote),
                linkedStagePos,
                linkedStageWidth,
                linkedStageHeight,
                linkedStagePivotY,
                linkedStageRotZ,
                Track.GetTrackX(linkedTrack),
                Track.GetTrackWidth(linkedTrack),
                linkedTrackAngle
                );

            // Linked Note World Pos
            var linkedNoteWorldPos = Util.Vector3Lerp3(zoneMin, zoneMax, linkedZonePos.x, linkedZonePos.y, linkedZonePos.z);

            // Sub Pole World Pos
            float noteEndTime = noteData.Time + noteData.Duration;
            var   subWorldPos = m_PoleRenderer.transform.position = Mathf.Abs(linkedNote.Time - noteEndTime) > 0.00001f ? Util.Remap(
                noteEndTime,
                linkedNote.Time,
                noteWorldPos + noteRot * new Vector3(
                    0f,
                    zoneSize * (MusicTime < noteData.Time ?
                                noteData._NoteDropEnd - noteData._NoteDropStart :
                                noteData._NoteDropEnd - gameOffset
                                ) * linkedStageHeight
                    ),
                linkedNoteWorldPos,
                MusicTime
                ) : noteWorldPos;

            // Get Scale Y from World Distance
            float scaleY = Vector3.Distance(subWorldPos, linkedNoteWorldPos);

            // Reduce Scale Y when Linked Note Not Appear Yet
            if (MusicTime < linkedNote._AppearTime)
            {
                float offset = linkedNoteY01 - noteData._NoteDropEnd + gameOffset;
                scaleY = offset == 0f ? 0f : scaleY - scaleY * (linkedNoteY01 - 1f) / offset;
            }

            // Final
            var poleSize = GetRectSize(SkinType.Pole, noteData.ItemType, false, false);

            m_PoleRenderer.ItemType           = noteData.ItemType;
            m_PoleRenderer.transform.rotation = linkedNoteWorldPos != subWorldPos?Quaternion.LookRotation(
                linkedNoteWorldPos - subWorldPos, -MainRenderer.transform.forward
                ) * Quaternion.Euler(90f, 0f, 0f) : Quaternion.identity;

            m_PoleRenderer.transform.localScale = new Vector3(zoneSize * poleSize.x, scaleY, 1f);
            m_PoleRenderer.RendererEnable       = true;
            m_PoleRenderer.Duration             = Duration;
            m_PoleRenderer.Pivot = new Vector3(0.5f, 0f);
            m_PoleRenderer.Scale = new Vector2(poleSize.x, scaleY / zoneSize);
            m_PoleRenderer.Tint  = MusicTime > Time + Duration ? HighlightTints[(int)SkinType.Pole] : WHITE_32;
            m_PoleRenderer.Alpha = alpha * Mathf.Clamp01((linkedNote._NoteDropStart - gameOffset) * 16f);
            m_PoleRenderer.SetSortingLayer(
                FrontPole ? SortingLayerID_Pole_Front : SortingLayerID_Pole_Back,
                GetSortingOrder()
                );
        }
Beispiel #2
0
        private void Update_Movement(Beatmap.Stage linkedStage, Beatmap.Track linkedTrack, Beatmap.Note noteData, Beatmap.Note linkedNote)
        {
            var   stagePos    = Stage.GetStagePosition(linkedStage, linkedTrack.StageIndex);
            float stageWidth  = Stage.GetStageWidth(linkedStage);
            float stagePivotY = Stage.GetStagePivotY(linkedStage);
            float stageHeight = Stage.GetStageHeight(linkedStage);
            float stageRotZ   = Stage.GetStageWorldRotationZ(linkedStage);
            float trackX      = Track.GetTrackX(linkedTrack);
            float trackWidth  = Track.GetTrackWidth(linkedTrack);
            float trackAngle  = Track.GetTrackAngle(linkedTrack);
            float gameOffset  = GetGameDropOffset(noteData.TimingID, noteData._SpeedMuti);
            float noteY01     = MusicTime < Time ? (noteData._NoteDropStart - gameOffset) : 0f;
            float noteSizeY   = noteData._NoteDropEnd - gameOffset - noteY01;

            var(zoneMin, zoneMax, zoneSize, _) = ZoneMinMax;
            bool  isLink      = linkedNote != null;
            bool  activeSelf  = GetNoteActive(noteData, null, noteData._AppearTime);
            float alpha       = Stage.GetStageAlpha(linkedStage) * Track.GetTrackAlpha(linkedTrack) * Mathf.Clamp01(16f - noteY01 * 16f);
            bool  highlighing = MusicTime > Time && MusicTime < Time + Duration;
            float noteZ       = GetNoteZ(noteData);
            var   tint        = highlighing ? HighlightTints[(int)SkinType.Note] : WHITE_32;

            if (TintNote)
            {
                tint *= linkedTrack.c_Tint;
            }

            // Movement
            var noteZonePos = Track.LocalToZone(
                noteData.X, noteY01, noteZ,
                stagePos, stageWidth, stageHeight, stagePivotY, stageRotZ,
                trackX, trackWidth, trackAngle
                );
            var noteRot      = Quaternion.Euler(0f, 0f, stageRotZ) * Quaternion.Euler(trackAngle, 0f, 0f);
            var noteWorldPos = Util.Vector3Lerp3(zoneMin, zoneMax, noteZonePos.x, noteZonePos.y, noteZonePos.z);

            // Size
            var     noteSize          = GetRectSize(SkinType.Note, noteData.ItemType);
            float   minHeight         = GetMinHeight(SkinType.Note, noteData.ItemType);
            float   noteScaleX        = noteSize.x < 0f ? stageWidth * trackWidth * noteData.Width : noteSize.x;
            float   noteScaleY_scaler = Mathf.Max(noteSizeY * stageHeight, minHeight);
            float   noteScaleY        = Mathf.Max(noteSizeY * stageHeight + minHeight, 0f);
            Vector3 zoneNoteScale     = new Vector3(
                zoneSize * noteScaleX,
                zoneSize * noteScaleY,
                1f
                );
            Vector3 zoneNoteScale_scaler = new Vector3(
                zoneSize * noteScaleX,
                zoneSize * noteScaleY_scaler,
                1f
                );

            // Transform
            transform.position  = Late_NoteWorldPos = noteWorldPos;
            ColRot              = MainRenderer.transform.rotation = noteRot;
            ColSize             = MainRenderer.transform.localScale = zoneNoteScale;
            m_Scaler.localScale = zoneNoteScale_scaler;
            m_Scaler.rotation   = noteRot;

            // Renderer
            MainRenderer.RendererEnable = !isLink || activeSelf;
            MainRenderer.ItemType       = noteData.ItemType;
            MainRenderer.Tint           = tint;
            MainRenderer.Alpha          = alpha;
            MainRenderer.Duration       = Duration;
            MainRenderer.Scale          = new Vector2(noteScaleX, noteScaleY);
            MainRenderer.SetSortingLayer(
                Duration <= FLOAT_GAP ? SortingLayerID_Note : SortingLayerID_Note_Hold,
                GetSortingOrder()
                );
        }