/// <summary> /// Fonction dont le rôle est de lancer le jeu /// </summary> public void Run() { //Ajout des étoiles dans le jeu for (int i = 0; i < 250; i++) { stars.Add(new Star((r.Next(0, WIDTH)), r.Next(0, r.Next(0, HEIGHT)), DELTA_T)); } // ppoulin // Chargement de la StringTable. A décommenter au moment opportun if (ErrorCode.OK == StringTable.GetInstance().Parse(File.ReadAllText("Data/st.txt"))) { window.SetActive(); //Tant que la fenêtre est ouverte while (window.IsOpen) { //Afficher le contenu à l'écran window.Clear(Color.Black); window.DispatchEvents(); if (false == Update()) { break; } Draw(); window.Display(); } } }
/// <summary> /// Méthode principale de la partie. /// </summary> public void Run() { if (File.Exists("Data/st.txt")) { if (ErrorCode.OK == StringTable.GetInstance().Parse(File.ReadAllLines("Data/st.txt"))) { InitGame(); { window.SetActive(); while (window.IsOpen) { window.Clear(Color.Black); window.DispatchEvents(); if (false == Update()) { break; } Draw(); window.Display(); } } } } }
public void Run() { // ppoulin // Chargement de la StringTable. A décommenter au moment opportun if (ErrorCode.OK == StringTable.GetInstance().Parse(File.ReadAllText("Data/st.txt"))) { window.SetActive(); while (window.IsOpen) { window.Clear(Color.Black); window.DispatchEvents(); if (false == Update()) { break; } Draw(); window.Display(); } } }
/// <summary> /// Affichage de tous les éléments du jeu /// </summary> public void Draw() { // Parcourez les listes appropriées pour faire afficher les éléments demandés. hero.Draw(window); foreach (Projectile i in projectiles) { i.Draw(window); } foreach (Enemy enemy in enemies) { enemy.Draw(window); } foreach (Enemy enemy in basicEnemies) { enemy.Draw(window); } foreach (Star star in stars) { star.Draw(window); } foreach (Particule particule in particles) { particule.Draw(window); } // Affichage des statistiques.A décommenter au moment opportun //Temps total text.Position = new Vector2f(0, 10); text.DisplayedString = string.Format("{1} = {0,-5}", ((int)(totalTime)).ToString(), StringTable.GetInstance().GetValue(CurrentLanguage, "ID_TOTAL_TIME")); window.Draw(text); //Points de vie text.Position = new Vector2f(0, 50); text.DisplayedString = string.Format("{1} = {0,-4}", hero.Life.ToString(), StringTable.GetInstance().GetValue(CurrentLanguage, "ID_LIFE")); window.Draw(text); }
/// <summary> /// Fonction dont le rôle est d'afficher le contenu à l'écran /// </summary> public void Draw() { // Parcourir les listes appropriées pour faire afficher les éléments souhaités. foreach (Star etoile in stars) { etoile.Draw(window); } foreach (Projectile projectile in projectiles) { projectile.Draw(window); } foreach (Projectile projectile in projectilesBomb) { projectile.Draw(window); } foreach (Particle particule in particules) { particule.Draw(window); } //Afficher le héro: hero.Draw(window); //Afficher les ennemis foreach (Enemy ennemi in ennemis) { ennemi.Draw(window); } // Affichage des statistiques: // Temps total text.Position = new Vector2f(0, 10); text.DisplayedString = string.Format("{1} = {0,-5}", ((int)(totalTime / 100)).ToString(), StringTable.GetInstance().GetValue(currentLanguage, "ID_TOTAL_TIME")); window.Draw(text); // Points de vie text.Position = new Vector2f(0, 50); text.DisplayedString = string.Format("{1} = {0,-4}", hero.Life.ToString(), StringTable.GetInstance().GetValue(currentLanguage, "ID_LIFE")); window.Draw(text); }
public void TestGetValueInvalide() { StringTable st = StringTable.GetInstance(); Assert.AreNotEqual(st.GetValue(Language.English, "ID_TOTAL_TIME"), "Temps total"); }
public void TestGetValueValide() { StringTable st = StringTable.GetInstance(); Assert.AreEqual(st.GetValue(Language.French, "ID_TOTAL_TIME"), "Temps total"); }
public void TestItemsManquants3() { StringTable st = StringTable.GetInstance(); Assert.AreEqual(ErrorCode.MISSING_FIELD, st.Parse(@" ==> Temps total---Total time ==>Vie--- Life")); }
public void TestItemManquant2() { StringTable st = StringTable.GetInstance(); Assert.AreEqual(ErrorCode.MISSING_FIELD, st.Parse(@"ID_TOTAL_TIME==>Temps totalTotal timeID_LIFE==>VieLife")); }
public void TestContenueIncorrect() { StringTable st = StringTable.GetInstance(); Assert.AreEqual(ErrorCode.MISSING_FIELD, st.Parse("sdgsfgsdfgsfdg")); }
public void TestFichierCorrect() { StringTable st = StringTable.GetInstance(); Assert.AreEqual(ErrorCode.OK, st.Parse(File.ReadAllText("Data/st.txt"))); }
public void TestFichierVide() { StringTable st = StringTable.GetInstance(); Assert.AreEqual(ErrorCode.MISSING_FIELD, st.Parse("")); }
/// <summary> /// Méthode qui est appelée une fois par frame pour dessiner tout les objets à l'écran. /// </summary> public void Draw() { // Update Camera position view.Center = new Vector2f(((1f / 11f) * hero.Position.X + (10f / 11f) * GAME_WIDTH / 2), ((1f / 11f) * hero.Position.Y + (10f / 11f) * GAME_HEIGHT / 2)); window.SetView(view); // Parcourez les listes appropriées pour faire afficher les éléments demandés. foreach (var projectile in projectiles) { projectile.Draw(window); } foreach (var star in stars) { star.Draw(window); } foreach (var wall in walls) { wall.Draw(window); } foreach (var particle in fragmentParticles) { particle.Draw(window); } foreach (var particle in smokeParticles) { particle.Draw(window); } foreach (var character in enemies) { character.Draw(window); } hero.Draw(window); #region Draw Text if (!GameIsRunning) { PauseScreen pauseScreen = new PauseScreen(0, 0, 4); pauseScreen.Draw(window); // Pause text text.DisplayedString = $"{StringTable.GetInstance().GetValue(CurrentLanguage, "ID_PAUSE")}"; text.Position = new Vector2f(Game.GAME_WIDTH / 2 - (text.DisplayedString.Length * text.CharacterSize) / 2, GAME_HEIGHT / 2 - text.CharacterSize); window.Draw(text); // Start prompt text if (controller.ControllerIsPluggedIn()) { text.DisplayedString = $"{StringTable.GetInstance().GetValue(CurrentLanguage, "ID_START_PROMPT")}"; } else { text.DisplayedString = $"{StringTable.GetInstance().GetValue(CurrentLanguage, "ID_START_KEYBOARD_PROMPT")}"; } text.CharacterSize = 18; text.Position = new Vector2f(Game.GAME_WIDTH / 2 - (text.DisplayedString.Length * text.CharacterSize) / 2, GAME_HEIGHT / 2 + text.CharacterSize); window.Draw(text); // Debug enemy spawning text text.DisplayedString = $"{StringTable.GetInstance().GetValue(CurrentLanguage, "ID_CONTROL_DEBUG")}"; text.Position = new Vector2f(Game.GAME_WIDTH / 2 - (text.DisplayedString.Length * text.CharacterSize) / 2, GAME_HEIGHT / 2 + text.CharacterSize * 2 + 5); window.Draw(text); // How to use bomb text text.DisplayedString = $"{StringTable.GetInstance().GetValue(CurrentLanguage, "ID_CONTROL_BOMB")}"; text.Position = new Vector2f(Game.GAME_WIDTH / 2 - (text.DisplayedString.Length * text.CharacterSize) / 2, GAME_HEIGHT / 2 + text.CharacterSize * 3 + 10); window.Draw(text); text.CharacterSize = 25; } // Temps total float timeElapsed = Stopwatch.ElapsedMilliseconds; timeElapsed /= 1000; timeElapsed = (float)Math.Round(timeElapsed, 2); text.DisplayedString = string.Format("{1} = {0,-5}", timeElapsed, StringTable.GetInstance().GetValue(CurrentLanguage, "ID_TOTAL_TIME")); text.Position = new Vector2f(0, GAME_HEIGHT + 5); window.Draw(text); // Points de vie text.DisplayedString = string.Format("{1} = {0,-4}", hero.life, StringTable.GetInstance().GetValue(CurrentLanguage, "ID_LIFE")); text.Position = new Vector2f(GAME_WIDTH - text.DisplayedString.Length * text.CharacterSize, -text.CharacterSize - 5); window.Draw(text); // Number of bombs text.DisplayedString = string.Format("{1} = {0,-4}", hero.nbBombs, StringTable.GetInstance().GetValue(CurrentLanguage, "ID_BOMBS")); text.Position = new Vector2f(Game.GAME_WIDTH / 2 - (text.DisplayedString.Length * text.CharacterSize) / 2, -text.CharacterSize - 5); window.Draw(text); // Score text.DisplayedString = string.Format("{1} = {0,-4}", score.GetScore(), StringTable.GetInstance().GetValue(CurrentLanguage, "ID_SCORE")); text.Position = new Vector2f(0, -text.CharacterSize - 5); window.Draw(text); // FPS framesPerSecond++; if (fps.Elapsed > TimeSpan.FromMilliseconds(1000)) { fpsTemp = framesPerSecond; fps.Restart(); framesPerSecond = 0; } text.Position = new Vector2f(GAME_WIDTH - 250, GAME_HEIGHT + 5); text.DisplayedString = string.Format("{1} = {0,-4}", fpsTemp, "FPS"); window.Draw(text); #endregion }