Exemplo n.º 1
0
        public static LevelAnalysis Analyse(int levelID, Progress[] users)
        {
            var analysis = new LevelAnalysis(levelID);

            var playtimes = new List <float>();

            foreach (var user in users)
            {
                if (user.IsLevelCompleted(levelID))
                {
                    playtimes.Add(user.GetPlaytime(levelID));
                }
            }

            if (playtimes.Count > 0)
            {
                playtimes.Sort();
                analysis.PercentCompleted = ((float)playtimes.Count / (float)users.Length) * 100.0f;
                analysis.MinPlaytime      = playtimes[0];
                analysis.MaxPlaytime      = playtimes[playtimes.Count - 1];
                analysis.MedianPlaytime   = playtimes[playtimes.Count / 2];
            }

            return(analysis);
        }
Exemplo n.º 2
0
        public static CampaignAnalysis Analyse(Campaign campaign, Progress[] users)
        {
            var results = new List <LevelAnalysis>();

            for (int i = 0; i < campaign.Levels.Count; ++i)
            {
                var levelPath = campaign.Levels[i];
                var levelData = LevelData.Get(levelPath);
                var id        = levelData.ID;
                results.Add(LevelAnalysis.Analyse(id, users));
            }
            return(new CampaignAnalysis(campaign.ID, results.ToArray()));
        }