/tags/Soutenance_finale/Structure/Structures/Stats.cs
C# | 315 lines | 205 code | 38 blank | 72 comment | 24 complexity | f8ee6f5a76ad090a742c927fc5e1e160 MD5 | raw file
Possible License(s): GPL-3.0
- using System;
- using System.Collections.Generic;
- using System.Text;
-
- namespace Kore.Structures
- {
- #region struct StatsTower
- /// <summary>
- /// Contient les statistiques liée ŕ une tourelle.
- /// </summary>
- public struct StatsTower
- {
- #region Attributs
- private int soldedcount;
- private int killedcount;
- private int buildedcount;
- private Structures.TowerType type;
- #endregion
-
- #region Constructeur
- public StatsTower (Structures.TowerType t)
- {
- this.soldedcount = 0;
- this.killedcount = 0;
- this.buildedcount = 0;
- this.type = t;
- }
- #endregion
-
- #region Accesseurs
- /// <summary>
- /// Nombre de tours qui ont été vendues
- /// </summary>
- public int SoldCount
- {
- get
- {
- return this.soldedcount;
- }
- set
- {
- this.soldedcount = value;
- }
- }
-
- /// <summary>
- /// Nombre de tours qui ont été malencontreusement supprimmées
- /// </summary>
- public int KillCount
- {
- get
- {
- return this.killedcount;
- }
- set
- {
- this.killedcount = value;
- }
- }
-
- /// <summary>
- /// Nombre de tours construite
- /// </summary>
- public int BuildedCount
- {
- get
- {
- return this.buildedcount;
- }
- set
- {
- this.buildedcount = value;
- }
- }
-
- /// <summary>
- /// Le type de la tour concernée.
- /// </summary>
- public Structures.TowerType Type
- {
- get
- {
- return this.type;
- }
- }
- #endregion
- }
- #endregion
-
- #region struct StatsMonster
- /// <summary>
- /// Contient les statistiques pour un type de monstre.
- /// </summary>
- public struct StatsMonster
- {
- #region Attributs
- private int lifeCount;
- private int hammerKill;
- private Structures.MonsterType type;
- #endregion
-
- #region Constructeurs
- //Constructeurs
- public StatsMonster(Structures.MonsterType t)
- {
- this.lifeCount = 0;
- this.hammerKill = 0;
- this.type = t;
- }
- #endregion
-
- #region Accesseurs
- //Accesseurs
- /// <summary>
- /// Nombre de vies perdus ŕ cause de cette espčce de Kor.
- /// </summary>
- public int LifeCount
- {
- get
- {
- return this.lifeCount;
- }
- set
- {
- this.lifeCount = value;
- }
- }
-
- /// <summary>
- /// Nombre de monstres tué au mateau
- /// </summary>
- public int HammerKill
- {
- get
- {
- return this.hammerKill;
- }
- set
- {
- this.hammerKill = value;
- }
- }
-
- /// <summary>
- /// Lespčce du Kor concerné.
- /// </summary>
- public Structures.MonsterType Type
- {
- get
- {
- return this.type;
- }
- }
- #endregion
- }
- #endregion
-
- #region class Stats
- /// <summary>
- /// Gčre les stats liées ŕ la partie en cours.
- /// </summary>
- public class Stats
- {
- #region Propriétés
- /// <summary>
- /// Temps de jeu
- /// </summary>
- public int TpsDeJeu { get; set; }
-
- /// <summary>
- /// Nombre de monstres tués au total.
- /// </summary>
- public int MonstersKilled { get; set; }
- public int HammerKill { get; set; }
- /// <summary>
- /// Nombre de monstres parti !
- /// </summary>
- public int MonstersStarted { get; set; }
-
- /// <summary>
- /// Argent total dépensé.
- /// </summary>
- public int MoneySpent { get; set; }
-
- /// <summary>
- /// Bénéfices uniquement
- /// </summary>
- public int MoneyWon { get; set; }
-
- /// <summary>
- /// Tours construites
- /// </summary>
- public int TowerBuilded { get; set; }
-
- /// <summary>
- /// Tours détruites
- /// </summary>
- public int TowerSpended { get; set; }
-
- /// <summary>
- /// Cheats activés
- /// </summary>
- public bool Cheats { get; set; }
-
- /// <summary>
- /// Tableau contenant les statistiques pour chaque tour.
- /// </summary>
- public Dictionary<Kore.Structures.TowerType, Structures.StatsTower> StatsTower;
-
- /// <summary>
- /// Tableau contenant les statistiques pour chaque monstre.
- /// </summary>
- public Dictionary<Kore.Structures.MonsterType, Structures.StatsMonster> StatsMonster;
- #endregion
-
- #region Constructeur
- //Constructeurs
-
- /// <summary>
- /// Initialise toutes les stats.
- /// </summary>
- public Stats()
- {
- this.TpsDeJeu = 0;
- this.MonstersKilled = 0;
- this.HammerKill = 0;
- this.MonstersStarted = 0;
- this.MoneySpent = 0;
- this.MoneyWon = 0;
- this.TowerBuilded = 0;
- this.TowerSpended = 0;
- this.Cheats = false;
-
- this.StatsTower = new Dictionary<Kore.Structures.TowerType, Structures.StatsTower>()
- {
- { Structures.TowerType.Normal, new Structures.StatsTower() },
- { Structures.TowerType.Faster, new Structures.StatsTower() },
- { Structures.TowerType.Stronger, new Structures.StatsTower() },
- { Structures.TowerType.Glu, new Structures.StatsTower() },
- { Structures.TowerType.Poison, new Structures.StatsTower() },
- { Structures.TowerType.Power, new Structures.StatsTower() },
- { Structures.TowerType.Bumper, new Structures.StatsTower() }
- };
-
- this.StatsMonster = new Dictionary<Kore.Structures.MonsterType, Structures.StatsMonster>()
- {
- { Structures.MonsterType.Normal, new Structures.StatsMonster() },
- { Structures.MonsterType.Bandit, new Structures.StatsMonster() },
- { Structures.MonsterType.Kask, new Structures.StatsMonster() },
- { Structures.MonsterType.Ghost, new Structures.StatsMonster() }
- };
- }
- #endregion
-
- #region Méthodes
- /// <summary>
- /// Méthode qui exporte les stats actuelles vers le profile
- /// </summary>
- public void exportToProfile(int skors, bool gagne, bool multi, bool carteDeLaCampagne)
- {
- Kore.Datas.profil.TpsJoue += (uint)TpsDeJeu;
-
- if (multi)
- Kore.Datas.profil.PartyMulti++;
- if (gagne)
- Kore.Datas.profil.PartyWin++;
- else
- Kore.Datas.profil.PartyLost++;
-
- if (carteDeLaCampagne)
- {
- Kore.Datas.profil.Experience += skors;
-
- if (this.TowerBuilded > Kore.Datas.profil.MaxTowerBuilded)
- Kore.Datas.profil.MaxTowerBuilded = (uint)this.TowerBuilded;
-
- //On donne des achievements !
- if (!this.Cheats)
- {
- Kore.Datas.profil.MonsterKill += (uint)this.MonstersKilled;
-
- //Traitement sur les monstres
- //foreach (KeyValuePair<Kore.Structures.MonsterType, Structures.StatsMonster> m in this.StatsMonster)
-
-
- Kore.Datas.profil.MonsterKillHammer += (uint)this.HammerKill;
-
- if (Kore.Datas.profil.MonsterKill > 500 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.DebutEclatant))
- Kore.Datas.profil.Recompenses.Add(Achievements.DebutEclatant, DateTime.Now);
- if (Kore.Datas.profil.MonsterKill > 5000 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.EncoreUnEffort))
- Kore.Datas.profil.Recompenses.Add(Achievements.EncoreUnEffort, DateTime.Now);
- if (Kore.Datas.profil.MonsterKill > 50000 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.Eradikation))
- Kore.Datas.profil.Recompenses.Add(Achievements.Eradikation, DateTime.Now);
-
- if (Kore.Datas.profil.MonsterKillHammer > 500 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.Explosifs))
- Kore.Datas.profil.Recompenses.Add(Achievements.Explosifs, DateTime.Now);
-
- if (carteDeLaCampagne && this.TowerSpended == 0 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.NoDestruction))
- Kore.Datas.profil.Recompenses.Add(Achievements.NoDestruction, DateTime.Now);
- if (carteDeLaCampagne && this.StatsTower[Kore.Structures.TowerType.Faster].BuildedCount >= 0 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.NoDestruction))
- Kore.Datas.profil.Recompenses.Add(Achievements.NoDestruction, DateTime.Now);
-
- if (this.TowerBuilded >= 100 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.UnionForce))
- Kore.Datas.profil.Recompenses.Add(Achievements.UnionForce, DateTime.Now);
- }
- }
- if (Kore.Datas.profil.TpsJoue >= 151200 && !Kore.Datas.profil.Recompenses.ContainsKey(Achievements.SensDeLavie))
- Kore.Datas.profil.Recompenses.Add(Achievements.NoDestruction, DateTime.Now);
-
-
- }
- #endregion
- }
- #endregion
- }