update:倒计时bug'

This commit is contained in:
ltx 2026-02-24 13:19:21 +08:00
parent d9e2a90a22
commit c6c50f3d6a
5 changed files with 59 additions and 39 deletions

View File

@ -175,7 +175,8 @@ namespace Wpf_AiSportsMicrospace
else else
{ {
//var newPage = new TrainingRecords(); //var newPage = new TrainingRecords();
var newPage = new WhackAMole(); //var newPage = new WhackAMole();
var newPage = new StandingLeap();
mainWin?.SwitchPageWithMaskAnimation(newPage, true); mainWin?.SwitchPageWithMaskAnimation(newPage, true);
} }
} }

View File

@ -25,7 +25,9 @@
x:Name="centerImg4" x:Name="centerImg4"
Visibility="Hidden" Visibility="Hidden"
gif:ImageBehavior.AnimatedSource="/Resources/Img/test_img/jump_long/jumping.gif" gif:ImageBehavior.AnimatedSource="/Resources/Img/test_img/jump_long/jumping.gif"
gif:ImageBehavior.RepeatBehavior="0" gif:ImageBehavior.RepeatBehavior="1x"
gif:ImageBehavior.AutoStart="False"
gif:ImageBehavior.AnimationSpeedRatio="1.5"
gif:ImageBehavior.AnimateInDesignMode="True" gif:ImageBehavior.AnimateInDesignMode="True"
HorizontalAlignment="Left" VerticalAlignment="Top" Margin="824,72,0,0" Width="824" Height="610"/> HorizontalAlignment="Left" VerticalAlignment="Top" Margin="824,72,0,0" Width="824" Height="610"/>
<Grid Width="1920" Height="1080" Background="#80000000" x:Name="TipBox" Opacity="0"> <Grid Width="1920" Height="1080" Background="#80000000" x:Name="TipBox" Opacity="0">

View File

@ -230,7 +230,7 @@ namespace Views.JumpLong
ImageBehavior.SetRepeatBehavior(centerImg4, new RepeatBehavior(2)); ImageBehavior.SetRepeatBehavior(centerImg4, new RepeatBehavior(2));
ImageBehavior.SetRepeatBehavior(centerImg4, new RepeatBehavior(1)); ImageBehavior.SetRepeatBehavior(centerImg4, new RepeatBehavior(1));
ImageBehavior.GetAnimationController(centerImg4).Play(); ImageBehavior.GetAnimationController(centerImg4).Play();
await Task.Delay(800); await Task.Delay(2100);
_sport.Stop();//关闭运动 _sport.Stop();//关闭运动
_mainWin.FacialRecognitionEvent -= this.HumanPredicting; _mainWin.FacialRecognitionEvent -= this.HumanPredicting;
count.Text = counts; count.Text = counts;

View File

@ -226,13 +226,13 @@ namespace Wpf_AiSportsMicrospace.Views
StartCountdown(3); StartCountdown(3);
_isCountdownStarted = true; // 倒计时开始,停止左手检测 _isCountdownStarted = true; // 倒计时开始,停止左手检测
break; break;
case (int)WavingAction.Raising: //case (int)WavingAction.Raising:
UpdateCountdown(); // UpdateCountdown();
break; // break;
case (int)WavingAction.RaiseHand: //case (int)WavingAction.RaiseHand:
FinishCountdown(); // FinishCountdown();
_currentGameState = GameState.Running; // 倒计时完成 → 游戏开始 // _currentGameState = GameState.Running; // 倒计时完成 → 游戏开始
break; // break;
} }
} }
break; break;
@ -246,7 +246,7 @@ namespace Wpf_AiSportsMicrospace.Views
private double _currentCountdown = 3600; private double _currentCountdown = 3600;
private DateTime _lastUpdateTime = DateTime.Now; private DateTime _lastUpdateTime = DateTime.Now;
private void StartCountdown(int start = 3) private async void StartCountdown(int start = 3)
{ {
_mainWin.ShowCountDownAnimation(); _mainWin.ShowCountDownAnimation();
//_currentCountdown = start; //_currentCountdown = start;
@ -289,6 +289,10 @@ namespace Wpf_AiSportsMicrospace.Views
// 绑定事件 // 绑定事件
_mainWin.FacialRecognitionEvent += handler; _mainWin.FacialRecognitionEvent += handler;
await Task.Delay(3000);
FinishCountdown();
_currentGameState = GameState.Running;
} }
private void UpdateCountdown() private void UpdateCountdown()

