Beispiel #1
0
        private void Update_Movement(Beatmap.Stage linkedStage, Beatmap.Track trackData)
        {
            var(zoneMin, zoneMax, zoneSize, _) = ZoneMinMax;
            float trackWidth  = GetTrackWidth(trackData);
            float stageWidth  = Stage.GetStageWidth(linkedStage);
            float stageHeight = Stage.GetStageHeight(linkedStage);
            float stagePivotY = Stage.GetStagePivotY(linkedStage);
            float stageRotZ   = Stage.GetStageWorldRotationZ(linkedStage);
            var   stagePos    = Stage.GetStagePosition(linkedStage, trackData.StageIndex);
            float rotX        = GetTrackAngle(trackData);
            float trackX      = GetTrackX(trackData);
            var   pos         = Stage.LocalToZone(trackX, 0f, 0f, stagePos, stageWidth, stageHeight, stagePivotY, stageRotZ);

            // Movement
            transform.position      = Util.Vector3Lerp3(zoneMin, zoneMax, pos.x, pos.y);
            transform.localRotation = Quaternion.Euler(0f, 0f, stageRotZ) * Quaternion.Euler(rotX, 0, 0);
            ColSize = MainRenderer.transform.localScale = m_TrackTintRenderer.transform.localScale = new Vector3(
                zoneSize * trackWidth * stageWidth,
                zoneSize * stageHeight,
                1f
                );

            // Tray
            if (trackData.HasTray)
            {
                var traySize      = GetRectSize(SkinType.Tray, trackData.ItemType, false, false);
                var judgeLineSize = GetRectSize(SkinType.JudgeLine, trackData.ItemType);
                var trayPos       = LocalToZone(
                    TrayX, judgeLineSize.y / 2f / stageHeight, 0f,
                    stagePos, stageWidth, stageHeight, stagePivotY, stageRotZ,
                    trackX, trackWidth, rotX
                    );
                m_TrayRenderer.transform.position   = Util.Vector3Lerp3(zoneMin, zoneMax, trayPos.x, trayPos.y);
                m_TrayRenderer.transform.localScale = new Vector3(traySize.x, traySize.y, 1f);
                m_TrayRenderer.Scale = traySize;
            }

            // Renderer
            MainRenderer.RendererEnable        = true;
            m_TrackTintRenderer.RendererEnable = true;
            m_TrackTintRenderer.ItemType       = trackData.ItemType;
            MainRenderer.ItemType         = trackData.ItemType;
            m_TrayRenderer.RendererEnable = trackData.HasTray;
            m_TrayRenderer.ItemType       = trackData.ItemType;
            MainRenderer.Duration         = m_TrayRenderer.Duration = m_TrackTintRenderer.Duration = Duration;
            MainRenderer.Scale            = m_TrackTintRenderer.Scale = new Vector2(stageWidth * trackWidth, stageHeight);
            m_TrackTintRenderer.Tint      = trackData.c_Tint = GetTrackColor(trackData);
            MainRenderer.Alpha            = m_TrayRenderer.Alpha = Stage.GetStageAlpha(linkedStage) * GetTrackAlpha(trackData);
            m_TrackTintRenderer.Alpha    *= MainRenderer.Alpha;
            MainRenderer.SetSortingLayer(SortingLayerID_Track, GetSortingOrder());
            m_TrackTintRenderer.SetSortingLayer(SortingLayerID_TrackTint, GetSortingOrder());
            m_TrayRenderer.SetSortingLayer(SortingLayerID_Tray, 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()
                );
        }