コード例 #1
0
        /// <summary>
        /// 計測を停止します。既存の計測は記録されます
        /// </summary>
        public void Stop()
        {
#if DEBUG
            lock (lockObj)
            {
                if (IsRecording)
                {
                    Stopwatch.Stop();
                    var elapsed = Stopwatch.Elapsed;
                    TotalElapsed += elapsed;

                    if (Records.ContainsKey(CurrentLabel))
                    {
                        Records[CurrentLabel] += elapsed;
                    }
                    else
                    {
                        Records[CurrentLabel] = elapsed;
                    }

                    CurrentLabel = null;
                    Stopwatch.Reset();
                }
            }
#endif
        }
コード例 #2
0
        public static void SaveRecord(IDifficultyBeatmap beatmap, LevelCompletionResults result, bool submissionDisabled = false)
        {
            // We now keep failed records.
            var cleared = result.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared;

            // If submissionDisabled = true, we assume custom gameplay modifiers are applied.
            var param = ModsToParam(result.gameplayModifiers);

            param |= submissionDisabled ? Param.SubmissionDisabled : 0;

            var record = new Record
            {
                Date          = DateTimeOffset.Now.ToUnixTimeMilliseconds(),
                ModifiedScore = result.modifiedScore,
                RawScore      = result.rawScore,
                LastNote      = cleared ? -1 : result.goodCutsCount + result.badCutsCount + result.missedCount,
                Param         = (int)param
            };

            var beatmapCharacteristicName = beatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName;
            var difficulty = $"{beatmap.level.levelID}___{(int)beatmap.difficulty}___{beatmapCharacteristicName}";

            if (!Records.ContainsKey(difficulty))
            {
                Records.Add(difficulty, new List <Record>());
            }
            Records[difficulty].Add(record);

            // Save to a file. We do this synchronously because the overhead is small. (400 ms / 15 MB, 60 ms / 1 MB)
            SaveRecordsToFile();

            Plugin.Log?.Info($"Saved a new record {difficulty} ({result.modifiedScore}).");
        }
コード例 #3
0
 public void Remove(int id)
 {
     if (Records.ContainsKey(id))
     {
         Records.Remove(id);
     }
 }
コード例 #4
0
 public void AddRecord(Record _record)
 {
     if (Records.ContainsKey(_record.Id))
     {
         return;
     }
     Records.Add(_record.Id, _record);
 }
コード例 #5
0
 public Record GetRecord(string _id)
 {
     if (Records.ContainsKey(_id))
     {
         return(Records[_id]);
     }
     return(null);
 }
コード例 #6
0
        void ReadVariables(string[] lines, ref int lineCtr)
        {
            SkipBlankLines(lines, ref lineCtr);

            if (lines[lineCtr].IndexOf("Variable", StringComparison.InvariantCultureIgnoreCase) < 0 ||
                lines[lineCtr].IndexOf("Columns", StringComparison.InvariantCultureIgnoreCase) < 0 ||
                lines[lineCtr].IndexOf("Len", StringComparison.InvariantCultureIgnoreCase) < 0)
            {
                throw new Exception(Messages.MissingVariablesDeclaration);
            }

            lineCtr++;

            while (lineCtr < lines.Length && !String.IsNullOrWhiteSpace(lines[lineCtr]))
            {
                string line         = lines[lineCtr];
                int    nonSpacePos  = line.TakeWhile(c => char.IsWhiteSpace(c)).Count();
                int    spacePos     = line.Substring(nonSpacePos + 1).TakeWhile(c => !char.IsWhiteSpace(c)).Count();
                string variableName = line.Substring(nonSpacePos, spacePos + 1);

                line        = line.Substring(nonSpacePos + spacePos + 1);
                nonSpacePos = line.TakeWhile(c => char.IsWhiteSpace(c)).Count();
                spacePos    = line.Substring(nonSpacePos + 1).TakeWhile(c => !char.IsWhiteSpace(c)).Count();
                string recordType = line.Substring(nonSpacePos, spacePos + 1);

                line        = line.Substring(nonSpacePos + spacePos + 1);
                nonSpacePos = line.TakeWhile(c => char.IsWhiteSpace(c)).Count();
                spacePos    = line.Substring(nonSpacePos + 1).TakeWhile(c => !char.IsWhiteSpace(c)).Count();
                string columns = line.Substring(nonSpacePos, spacePos + 1);

                line        = line.Substring(nonSpacePos + spacePos + 1);
                nonSpacePos = line.TakeWhile(c => char.IsWhiteSpace(c)).Count();
                spacePos    = line.Substring(nonSpacePos + 1).TakeWhile(c => !char.IsWhiteSpace(c)).Count();
                string len = line.Substring(nonSpacePos, spacePos + 1);

                // ignore the second value of the columns string
                int dashPos = columns.IndexOf("-");

                if (dashPos > 0)
                {
                    columns = columns.Substring(0, dashPos);
                }

                Variable variable = new Variable();
                variable.Name          = variableName;
                variable.StartPosition = Int32.Parse(columns, CultureInfo.InvariantCulture);
                variable.Length        = Int32.Parse(len, CultureInfo.InvariantCulture);

                if (!Records.ContainsKey(recordType))
                {
                    Records.Add(recordType, new List <Variable>());
                }

                Records[recordType].Add(variable);

                lineCtr++;
            }
        }