View File

@ -201,15 +201,18 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
switch (rightWaving) switch (rightWaving)
{ {
case (int)WavingAction.FirstHand: case (int)WavingAction.FirstHand:
StartCountdown(3); if (!_isCountdownStarted)
_isCountdownStarted = true; {
StartCountdown(3);
}
break; break;
case (int)WavingAction.Raising: case (int)WavingAction.Raising:
UpdateCountdown(); //UpdateCountdown();
break; break;
case (int)WavingAction.RaiseHand: case (int)WavingAction.RaiseHand:
FinishCountdown(); //FinishCountdown();
_currentGameState = GameState.Running; //_currentGameState = GameState.Running;
break; break;
} }
} }
@ -230,15 +233,18 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
private int _currentCountdown = 3; private int _currentCountdown = 3;
private DateTime _lastUpdateTime = DateTime.Now; private DateTime _lastUpdateTime = DateTime.Now;
private void StartCountdown(int start = 4) private async void StartCountdown(int start = 4)
{ {
_mainWin.ShowCountDownAnimation();
_isCountdownStarted = true;
_currentCountdown = start; _currentCountdown = start;
//countdownText.Text = _currentCountdown.ToString(); //countdownText.Text = _currentCountdown.ToString();
//countdownGrid.Visibility = Visibility.Visible; //countdownGrid.Visibility = Visibility.Visible;
_lastUpdateTime = DateTime.Now; _lastUpdateTime = DateTime.Now;
_mainWin.ShowCountDownAnimation();
Utils.PlayBackgroundMusic("countdown_3.mp3", false); Utils.PlayBackgroundMusic("countdown_3.mp3", false);
//UpdateCountdown();
//开始人脸识别============================================= //开始人脸识别=============================================
Action<VideoFrame> handler = null; Action<VideoFrame> handler = null;
@ -269,8 +275,31 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
// 这里可以继续处理 studentList // 这里可以继续处理 studentList
}; };
// 绑定事件 //// 绑定事件
_mainWin.FacialRecognitionEvent += handler; _mainWin.FacialRecognitionEvent += handler;
await Task.Delay(3000);
FinishCountdown();
_currentGameState = GameState.Running;
}
private void UpdateCountdown()
{
if ((DateTime.Now - _lastUpdateTime).TotalSeconds >= 1)
{
_lastUpdateTime = DateTime.Now;
_currentCountdown--;
if (_currentCountdown > 0)
{
countdownText.Text = _currentCountdown.ToString();
}
else
{
FinishCountdown();
_currentGameState = GameState.Running;
}
}
} }
private async Task LoadImageFromUrlAsync(string imageUrl, Image image) private async Task LoadImageFromUrlAsync(string imageUrl, Image image)
@ -301,24 +330,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
} }
} }
private void UpdateCountdown()
{
if ((DateTime.Now - _lastUpdateTime).TotalSeconds >= 1)
{
_lastUpdateTime = DateTime.Now;
_currentCountdown--;
if (_currentCountdown > 0)
{
countdownText.Text = _currentCountdown.ToString();
}
else
{
FinishCountdown();
}
}
}
private async void FinishCountdown() private async void FinishCountdown()
{ {
countdownText.Text = "GO!"; countdownText.Text = "GO!";
@ -593,8 +604,10 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
private void Image_MouseDown(object sender, MouseButtonEventArgs e) private void Image_MouseDown(object sender, MouseButtonEventArgs e)
{ {
popSilder1.StartMarginAnimation(); //popSilder1.StartMarginAnimation();
popSilder2.StartMarginAnimation(); //popSilder2.StartMarginAnimation();
//StartCountdown();
StartCountdown(3);
} }
} }
} }