better plan stats
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules;
|
||||
using EscapeRoomEngine.Engine.Runtime.UI;
|
||||
using EscapeRoomEngine.Engine.Runtime.Utilities;
|
||||
using UnityEngine;
|
||||
using Logger = EscapeRoomEngine.Engine.Runtime.Utilities.Logger;
|
||||
@@ -65,6 +66,12 @@ namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
||||
{
|
||||
_currentSession = new Session();
|
||||
|
||||
// add a first plan result with the initial target and estimated times
|
||||
_currentSession.PlanResults.Add(new PlanResult(
|
||||
GameControl.Instance.TargetTime,
|
||||
.5f,
|
||||
GameControl.Instance.EstimatedTime));
|
||||
|
||||
Logger.Log($"Started {_currentSession}", LogType.Measuring);
|
||||
}
|
||||
|
||||
|
||||
21
Assets/Engine/Runtime/Measurements/PlanResult.cs
Normal file
21
Assets/Engine/Runtime/Measurements/PlanResult.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using JetBrains.Annotations;
|
||||
using Realms;
|
||||
|
||||
namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
||||
{
|
||||
public class PlanResult : EmbeddedObject
|
||||
{
|
||||
public float TargetTime { get; set; }
|
||||
public float SectionPercentile { get; set; }
|
||||
public float TimeEstimation { get; set; }
|
||||
|
||||
[UsedImplicitly]
|
||||
public PlanResult() {}
|
||||
public PlanResult(float targetTime, float sectionPercentile, float timeEstimation)
|
||||
{
|
||||
TargetTime = targetTime;
|
||||
SectionPercentile = sectionPercentile;
|
||||
TimeEstimation = timeEstimation;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Engine/Runtime/Measurements/PlanResult.cs.meta
Normal file
3
Assets/Engine/Runtime/Measurements/PlanResult.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72a6c9ba31594039aacf6da8f566f885
|
||||
timeCreated: 1671175940
|
||||
@@ -1,4 +1,5 @@
|
||||
using EscapeRoomEngine.Engine.Runtime.Modules;
|
||||
using EscapeRoomEngine.Engine.Runtime.UI;
|
||||
using Realms;
|
||||
using UnityEngine;
|
||||
using Logger = EscapeRoomEngine.Engine.Runtime.Utilities.Logger;
|
||||
@@ -8,7 +9,7 @@ namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
||||
{
|
||||
public class PuzzleStorage : MonoBehaviour
|
||||
{
|
||||
private const int SchemaVersion = 1;
|
||||
private const int SchemaVersion = 2;
|
||||
|
||||
public static PuzzleStorage Instance { get; private set; }
|
||||
|
||||
@@ -27,6 +28,12 @@ namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
||||
if (oldSchemaVersion < 1)
|
||||
{
|
||||
// migration from version 0 to 1
|
||||
// nothing to do
|
||||
}
|
||||
if (oldSchemaVersion < 2)
|
||||
{
|
||||
// migration from version 1 to 2
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
Logger.Log($"Migrated database to version {SchemaVersion}", LogType.Measuring);
|
||||
@@ -97,8 +104,11 @@ namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
||||
// add solved puzzle to session
|
||||
session.PuzzlesSolved.Add(found);
|
||||
|
||||
// add time percentile to session
|
||||
session.Percentiles.Add(found.Distribution.Cumulative(measurement.Time));
|
||||
// add plan result to session
|
||||
session.PlanResults.Add(new PlanResult(
|
||||
GameControl.Instance.TargetTime,
|
||||
found.Distribution.Cumulative(measurement.Time),
|
||||
GameControl.Instance.EstimatedTime));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,11 @@ namespace EscapeRoomEngine.Engine.Runtime.Measurements
|
||||
[PrimaryKey]
|
||||
public ObjectId ID { get; set; }
|
||||
public float Time { get; set; }
|
||||
public IList<float> Percentiles { get; }
|
||||
public IList<PlanResult> PlanResults { get; }
|
||||
public IList<Puzzle> PuzzlesSolved { get; }
|
||||
|
||||
public float MeanPercentile => Percentiles.Count == 0 ? .5f : Probability.Mean(Percentiles.ToArray());
|
||||
public IEnumerable<float> Percentiles => PlanResults.Select(result => result.SectionPercentile);
|
||||
public float MeanPercentile => PlanResults.Count == 0 ? .5f : Probability.Mean(Percentiles.ToArray());
|
||||
|
||||
[UsedImplicitly]
|
||||
public Session()
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace EscapeRoomEngine.Engine.Runtime.UI
|
||||
public float TimeInRoom { get; set; }
|
||||
public float TargetTime { get; private set; }
|
||||
public float EstimatedTimeRoom { get; private set; }
|
||||
public float EstimatedTime { get; private set; }
|
||||
|
||||
private float _previousUIUpdate, _previousPlanUpdate;
|
||||
|
||||
@@ -153,7 +154,9 @@ namespace EscapeRoomEngine.Engine.Runtime.UI
|
||||
{
|
||||
EstimatedTimeRoom =
|
||||
TimeElapsed - TimeInRoom + Mathf.Max(TimeInRoom, Measure.EstimateTime(room));
|
||||
estimateTimeText.text = TimeToText(EstimatedTimeRoom + Engine.Instance.EstimatedTimeRemaining);
|
||||
EstimatedTime = EstimatedTimeRoom + Engine.Instance.EstimatedTimeRemaining;
|
||||
|
||||
estimateTimeText.text = TimeToText(EstimatedTime);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user