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; }
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; }
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()); }
// Matrix public static Vector3 LocalToZone( float x01, float y01, float z01, Vector2 stagePos, float stageWidth, float stageHeight, float stagePivotY, float stageRotZ, float trackX, float trackWidth, float trackRotX ) { var sPos = Matrix4x4.TRS( new Vector3(trackX, 0f, 0f), Quaternion.Euler(trackRotX, 0f, 0f), new Vector3(trackWidth, 1f, 1f) ).MultiplyPoint(new Vector3(x01 - 0.5f, y01, -z01)); return(Stage.LocalToZone(sPos.x, sPos.y, sPos.z, stagePos, stageWidth, stageHeight, stagePivotY, stageRotZ)); }
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); }