背景
This commit is contained in:
parent
2bad6bedd2
commit
1bec6bbb84
@ -42,8 +42,6 @@ namespace Views.SquatFu
|
|||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
private GameState _currentGameState = GameState.NotStarted;
|
private GameState _currentGameState = GameState.NotStarted;
|
||||||
private readonly object _updateLock = new object();
|
|
||||||
private readonly Dictionary<int, (string lastNumber, DateTime lastChangeTime, string currentState)> _jumpStatus = new Dictionary<int, (string, DateTime, string)>();
|
|
||||||
private WhackAMoleContext _WhackAMoleContext;
|
private WhackAMoleContext _WhackAMoleContext;
|
||||||
Image tipImage;
|
Image tipImage;
|
||||||
|
|
||||||
@ -80,11 +78,14 @@ namespace Views.SquatFu
|
|||||||
|
|
||||||
_WhackAMoleContext.CirclePositions = Utils.GetPointsList(pointCount, cfg);
|
_WhackAMoleContext.CirclePositions = Utils.GetPointsList(pointCount, cfg);
|
||||||
|
|
||||||
DrawCirclesWithText();
|
|
||||||
// 播放音乐
|
|
||||||
PlayMusic("raisehand.mp3");
|
|
||||||
_mainWin.HumanFrameUpdated += OnHumanFrameUpdated;
|
_mainWin.HumanFrameUpdated += OnHumanFrameUpdated;
|
||||||
_mainWin.WebcamClient.StartExtract();
|
_mainWin.WebcamClient.StartExtract();
|
||||||
|
|
||||||
|
DrawCirclesWithText();
|
||||||
|
|
||||||
|
// 播放音乐
|
||||||
|
PlayMusic("raisehand.mp3");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
||||||
@ -180,61 +181,51 @@ namespace Views.SquatFu
|
|||||||
private bool _isCountdownStarted = false; // 新增标记
|
private bool _isCountdownStarted = false; // 新增标记
|
||||||
private void OnHumanFrameUpdated(object sender, List<Human> humans)
|
private void OnHumanFrameUpdated(object sender, List<Human> humans)
|
||||||
{
|
{
|
||||||
try
|
if (humans == null || humans.Count == 0) return;
|
||||||
|
|
||||||
|
switch (_currentGameState)
|
||||||
{
|
{
|
||||||
if (humans == null || humans.Count == 0) return;
|
case GameState.NotStarted: // 未开始
|
||||||
|
if (!_isCountdownStarted) // 只有倒计时未开始才检测左手
|
||||||
switch (_currentGameState)
|
{
|
||||||
{
|
int leftWaving = sportOperate.VerifyLeftWavingAction(humans);
|
||||||
case GameState.NotStarted: // 未开始
|
if (leftWaving == 5)
|
||||||
if (!_isCountdownStarted) // 只有倒计时未开始才检测左手
|
|
||||||
{
|
{
|
||||||
int leftWaving = sportOperate.VerifyLeftWavingAction(humans);
|
_isCountdownStarted = true;
|
||||||
if (leftWaving == 5)
|
_mainWin.HumanFrameUpdated -= OnHumanFrameUpdated;
|
||||||
{
|
|
||||||
_isCountdownStarted = true;
|
|
||||||
_mainWin.HumanFrameUpdated -= OnHumanFrameUpdated;
|
|
||||||
|
|
||||||
// 举左手逻辑,例如结束动画或退出
|
// 举左手逻辑,例如结束动画或退出
|
||||||
var newPage = new Home();
|
var newPage = new Home();
|
||||||
_mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
_mainWin?.SwitchPageWithMaskAnimation(newPage, true);
|
||||||
return; // 提前退出
|
return; // 提前退出
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int rightWaving = sportOperate.VerifyRightWavingAction(humans);
|
int rightWaving = sportOperate.VerifyRightWavingAction(humans);
|
||||||
if (rightWaving >= 3 && RankingGrid.Visibility != Visibility.Visible)
|
if (rightWaving >= 3 && RankingGrid.Visibility != Visibility.Visible)
|
||||||
|
{
|
||||||
|
switch (rightWaving)
|
||||||
{
|
{
|
||||||
switch (rightWaving)
|
case (int)WavingAction.FirstHand:
|
||||||
{
|
_currentGameState = GameState.Running;
|
||||||
case (int)WavingAction.FirstHand:
|
StartCountdown(3);
|
||||||
_currentGameState = GameState.Running;
|
_isCountdownStarted = true; // 倒计时开始,停止左手检测
|
||||||
StartCountdown(3);
|
break;
|
||||||
_isCountdownStarted = true; // 倒计时开始,停止左手检测
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case GameState.Running: // 游戏进行中
|
case GameState.Running: // 游戏进行中
|
||||||
UpdateCircleCounts(humans);
|
UpdateCircleCounts(humans);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine("OnFrameExtracted error: " + ex.Message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double _currentCountdown = 3600;
|
|
||||||
private DateTime _lastUpdateTime = DateTime.Now;
|
|
||||||
private async void StartCountdown(int start = 3)
|
private async void StartCountdown(int start = 3)
|
||||||
{
|
{
|
||||||
_mainWin.ShowCountDownAnimation();
|
_mainWin.ShowCountDownAnimation();
|
||||||
|
|
||||||
Utils.PlayBackgroundMusic("whackamole.mp3", false);
|
Utils.PlayBackgroundMusic("countdown_3.mp3", false);
|
||||||
|
|
||||||
//开始人脸识别 =============================================
|
//开始人脸识别 =============================================
|
||||||
//Action < VideoFrame > handler = null;
|
//Action < VideoFrame > handler = null;
|
||||||
|
|
||||||
@ -279,9 +270,10 @@ namespace Views.SquatFu
|
|||||||
countdownText.Text = "GO!";
|
countdownText.Text = "GO!";
|
||||||
countdownGrid.Visibility = Visibility.Hidden;
|
countdownGrid.Visibility = Visibility.Hidden;
|
||||||
|
|
||||||
|
|
||||||
// 播放背景音乐(循环)
|
// 播放背景音乐(循环)
|
||||||
Utils.PlayBackgroundMusic("homeprojectselected1.mp3", true);
|
|
||||||
|
Utils.PlayBackgroundMusic("whackamole.mp3", false);
|
||||||
|
|
||||||
// 启动60秒倒计时(独立任务)
|
// 启动60秒倒计时(独立任务)
|
||||||
StartGameCountdown(60);
|
StartGameCountdown(60);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user