From c4fa3cfe3f35cd69352ad06a9261f557a8f7653e Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Sat, 18 Oct 2025 10:44:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Wpf_AiSportsMicrospace/Common/SportOperate.cs | 2 +- .../MyUserControl/CoverFlowControl.xaml.cs | 2 +- .../Views/JumpRope/MusicJumpRope.xaml | 13 --- .../Views/JumpRope/MusicJumpRope.xaml.cs | 82 +------------------ 4 files changed, 6 insertions(+), 93 deletions(-) diff --git a/Wpf_AiSportsMicrospace/Common/SportOperate.cs b/Wpf_AiSportsMicrospace/Common/SportOperate.cs index 83f0d72..7148e16 100644 --- a/Wpf_AiSportsMicrospace/Common/SportOperate.cs +++ b/Wpf_AiSportsMicrospace/Common/SportOperate.cs @@ -155,7 +155,7 @@ namespace Wpf_AiSportsMicrospace.Common } var duration = DateTime.Now - _raiseStartTime.Value; - if (duration.TotalSeconds >= 3) + if (duration.TotalSeconds >= 1) { _raiseStartTime = null; _wristStartTime = null; diff --git a/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs b/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs index 14c5fe5..4d2df00 100644 --- a/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs +++ b/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs @@ -116,7 +116,7 @@ namespace Wpf_AiSportsMicrospace.MyUserControl { if (_currentItem.Progress < 1) { - _currentItem.Progress += 0.00556; // 控制速度 + _currentItem.Progress += 0.01; // 控制速度 if (spark != null) { var pos = GetSparkPosition(_currentItem.Progress, 150, 200); diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml index 94a9065..d4c8c9b 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml @@ -35,18 +35,5 @@ TextAlignment="Center" /> - - - - - - - - - - - - - diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs index fc21ab8..578c009 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs @@ -38,35 +38,8 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope private readonly object _updateLock = new object(); private readonly Dictionary _jumpStatus = new Dictionary(); private MusicJumpRopeContext _musicJumpRopeContext; - public Dictionary> _musicBeatsDic; private GameState _currentGameState = GameState.NotStarted; - List RankingItemList = new(); - private List _musicBeats = new List() - { - 0.545,1.09,1.635,2.18,2.725,3.27,3.815,4.36,4.905,5.45, - 5.995,6.54,7.085,7.63,8.175,8.72,9.265,9.81,10.355,10.9, - 11.445,11.99,12.535,13.08,13.625,14.17,14.715,15.26,15.805,16.35, - 16.895,17.44,17.985,18.53,19.075,19.62,20.165,20.71,21.255,21.8, - 22.345,22.89,23.435,23.98,24.525,25.07,25.615,26.16,26.705,27.25, - 27.795,28.34,28.885,29.43,29.975,30.52,31.065,31.61,32.155,32.7, - 33.245,33.79,34.335,34.88,35.425,35.97,36.515,37.06,37.605,38.15, - 38.695,39.24,39.785,40.33,40.875,41.42,41.965,42.51,43.055,43.6, - 44.145,44.69,45.235,45.78,46.325,46.87,47.415,47.96,48.505,49.05, - 49.595,50.14,50.685,51.23,51.775,52.32,52.865,53.41,53.955,54.5, - 55.045,55.59,56.135,56.68,57.225,57.77,58.315,58.86,59.405,59.95, - 60.495,61.04,61.585,62.13,62.675,63.22,63.765,64.31,64.855,65.4, - 65.945,66.49,67.035,67.58,68.125,68.67,69.215,69.76,70.305,70.85, - 71.395,71.94,72.485,73.03,73.575,74.12,74.665,75.21,75.755,76.3, - 76.845,77.39,77.935,78.48,79.025,79.57,80.115,80.66,81.205,81.75, - 82.295,82.84,83.385,83.93,84.475,85.02,85.565,86.11,86.655,87.2, - 87.745,88.29,88.835,89.38,89.925,90.47,91.015,91.56,92.105,92.65, - 93.195,93.74,94.285,94.83,95.375,95.92,96.465,97.01,97.555,98.1, - 98.645,99.19,99.735,100.28,100.825,101.37,101.915,102.46,103.005,103.55, - 104.095,104.64,105.185,105.73,106.275,106.82,107.365,107.91,108.455 - - }; - private List _musicBeatTextBlock = new List(); // 容忍时间(节拍误差) @@ -82,17 +55,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope Loaded += UserControl_Loaded; Unloaded += UserControl_Unloaded; _musicJumpRopeContext = new MusicJumpRopeContext(); - _musicBeatsDic = _musicJumpRopeContext.MusicBeatsDic; - - _totalDots = _musicJumpRopeContext.MusicBeats["1"].Count(); - - // 左控件 - LeftBeats.DotCount = _totalDots; - LeftBeats.MusicBeatsDic = _musicBeatsDic; - - // 右控件 - RightBeats.DotCount = _totalDots; - RightBeats.MusicBeatsDic = _musicBeatsDic; } private async void UserControl_Loaded(object sender, RoutedEventArgs e) @@ -285,8 +247,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope // 播放背景音乐(循环) Utils.PlayBackgroundMusic("1.MP3", true); - StartBeatScrollTimer(); - for (int i = seconds; i >= 0; i--) { countdownText.Text = i.ToString(); @@ -510,10 +470,10 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope _musicJumpRopeContext.UserBeatSyncList[indexCopy]++; _musicBeatTextBlock[indexCopy].Text = $"卡点 x{_musicJumpRopeContext.UserBeatSyncList[indexCopy]}"; - if (indexCopy == 0) - LeftBeats.SetSelected(currentSecond, true); - else - RightBeats.SetSelected(currentSecond, true); + //if (indexCopy == 0) + // LeftBeats.SetSelected(currentSecond, true); + //else + // RightBeats.SetSelected(currentSecond, true); //Application.Current.Dispatcher.BeginInvoke(() => //{ @@ -656,39 +616,5 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope return userItem; } - - private DispatcherTimer _beatScrollTimer; - private double totalTime = 108.455; // 音乐总时长 - private int _lastSecond = -1; // 上一次已经处理的秒数 - private void StartBeatScrollTimer() - { - _beatScrollTimer = new DispatcherTimer(); - _beatScrollTimer.Interval = TimeSpan.FromMilliseconds(500); // 每秒一次 - - int lastSecond = -1; - - _beatScrollTimer.Tick += (s, e) => - { - double currentTime = Utils.GetMusicCurrentTime(); - int currentSecond = (int)Math.Floor(currentTime)+1; - - if (currentSecond <= lastSecond) return; - lastSecond = currentSecond; - // 左控件 - if (_musicBeatsDic.TryGetValue(currentSecond, out var leftBeats)) - { - LeftBeats.SetSelected(currentSecond, true); - LeftBeats.ScrollToDotCenter(currentSecond, mirror: true); - } - - // 右控件 - if (_musicBeatsDic.TryGetValue(currentSecond, out var rightBeats)) - { - RightBeats.SetSelected(currentSecond, true); - RightBeats.ScrollToDotCenter(currentSecond, mirror: false); - } - }; - _beatScrollTimer.Start(); - } } }