Beispiel #1
0
        private void Update()
        {
            int index = transform.GetSiblingIndex();

            if (Beatmap == null || !Beatmap.GetActive(5, index) || MusicPlaying)
            {
                gameObject.SetActive(false);
                return;
            }

            // Movement
            var(zoneMin, zoneMax, zoneSize, _) = ZoneMinMax;
            var trackData   = Beatmap.Tracks[index];
            var linkedStage = trackData.StageIndex >= 0 && trackData.StageIndex < Beatmap.Stages.Count ? Beatmap.Stages[trackData.StageIndex] : null;

            if (linkedStage == null || !linkedStage._Active)
            {
                gameObject.SetActive(false);
                return;
            }
            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 trackX      = Track.GetTrackX(trackData);
            float trackRotX   = Track.GetTrackAngle(trackData);
            var   pos         = Stage.LocalToZone(trackX, 0f, 0f, stagePos, stageWidth, stageHeight, stagePivotY, stageRotZ);

            LateScaleY         = Stage.GetStageHeight(linkedStage) * zoneSize;
            transform.position = Util.Vector3Lerp3(zoneMin, zoneMax, pos.x, pos.y);
            transform.rotation = Quaternion.Euler(0f, 0f, stageRotZ) * Quaternion.Euler(trackRotX, 0f, 0f);
            LateTime           = trackData.Time;
            LateDuration       = trackData.Duration;
        }
Beispiel #2
0
        private void Update()
        {
            int index = transform.GetSiblingIndex();

            if (Beatmap == null || !Beatmap.GetActive(4, index) || MusicPlaying)
            {
                gameObject.SetActive(false);
                return;
            }

            // Movement
            var(zoneMin, zoneMax, zoneSize, _) = ZoneMinMax;
            var stageData   = Beatmap.Stages[index];
            var stagePos    = Stage.GetStagePosition(stageData, index);
            var stageWidth  = Stage.GetStageWidth(stageData);
            var stageHeight = Stage.GetStageHeight(stageData);
            var stagePivotY = Stage.GetStagePivotY(stageData);
            var stageRotZ   = Stage.GetStageWorldRotationZ(stageData);
            var pos         = Stage.LocalToZone(0.5f, 0f, 0f, stagePos, stageWidth, stageHeight, stagePivotY, stageRotZ);

            LateScaleY         = stageHeight * zoneSize;
            transform.position = Util.Vector3Lerp3(zoneMin, zoneMax, pos.x, pos.y);
            transform.rotation = Quaternion.Euler(0f, 0f, stageRotZ);
            LateTime           = stageData.Time;
            LateDuration       = stageData.Duration;
        }
Beispiel #3
0
        private void Update_Gizmos(Beatmap.Stage linkedStage, Beatmap.Note noteData, int noteIndex)
        {
            bool active = !(noteData is null) && noteData._Active && MusicTime < noteData.Time + noteData.Duration;

            // Label
            if (Label != null)
            {
                if (ShowIndexLabel && !MusicPlaying && active)
                {
                    Label.gameObject.SetActive(true);
                    Label.Text = noteData.SoundFxIndex <= 0 ? noteIndex.ToString() : (noteIndex.ToString() + " fx");
                    Label.transform.localRotation = MainRenderer.transform.localRotation;
                }
                else
                {
                    Label.gameObject.SetActive(false);
                }
            }

            // Col
            TrySetColliderLayer(Duration <= FLOAT_GAP ? LayerID_Note : LayerID_Note_Hold);

            // ZLine
            bool zlineActive = ShowGrid && active && Abreast.value <0.5f && noteData.Z> 0.0005f;

            if (m_ZLineRenderer.gameObject.activeSelf != zlineActive)
            {
                m_ZLineRenderer.gameObject.SetActive(zlineActive);
            }
            // ZLine Color
            if (zlineActive)
            {
                m_ZLineRenderer.color = Color.Lerp(
                    m_ZLineRenderer.color,
                    Color.black * 0.2f,
                    UnityEngine.Time.deltaTime * 1.4f
                    );
            }
            else
            {
                if (m_ZLineRenderer.color != Color.clear)
                {
                    m_ZLineRenderer.color = Color.clear;
                }
            }
            // ZLine Scale
            if (zlineActive)
            {
                float zlineScaleY = GetNoteZ(noteData) * Stage.GetStageHeight(linkedStage) * ZoneMinMax.size;
                var   zScale      = m_ZLineRenderer.transform.localScale;
                if (Mathf.Abs(zScale.y - zlineScaleY) > 0.0001f)
                {
                    zScale.y = zlineScaleY;
                    m_ZLineRenderer.transform.localScale = zScale;
                }
                // ZLine Rot
                m_ZLineRenderer.transform.localRotation = MainRenderer.transform.localRotation * Quaternion.Euler(-90f, 0f, 0f);
            }
        }
