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_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());
        }
        private void Update()
        {
            var map         = GetBeatmap();
            int motionIndex = transform.GetSiblingIndex();
            var stage       = map != null?map.GetItem(0, ItemIndex) as Beatmap.Stage : null;

            bool active = false;

            if (stage != null)
            {
                float musicTime = GetMusicTime();
                var   itemTime  = map.GetTime(0, ItemIndex);
                var(hasA, hasB) = map.SearchMotionValueTween(ItemIndex, MotionType, musicTime - itemTime, out float valuA, out float valueB, out int tween, out int aimMotionIndex);
                if (hasA && hasB && aimMotionIndex >= 0)
                {
                    active = motionIndex >= aimMotionIndex && motionIndex <= aimMotionIndex + 1;
                }
                if (active && map.GetMotionTime(ItemIndex, MotionType, motionIndex, out float motionTime))
                {
                    // Pos
                    var(zoneMin, zoneMax, _, _) = GetZoneMinMax();
                    var zonePos  = Stage.GetStagePosition(stage, ItemIndex, itemTime + motionTime);
                    var worldPos = Util.Vector3Lerp3(zoneMin, zoneMax, zonePos.x, zonePos.y);
                    transform.position = worldPos;
                    // Line
                    if (motionIndex < aimMotionIndex + 1 && map.GetMotionTime(ItemIndex, MotionType, motionIndex + 1, out float nextMotionTime))
                    {
                        var nextPos      = Stage.GetStagePosition(stage, ItemIndex, itemTime + nextMotionTime);
                        var nextWorldPos = Util.Vector3Lerp3(zoneMin, zoneMax, nextPos.x, nextPos.y);
                        m_Line.transform.rotation = Quaternion.Euler(0f, 0f, Vector2.SignedAngle(Vector2.right, nextWorldPos - worldPos));
                        m_Line.size = new Vector2(Vector2.Distance(worldPos, nextWorldPos) / m_Line.transform.localScale.x, m_Line.size.y);
                        m_Line.gameObject.TrySetActive(true);
                    }
                    else
                    {
                        m_Line.gameObject.TrySetActive(false);
                    }
                }
            }
            // Index
            m_Index.RendererEnable = active;
            if (active)
            {
                m_Index.Text = motionIndex.ToString();
            }
            // Root
            Root.gameObject.TrySetActive(active);
            // Selection
            m_Selection.gameObject.TrySetActive(motionIndex == SelectingMotionIndex);
        }
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()
                );
        }