Pimeko

Untitled

Apr 6th, 2014
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.37 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.Xna.Framework.Content;
  6. using Microsoft.Xna.Framework;
  7. using Microsoft.Xna.Framework.Input;
  8. using Microsoft.Xna.Framework.Graphics;
  9.  
  10. namespace Projet
  11. {
  12.     class ScoreManager
  13.     {
  14.         private static float comboDuration = 5f, comboTimer;
  15.  
  16.         public static string CalculateTimeSpent(float secondSpent)
  17.         {
  18.             int seconds = (int)secondSpent;
  19.             string timeSpent = seconds / 60 + " '' " + seconds % 60;
  20.             return timeSpent;
  21.         }
  22.  
  23.         public static int ScoreToStars(int score)
  24.         {
  25.             int nbIAs = LevelLoader.iaList.Count;
  26.             int bestScore = 0;
  27.  
  28.             if (nbIAs > 0)
  29.             {
  30.                 if (nbIAs <= 5)
  31.                     for (int i = 1; i <= nbIAs; i++) bestScore += 100 * i;
  32.  
  33.                 else
  34.                     bestScore = 500 * (nbIAs - 2);
  35.  
  36.                 if (score < bestScore / 6)
  37.                     return 0;
  38.                 else if (score < 2 * bestScore / 6)
  39.                     return 1;
  40.                 else if (score < 3 * bestScore / 6)
  41.                     return 2;
  42.                 else if (score < 4 * bestScore / 6)
  43.                     return 3;
  44.                 else if (score < 5 * bestScore / 6)
  45.                     return 4;
  46.                 else if (score <= bestScore)
  47.                     return 5;
  48.                 else
  49.                     return 0;
  50.             }
  51.             else
  52.             {
  53.                 return 5;
  54.             }
  55.         }
  56.  
  57.         public static void RestartComboTimer()
  58.         {
  59.             comboTimer = 0f;
  60.         }
  61.  
  62.         public static void UpdateComboTimer(GameTime gameTime)
  63.         {
  64.             if (comboTimer > comboDuration)
  65.             {
  66.                 Level.combo = -1;
  67.                 comboTimer = 0f;
  68.             }
  69.             else
  70.                 comboTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
  71.         }
  72.  
  73.         public static void UpdateCombo()
  74.         {
  75.             if (comboTimer < comboDuration)
  76.             {
  77.                 if (Level.combo > 0)
  78.                     Level.score += 100 + Level.combo * 100;
  79.  
  80.                 if (Level.combo < 4)
  81.                     Level.combo++;
  82.             }
  83.             else
  84.                 Level.combo = -1;
  85.         }
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment