/// <summary> /// changes the game's state /// </summary> /// <param name="newMode"></param> private void SetMode(GameMode newMode) { oturn = oturn + 10000; turn = 0; GameMode oldStatus = Status; switch (newMode) { case GameMode.GAME_OVER_DEATH: case GameMode.GAME_OVER_ESC: if (newMode == GameMode.GAME_OVER_DEATH) { cfg.playerCfg.scoreNo = cfg.scores.add(cfg.playerName, Score) + 1; } if (Audio != null) { if (newMode == GameMode.GAME_OVER_DEATH) { Audio.PlayDeath(); } Audio.MusicMenu(); } numLaby = 0; SetLabyrinth(numLaby); if ((oldStatus == GameMode.PLAY) || (oldStatus == GameMode.DEATH)) { save(); } SleepTime = Constants.INITIAL_SLEEP_TIME; if (Timer != null && Timer.IsStarted) { Timer.Stop(); } break; case GameMode.READY: if (Audio != null) { Audio.PlayIntro(); Audio.MusicGame(); } // copie le niveau dans le labyrinthe courant DrawReady(); // init du laby courant SetLabyrinth(numLaby); DrawLives(); if (Timer == null) { throw new Exception("You must provide a timer, fill 'Timer' property"); } if (!Timer.IsStarted) { Timer.Start(); } break; case GameMode.PLAY: //draw.drawBack(); if (PacMan == null) { PacMan = new Pacman(); } else { PacMan.Init(); } // taskBox.tskProvider.checkSpeed(-1);//init with default speed value List <Ghost> tmpList = new List <Ghost>(); CurrentBonus = null; for (int i = 0; i < cfg.ghostCount; i++) { tmpList.Add(new Ghost(FANTOME_FIRST + i)); } Ghosts = tmpList; break; case GameMode.DEATH: Lives--; Audio.PlayKill(); _FlyingScores.Clear(); if (PacMan != null) { PacMan.Dead(); } break; } Status = newMode; }
/// <summary> /// changes the game's state /// </summary> /// <param name="newMode"></param> private void SetMode(GameMode newMode) { turn = 0; Status = newMode; switch (Status) { case GameMode.GAME_OVER: // copie le niveau dans le labyrinthe courant numLaby = 0; SetLabyrinth(numLaby); SleepTime = INITIAL_SLEEP_TIME; if (Timer != null && Timer.IsStarted) { Timer.Stop(); } //draw.drawGameOver(); //drawScore(); break; case GameMode.READY: // copie le niveau dans le labyrinthe courant DrawReady(); // init du laby courant SetLabyrinth(numLaby); DrawLives(); if (Timer == null) { throw new Exception("You must provide a timer, fill 'Timer' property"); } if (!Timer.IsStarted) { Timer.Start(); } break; case GameMode.PLAY: //draw.drawBack(); if (PacMan == null) { PacMan = new Pacman(); } else { PacMan.Init(); } List <Ghost> tmpList = new List <Ghost>(); CurrentBonus = null; for (int i = 0; i < FANTOME_COUNT; i++) { tmpList.Add(new Ghost(FANTOME_FIRST + i)); } Ghosts = tmpList; break; case GameMode.DEATH: Lives--; _FlyingScores.Clear(); if (PacMan != null) { PacMan.Dead(); } break; } }