PageRenderTime 87ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/Soutenance_finale/Structure/Structures/Stats.cs

http://xe8tmw7c.googlecode.com/
C# | 315 lines | 205 code | 38 blank | 72 comment | 24 complexity | f8ee6f5a76ad090a742c927fc5e1e160 MD5 | raw file
Possible License(s): GPL-3.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Kore.Structures
  5. {
  6. #region struct StatsTower
  7. /// <summary>
  8. /// Contient les statistiques liée ŕ une tourelle.
  9. /// </summary>
  10. public struct StatsTower
  11. {
  12. #region Attributs
  13. private int soldedcount;
  14. private int killedcount;
  15. private int buildedcount;
  16. private Structures.TowerType type;
  17. #endregion
  18. #region Constructeur
  19. public StatsTower (Structures.TowerType t)
  20. {
  21. this.soldedcount = 0;
  22. this.killedcount = 0;
  23. this.buildedcount = 0;
  24. this.type = t;
  25. }
  26. #endregion
  27. #region Accesseurs
  28. /// <summary>
  29. /// Nombre de tours qui ont été vendues
  30. /// </summary>
  31. public int SoldCount
  32. {
  33. get
  34. {
  35. return this.soldedcount;
  36. }
  37. set
  38. {
  39. this.soldedcount = value;
  40. }
  41. }
  42. /// <summary>
  43. /// Nombre de tours qui ont été malencontreusement supprimmées
  44. /// </summary>
  45. public int KillCount
  46. {
  47. get
  48. {
  49. return this.killedcount;
  50. }
  51. set
  52. {
  53. this.killedcount = value;
  54. }
  55. }
  56. /// <summary>
  57. /// Nombre de tours construite
  58. /// </summary>
  59. public int BuildedCount
  60. {
  61. get
  62. {
  63. return this.buildedcount;
  64. }
  65. set
  66. {
  67. this.buildedcount = value;
  68. }
  69. }
  70. /// <summary>
  71. /// Le type de la tour concernée.
  72. /// </summary>
  73. public Structures.TowerType Type
  74. {
  75. get
  76. {
  77. return this.type;
  78. }
  79. }
  80. #endregion
  81. }
  82. #endregion
  83. #region struct StatsMonster
  84. /// <summary>
  85. /// Contient les statistiques pour un type de monstre.
  86. /// </summary>
  87. public struct StatsMonster
  88. {
  89. #region Attributs
  90. private int lifeCount;
  91. private int hammerKill;
  92. private Structures.MonsterType type;
  93. #endregion
  94. #region Constructeurs
  95. //Constructeurs
  96. public StatsMonster(Structures.MonsterType t)
  97. {
  98. this.lifeCount = 0;
  99. this.hammerKill = 0;
  100. this.type = t;
  101. }
  102. #endregion
  103. #region Accesseurs
  104. //Accesseurs
  105. /// <summary>
  106. /// Nombre de vies perdus ŕ cause de cette espčce de Kor.
  107. /// </summary>
  108. public int LifeCount
  109. {
  110. get
  111. {
  112. return this.lifeCount;
  113. }
  114. set
  115. {
  116. this.lifeCount = value;
  117. }
  118. }
  119. /// <summary>
  120. /// Nombre de monstres tué au mateau
  121. /// </summary>
  122. public int HammerKill
  123. {
  124. get
  125. {
  126. return this.hammerKill;
  127. }
  128. set
  129. {
  130. this.hammerKill = value;
  131. }
  132. }
  133. /// <summary>
  134. /// L’espčce du Kor concerné.
  135. /// </summary>
  136. public Structures.MonsterType Type
  137. {
  138. get
  139. {
  140. return this.type;
  141. }
  142. }
  143. #endregion
  144. }
  145. #endregion
  146. #region class Stats
  147. /// <summary>
  148. /// Gčre les stats liées ŕ la partie en cours.
  149. /// </summary>
  150. public class Stats
  151. {
  152. #region Propriétés
  153. /// <summary>
  154. /// Temps de jeu
  155. /// </summary>
  156. public int TpsDeJeu { get; set; }
  157. /// <summary>
  158. /// Nombre de monstres tués au total.
  159. /// </summary>
  160. public int MonstersKilled { get; set; }
  161. public int HammerKill { get; set; }
  162. /// <summary>
  163. /// Nombre de monstres parti !
  164. /// </summary>
  165. public int MonstersStarted { get; set; }
  166. /// <summary>
  167. /// Argent total dépensé.
  168. /// </summary>
  169. public int MoneySpent { get; set; }
  170. /// <summary>
  171. /// Bénéfices uniquement
  172. /// </summary>
  173. public int MoneyWon { get; set; }
  174. /// <summary>
  175. /// Tours construites
  176. /// </summary>
  177. public int TowerBuilded { get; set; }
  178. /// <summary>
  179. /// Tours détruites
  180. /// </summary>
  181. public int TowerSpended { get; set; }
  182. /// <summary>
  183. /// Cheats activés
  184. /// </summary>
  185. public bool Cheats { get; set; }
  186. /// <summary>
  187. /// Tableau contenant les statistiques pour chaque tour.
  188. /// </summary>
  189. public Dictionary<Kore.Structures.TowerType, Structures.StatsTower> StatsTower;
  190. /// <summary>
  191. /// Tableau contenant les statistiques pour chaque monstre.
  192. /// </summary>
  193. public Dictionary<Kore.Structures.MonsterType, Structures.StatsMonster> StatsMonster;
  194. #endregion
  195. #region Constructeur
  196. //Constructeurs
  197. /// <summary>
  198. /// Initialise toutes les stats.
  199. /// </summary>
  200. public Stats()
  201. {
  202. this.TpsDeJeu = 0;
  203. this.MonstersKilled = 0;
  204. this.HammerKill = 0;
  205. this.MonstersStarted = 0;
  206. this.MoneySpent = 0;
  207. this.MoneyWon = 0;
  208. this.TowerBuilded = 0;
  209. this.TowerSpended = 0;
  210. this.Cheats = false;
  211. this.StatsTower = new Dictionary<Kore.Structures.TowerType, Structures.StatsTower>()
  212. {
  213. { Structures.TowerType.Normal, new Structures.StatsTower() },
  214. { Structures.TowerType.Faster, new Structures.StatsTower() },
  215. { Structures.TowerType.Stronger, new Structures.StatsTower() },
  216. { Structures.TowerType.Glu, new Structures.StatsTower() },
  217. { Structures.TowerType.Poison, new Structures.StatsTower() },
  218. { Structures.TowerType.Power, new Structures.StatsTower() },
  219. { Structures.TowerType.Bumper, new Structures.StatsTower() }
  220. };
  221. this.StatsMonster = new Dictionary<Kore.Structures.MonsterType, Structures.StatsMonster>()
  222. {
  223. { Structures.MonsterType.Normal, new Structures.StatsMonster() },
  224. { Structures.MonsterType.Bandit, new Structures.StatsMonster() },
  225. { Structures.MonsterType.Kask, new Structures.StatsMonster() },
  226. { Structures.MonsterType.Ghost, new Structures.StatsMonster() }
  227. };
  228. }
  229. #endregion
  230. #region Méthodes
  231. /// <summary>
  232. /// Méthode qui exporte les stats actuelles vers le profile
  233. /// </summary>
  234. public void exportToProfile(int skors, bool gagne, bool multi, bool carteDeLaCampagne)
  235. {
  236. Kore.Datas.profil.TpsJoue += (uint)TpsDeJeu;
  237. if (multi)
  238. Kore.Datas.profil.PartyMulti++;
  239. if (gagne)
  240. Kore.Datas.profil.PartyWin++;
  241. else
  242. Kore.Datas.profil.PartyLost++;
  243. if (carteDeLaCampagne)
  244. {
  245. Kore.Datas.profil.Experience += skors;
  246. if (this.TowerBuilded > Kore.Datas.profil.MaxTowerBuilded)
  247. Kore.Datas.profil.MaxTowerBuilded = (uint)this.TowerBuilded;
  248. //On donne des achievements !
  249. if (!this.Cheats)
  250. {
  251. Kore.Datas.profil.MonsterKill += (uint)this.MonstersKilled;
  252. //Traitement sur les monstres
  253. //foreach (KeyValuePair<Kore.Structures.MonsterType, Structures.StatsMonster> m in this.StatsMonster)
  254. Kore.Datas.profil.MonsterKillHammer += (uint)this.HammerKill;
  255. if (Kore.Datas.profil.MonsterKill > 500 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.DebutEclatant))
  256. Kore.Datas.profil.Recompenses.Add(Achievements.DebutEclatant, DateTime.Now);
  257. if (Kore.Datas.profil.MonsterKill > 5000 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.EncoreUnEffort))
  258. Kore.Datas.profil.Recompenses.Add(Achievements.EncoreUnEffort, DateTime.Now);
  259. if (Kore.Datas.profil.MonsterKill > 50000 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.Eradikation))
  260. Kore.Datas.profil.Recompenses.Add(Achievements.Eradikation, DateTime.Now);
  261. if (Kore.Datas.profil.MonsterKillHammer > 500 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.Explosifs))
  262. Kore.Datas.profil.Recompenses.Add(Achievements.Explosifs, DateTime.Now);
  263. if (carteDeLaCampagne && this.TowerSpended == 0 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.NoDestruction))
  264. Kore.Datas.profil.Recompenses.Add(Achievements.NoDestruction, DateTime.Now);
  265. if (carteDeLaCampagne && this.StatsTower[Kore.Structures.TowerType.Faster].BuildedCount >= 0 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.NoDestruction))
  266. Kore.Datas.profil.Recompenses.Add(Achievements.NoDestruction, DateTime.Now);
  267. if (this.TowerBuilded >= 100 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.UnionForce))
  268. Kore.Datas.profil.Recompenses.Add(Achievements.UnionForce, DateTime.Now);
  269. }
  270. }
  271. if (Kore.Datas.profil.TpsJoue >= 151200 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.SensDeLavie))
  272. Kore.Datas.profil.Recompenses.Add(Achievements.NoDestruction, DateTime.Now);
  273. }
  274. #endregion
  275. }
  276. #endregion
  277. }