コード例 #7
0
 private void SetField(int lineNo, int index, string value)
 {
     if (!Records.ContainsKey(lineNo))
     {
         Records.Add(lineNo, new List <string>());
     }
     if (Records[lineNo].Count <= index)
     {
         Records[lineNo].AddRange(Enumerable.Repeat(
                                      string.Empty, index - Records[lineNo].Count + 1));
     }
     Records[lineNo][index] = value;
 }
コード例 #8
0
        private void ShowAnswers()
        {
            Answer1.BackColor = Color.Turquoise;
            Answer2.BackColor = Color.Turquoise;
            Answer3.BackColor = Color.Turquoise;
            Answer4.BackColor = Color.Turquoise;

            ResetButton.Focus();

            TotalGames++;
            TimePlayed += TimeSpan.FromSeconds(Timer.GetCurrentSecondsElapsed());

            GameInProgress = false;
            contextMenuStrip1.Items[0].Text = "Total Games Played: " + TotalGames;
            contextMenuStrip1.Items[1].Text = "Total Time Played: " + TimePlayed;
            contextMenuStrip1.Items[2].Text = "Average: " + TimePlayed.TotalSeconds / TotalGames;

            double secondsPlayed = (TimePlayed - LastTimePlayed).TotalSeconds;

            LastTimePlayed = TimePlayed;

            TimeLabel.Text    = "Time: " + secondsPlayed.ToString("F2");
            TimeLabel.Visible = true;

            AverageLabel.Text    = "Avg: " + (TimePlayed.TotalSeconds / TotalGames).ToString("F2");
            AverageLabel.Visible = true;

            var answersKey = GetAnswersAsInt(Game.Answers);

            if (!Records.ContainsKey(answersKey))
            {
                Records.Add(answersKey, new GameRecord(new List <double>()
                {
                    secondsPlayed
                }));
            }
            else
            {
                FastLabel.Text = "Fast: " + Records[answersKey].Fastest.ToString("F2");
                SlowLabel.Text = "Slow: " + Records[answersKey].Slowest.ToString("F2");

                FastLabel.Visible = true;
                if (Records[answersKey].Fastest != Records[answersKey].Slowest)
                {
                    SlowLabel.Visible = true;
                }

                Records[answersKey].AddTime(secondsPlayed);
            }
        }
コード例 #9
0
 public void Add(int id, int count = 1)
 {
     if (!Records.ContainsKey(id))
     {
         Records.Add(id, count);
     }
     else
     {
         Records[id] += count;
     }
     if (Records[id] < 0)
     {
         Records[id] = 0;
     }
 }
コード例 #10
0
 public int this[int prodId]
 {
     get
     {
         return(Records.ContainsKey(prodId) ? Records[prodId] : 0);
     }
     set
     {
         if (Contains(prodId))
         {
             Records[prodId] = value;
         }
         else
         {
             Records.Add(prodId, value);
         }
     }
 }
コード例 #11
0
ファイル: World.cs プロジェクト: ModernMAK/UniVox
 public bool ContainsKey(int3 key)
 {
     return(Records.ContainsKey(key));
 }
コード例 #12
0
 public bool Contains(int prodId)
 {
     return(Records.ContainsKey(prodId));
 }
コード例 #13
0
 /// <summary>
 /// Searches for audio with name.
 /// </summary>
 /// <param name="audioKey">Audio name.</param>
 /// <returns>Is audio was found.</returns>
 public bool ContainAudio(string audioKey)
 {
     return(Records.ContainsKey(audioKey));
 }