Beispiel #4
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 #5
0
        protected Vector3?GetPosition(Beatmap map, int motionIndex, bool useRotation = true)
        {
            // Pos
            var(zoneMin, zoneMax, _, _) = GetZoneMinMax();
            int itemType   = MotionType >= 0 && MotionType <= 4 ? 0 : 1;
            int stageIndex = ItemIndex;
            var item       = map.GetItem(itemType, ItemIndex);

            if (item == null)
            {
                return(null);
            }
            if (itemType == 1)
            {
                stageIndex = (item as Beatmap.Track).StageIndex;
            }
            var stage = map.GetItem(0, stageIndex) as Beatmap.Stage;

            if (stage != null)
            {
                float musicTime = GetMusicTime();
                var   itemTime  = map.GetTime(itemType, ItemIndex);
                if (map.GetMotionTime(ItemIndex, MotionType, motionIndex, out float motionTime) && itemTime + motionTime + 0.001f > musicTime)
                {
                    float speedMuti = GetSpeedMuti();
                    float y01       = (itemTime + motionTime - musicTime) * speedMuti;
                    if (y01 >= 0f)
                    {
                        float stageRot = useRotation ? Stage.GetStageWorldRotationZ(stage) : 0f;
                        var   zonePos  = Stage.LocalToZone(
                            0.5f, y01, 0f,
                            Stage.GetStagePosition(stage, stageIndex),
                            Stage.GetStageWidth(stage),
                            Stage.GetStageHeight(stage),
                            Stage.GetStagePivotY(stage),
                            stageRot
                            );
                        return(Util.Vector3Lerp3(zoneMin, zoneMax, zonePos.x, zonePos.y, zonePos.z));
                    }
                }
            }
            return(null);
        }
Beispiel #6
0
        private void Update_Movement(Beatmap.Note noteData, bool tap, SkinType lumType)
        {
            // Life Time
            float noteEndTime = Time + noteData.Duration;

            MainRenderer.Duration       = Duration;
            MainRenderer.LifeTime       = MusicTime < noteEndTime ? MusicTime - noteData.Time : MusicTime - noteEndTime;
            MainRenderer.RendererEnable = true;

            // Get/Check Linked Track/Stage
            MainRenderer.RendererEnable = false;
            var linkedTrack = Beatmap.Tracks[noteData.TrackIndex];

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

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

            Time = noteData.Time;
            var   judgeLineSize = GetRectSize(SkinType.JudgeLine, 0);
            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 trackRotX     = Track.GetTrackAngle(linkedTrack);

            var(zoneMin, zoneMax, zoneSize, _) = ZoneMinMax;
            var pos = Track.LocalToZone(
                noteData.X, stageHeight > 0f ? judgeLineSize.y / 2f / stageHeight : 0f, Note.GetNoteZ(noteData),
                stagePos, stageWidth, stageHeight, stagePivotY, stageRotZ,
                trackX, trackWidth, trackRotX
                );
            var noteWorldPos = Util.Vector3Lerp3(zoneMin, zoneMax, pos.x, pos.y, pos.z);

            // Movement
            var   noteSize = GetRectSize(SkinType.Note, noteData.ItemType);
            var   lumSize = GetRectSize(lumType, 0, true, true);
            float scaleX, scaleY;

            if (lumSize.x < 0f)
            {
                // Scaled
                scaleX = (noteSize.x < 0f ? stageWidth * trackWidth * noteData.Width : noteSize.x) + LuminousAppend.x;
            }
            else
            {
                // Fixed
                scaleX = lumSize.x + LuminousAppend.x;
            }
            if (lumSize.y < 0f)
            {
                // Scaled
                scaleY = (tap ? LumHeight_Tap : LumHeight_Hold) + LuminousAppend.y;
            }
            else
            {
                // Fixed
                scaleY = lumSize.y + LuminousAppend.y;
            }

            transform.position = noteWorldPos;
            MainRenderer.transform.rotation   = Quaternion.Euler(0f, 0f, stageRotZ);
            MainRenderer.transform.localScale = new Vector3(
                zoneSize * scaleX,
                zoneSize * scaleY,
                1f
                );

            // Renderer
            MainRenderer.RendererEnable = true;
            MainRenderer.Loop           = lumType == SkinType.NoteLuminous ? 1 : 2;
            MainRenderer.Scale          = new Vector2(scaleX, scaleY);
            MainRenderer.SetSortingLayer(SortingLayerID_Lum, GetSortingOrder());
        }
Beispiel #7
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 #8
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()
                );
        }