public void PlayorPause() //暂停播放键功能方法 { switch (PlayState) //再检查播放状态 { case playState.stoped: //如果是停止状态 if (NowPlayingList.Count() != 0) //如果列表非空 { PlayState = playState.playing; //先更改播放状态 Open(new Uri(Convert.ToString(NowPlayingList[NowPlayingNumber].Path))); //打开文件 Play(); //播放,以上两步缺一不可 } else { MessageBox.Show("当前播放列表为空", "错误"); } break; case playState.playing: //如果是正在播放的状态 PlayState = playState.paused; //修改播放状态标记 Pause(); //暂停 break; case playState.paused: //如果是暂停状态 PlayState = playState.playing; Play(); //播放之 break; } }
// Update is called once per frame void Update() { switch (theCurrGameState) { case gameState.initialize: initialize(); break; case gameState.playGame: //print ("<!> Enter Play Game " + gameState.playGame + "<!>"); // print ("<!> gameEngine " + currPlayState + "<!>"); switch (currPlayState) { case playState.movingCubes: print("<!> gameEngine <!>"); gameEngine theGameEngine = GetComponent <gameEngine>(); theGameEngine.initMe(); currPlayState = playState.executingTask; break; } break; case gameState.gameOver: //loadGameOverGameManager(); StartCoroutine("loadGameOver"); currPlayState = playState.movingCubes; break; } }
public void Pause() { currentState = playState.pause; foreach (var item in startedEvents) { StopCoroutine(item); } startedEvents.Clear(); }
public void Play() { currentState = playState.play; foreach (var item in events) { if (item.time >= currentTime) { var c = StartCoroutine(playNoteAfter(item.time - currentTime, item)); startedEvents.Add(c); } } }
public void ChangeGameState() { LevelStateManagerScript.levelDone = false; if (Random.value <= 0.5f) { currentState = playState.twoD; Debug.Log("Game state is in 2D"); } else { currentState = playState.threeD; Debug.Log("Game state is in 3D"); } LevelStateManagerScript.levelEnd = false; fieldSpawner.SpawnNewPlayfield(); }
public void UserSayPlayThis(Music tempMusic, List MainList)//播放用户在音乐列表里选择的歌曲 { //先检查tempMusic是否是空值,因为用户可能双击了列表区的空白地方 if (tempMusic == null) { return; } if (tempMusic.Path == NowPlayingList[NowPlayingNumber].Path)//如果用户选择的音乐与当前所播放的音乐是同一个文件,则没有操作 { return; } else { PlayState = playState.playing;//改变播放状态 Open(new Uri(tempMusic.Path)); Play(); } //下边用来根据当前文件地址在列表中查找相应文件,从而定位用户选择的歌在列表中的位置,方便播放完之后自动进入下一首 switch (LoopState) { case loopState.invertedOrder: //如果是逆序的话 case loopState.positiveOrder: //如果是顺序播放的话 case loopState.singleTuneCirculation: //如果是单曲循环的话 for (int i = 0; i <= MainList.MusicList.Count() - 1; i++) //遍历MusicList列表,一一比对文件地址 { if (MainList.MusicList[i].Path == tempMusic.Path) //如果两者地址一样的话 { NowPlayingNumber = i; //就更改NowPlayingNumber的值 } } break; case loopState.disOrder: //如果是乱序的话 for (int i = 0; i <= MainList.RandomList.Count() - 1; i++) //遍历乱序表 { if (MainList.RandomList[i].Path == tempMusic.Path) { NowPlayingNumber = i; } } break; } }
public void Last()//切上一首歌 { if (NowPlayingList.Count() == 0) { return; } switch (LoopState) //根据循环状态执行相应代码 { case loopState.positiveOrder: //如果是顺序播放 case loopState.singleTuneCirculation: //如果单曲循环 case loopState.disOrder: //如果乱序播放 this.ListsLast(); break; case loopState.invertedOrder: //如果倒序播放 this.ListsNext(); break; } PlayState = playState.playing;//改变播放状态 }
public void Next() //切下一首歌 { if (NowPlayingList.Count() == 0) //先检测nowPlayingList是否为空,出现情况为用户未加载音乐时点击“下一首”按钮 { return; } else { switch (LoopState) //根据循环状态执行相应代码 { case loopState.singleTuneCirculation: //如果单曲循环 case loopState.positiveOrder: //如果是顺序播放 case loopState.disOrder: //如果乱序播放 this.ListsNext(); break; case loopState.invertedOrder: //如果倒序播放 this.ListsLast(); break; } PlayState = playState.playing;//改变播放状态 } }
/// <summary> /// Lógica del programa. /// </summary> /// <returns>Si se sale del programa o no</returns> public Boolean update() { this.currentScreenState = this.nextScreenState; this.currentPlayState = this.nextPlayState; switch (this.currentScreenState) { case screenState.INIT: // algo en inicio? this.nextScreenState = screenState.MENU; break; case screenState.MENU: updateButtonsState(this.menuButtons); if (this.menuButtons[(int)GameButtonList.menuButton.PLAY].justPushed()) { this.nextScreenState = screenState.PLAY; this.nextPlayState = playState.INIT; } else if (this.menuButtons[(int)GameButtonList.menuButton.EXIT].justPushed()) { // termina el juego return(false); } break; case screenState.PLAY: switch (this.currentPlayState) { case playState.INIT: // algo en inicio? this.gamePostures = null; this.gameScores.Clear(); this.nextPlayState = playState.SELECT_POSTURE; break; case playState.SELECT_POSTURE: // actualiza la postura objetivo if (updateCurrentGamePosture()) { /// @FIX001: this.drawPostureTimeOut = Stopwatch.StartNew(); this.nextPlayState = playState.DRAW_POSTURE; } // si no quedan mas posturas va a la puntuacion final else { this.nextPlayState = playState.FINAL_SCORE; } break; case playState.DRAW_POSTURE: // Esta fase es para presentarle al usuario la postura objetivo // TIMEOUT de 10 segundos o pulsar CONTINUE /// @FIX001: Estaba a null el this.drawPostureTimeOut, asique le he puesto valor en SELECT_POSTURE (Margen de error: 1frame). updateButtonsState(this.pauseButtons); if (this.pauseButtons[(int)GameButtonList.pauseButton.CONTINUE].justPushed() || isTimedOut(this.drawPostureTimeOut, DRAW_POSTURE_TIME)) { this.drawPostureTimeOut.Reset(); this.nextPlayState = playState.DETECT_POSTURE; } break; case playState.DETECT_POSTURE: updateButtonsState(this.gameButtons); if (this.gameButtons[(int)GameButtonList.gameButton.PAUSE].justPushed()) { this.nextPlayState = playState.PAUSE; } else { if (playerSkeleton != null) { Posture.Posture p = new Posture.Posture(playerSkeleton); score = p.compareTo(gamePostures[gamePosturesIndex], ref jointScore, averageTolerance, puntualTolerance); if (score < 1.0) { this.holdPostureTimeOut = Stopwatch.StartNew(); this.nextPlayState = playState.HOLD_POSTURE; } } } break; case playState.HOLD_POSTURE: updateButtonsState(this.gameButtons); if (this.gameButtons[(int)GameButtonList.gameButton.PAUSE].justPushed()) { this.nextPlayState = playState.PAUSE; } else { if (playerSkeleton != null) { Posture.Posture p = new Posture.Posture(playerSkeleton); score = p.compareTo(gamePostures[gamePosturesIndex], ref jointScore, averageTolerance, puntualTolerance); if (score < 1.0) { // La postura hay que mantenerla 2 segundos (HOLD_POSTURE_TIME) if (isTimedOut(this.holdPostureTimeOut, HOLD_POSTURE_TIME)) { gameScores.Add(gamePostures[gamePosturesIndex], score); this.holdPostureTimeOut.Reset(); this.scoreTimeOut = Stopwatch.StartNew(); this.nextPlayState = playState.SCORE; } } else { this.holdPostureTimeOut.Reset(); this.nextPlayState = playState.DETECT_POSTURE; } } } break; case playState.PAUSE: updateButtonsState(this.pauseButtons); if (this.pauseButtons[(int)GameButtonList.pauseButton.CONTINUE].justPushed()) { this.nextPlayState = playState.DETECT_POSTURE; } else if (this.pauseButtons[(int)GameButtonList.pauseButton.REPLAY].justPushed()) { this.nextPlayState = playState.INIT; } else if (this.pauseButtons[(int)GameButtonList.pauseButton.EXIT].justPushed()) { this.nextPlayState = playState.END; } break; case playState.SCORE: updateButtonsState(this.scoreButtons); // TIMEOUT de 10 segundos a la siguiente postura o se pulsa alguna opcion if (this.scoreButtons[(int)GameButtonList.scoreButton.NEXT].justPushed() || isTimedOut(this.scoreTimeOut, SCORE_TIME)) { this.scoreTimeOut.Reset(); this.nextPlayState = playState.SELECT_POSTURE; } else if (this.scoreButtons[(int)GameButtonList.scoreButton.MENU].justPushed()) { this.scoreTimeOut.Reset(); this.nextPlayState = playState.END; } else if (this.scoreButtons[(int)GameButtonList.scoreButton.REPLAY].justPushed()) { this.scoreTimeOut.Reset(); this.nextPlayState = playState.INIT; } break; case playState.FINAL_SCORE: updateButtonsState(this.scoreButtons); if (this.scoreButtons[(int)GameButtonList.scoreButton.MENU].justPushed()) { this.nextPlayState = playState.END; } else if (this.scoreButtons[(int)GameButtonList.scoreButton.REPLAY].justPushed()) { this.nextPlayState = playState.INIT; } break; default: case playState.END: this.nextScreenState = screenState.MENU; break; } break; default: case screenState.END: return(false); // Se avisa de que el programa dejara de actualizarse } return(true); // Si no esta en estado de END se continua con la ejecucion }
/// <summary> /// Lógica del programa. /// </summary> /// <returns>Si se sale del programa o no</returns> public Boolean update() { this.currentScreenState = this.nextScreenState; this.currentPlayState = this.nextPlayState; switch (this.currentScreenState) { case screenState.INIT: // algo en inicio? this.nextScreenState = screenState.MENU; break; case screenState.MENU: updateButtonsState(this.menuButtons); if (this.menuButtons[(int)GameButtonList.menuButton.PLAY].justPushed()) { this.nextScreenState = screenState.PLAY; this.nextPlayState = playState.INIT; } else if (this.menuButtons[(int)GameButtonList.menuButton.EXIT].justPushed()) { // termina el juego return false; } break; case screenState.PLAY: switch (this.currentPlayState) { case playState.INIT: // algo en inicio? this.gamePostures = null; this.gameScores.Clear(); this.nextPlayState = playState.SELECT_POSTURE; break; case playState.SELECT_POSTURE: // actualiza la postura objetivo if (updateCurrentGamePosture()) { /// @FIX001: this.drawPostureTimeOut = Stopwatch.StartNew(); this.nextPlayState = playState.DRAW_POSTURE; } // si no quedan mas posturas va a la puntuacion final else { this.nextPlayState = playState.FINAL_SCORE; } break; case playState.DRAW_POSTURE: // Esta fase es para presentarle al usuario la postura objetivo // TIMEOUT de 10 segundos o pulsar CONTINUE /// @FIX001: Estaba a null el this.drawPostureTimeOut, asique le he puesto valor en SELECT_POSTURE (Margen de error: 1frame). updateButtonsState(this.pauseButtons); if (this.pauseButtons[(int)GameButtonList.pauseButton.CONTINUE].justPushed() || isTimedOut(this.drawPostureTimeOut, DRAW_POSTURE_TIME)) { this.drawPostureTimeOut.Reset(); this.nextPlayState = playState.DETECT_POSTURE; } break; case playState.DETECT_POSTURE: updateButtonsState(this.gameButtons); if (this.gameButtons[(int)GameButtonList.gameButton.PAUSE].justPushed()) this.nextPlayState = playState.PAUSE; else { if (playerSkeleton != null) { Posture.Posture p = new Posture.Posture(playerSkeleton); score = p.compareTo(gamePostures[gamePosturesIndex], ref jointScore, averageTolerance, puntualTolerance); if (score < 1.0) { this.holdPostureTimeOut = Stopwatch.StartNew(); this.nextPlayState = playState.HOLD_POSTURE; } } } break; case playState.HOLD_POSTURE: updateButtonsState(this.gameButtons); if (this.gameButtons[(int)GameButtonList.gameButton.PAUSE].justPushed()) this.nextPlayState = playState.PAUSE; else { if (playerSkeleton != null) { Posture.Posture p = new Posture.Posture(playerSkeleton); score = p.compareTo(gamePostures[gamePosturesIndex], ref jointScore, averageTolerance, puntualTolerance); if (score < 1.0) { // La postura hay que mantenerla 2 segundos (HOLD_POSTURE_TIME) if (isTimedOut(this.holdPostureTimeOut, HOLD_POSTURE_TIME)) { gameScores.Add(gamePostures[gamePosturesIndex], score); this.holdPostureTimeOut.Reset(); this.scoreTimeOut = Stopwatch.StartNew(); this.nextPlayState = playState.SCORE; } } else { this.holdPostureTimeOut.Reset(); this.nextPlayState = playState.DETECT_POSTURE; } } } break; case playState.PAUSE: updateButtonsState(this.pauseButtons); if (this.pauseButtons[(int)GameButtonList.pauseButton.CONTINUE].justPushed()) this.nextPlayState = playState.DETECT_POSTURE; else if (this.pauseButtons[(int)GameButtonList.pauseButton.REPLAY].justPushed()) this.nextPlayState = playState.INIT; else if (this.pauseButtons[(int)GameButtonList.pauseButton.EXIT].justPushed()) this.nextPlayState = playState.END; break; case playState.SCORE: updateButtonsState(this.scoreButtons); // TIMEOUT de 10 segundos a la siguiente postura o se pulsa alguna opcion if (this.scoreButtons[(int)GameButtonList.scoreButton.NEXT].justPushed() || isTimedOut(this.scoreTimeOut, SCORE_TIME)) { this.scoreTimeOut.Reset(); this.nextPlayState = playState.SELECT_POSTURE; } else if (this.scoreButtons[(int)GameButtonList.scoreButton.MENU].justPushed()) { this.scoreTimeOut.Reset(); this.nextPlayState = playState.END; } else if (this.scoreButtons[(int)GameButtonList.scoreButton.REPLAY].justPushed()) { this.scoreTimeOut.Reset(); this.nextPlayState = playState.INIT; } break; case playState.FINAL_SCORE: updateButtonsState(this.scoreButtons); if (this.scoreButtons[(int)GameButtonList.scoreButton.MENU].justPushed()) this.nextPlayState = playState.END; else if (this.scoreButtons[(int)GameButtonList.scoreButton.REPLAY].justPushed()) this.nextPlayState = playState.INIT; break; default: case playState.END: this.nextScreenState = screenState.MENU; break; } break; default: case screenState.END: return false; // Se avisa de que el programa dejara de actualizarse } return true; // Si no esta en estado de END se continua con la ejecucion }
// Use this for initialization void Start() { currentState = playState.threeD; }