void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Debug.LogErrorFormat("Singleton {0} instantiated multiple times, destroy all but first one up", this.GetType().Name); Destroy(this); } this.sm = GameObject.FindWithTag("SessionManager").GetComponent <SessionManager>(); playerShipMenu = transform.Find("PlayerShipMenu").gameObject; retroButton = transform.Find("RetroButton").gameObject; endlessButton = transform.Find("EndlessButton").gameObject; endlessUICanvas.SetActive(false); retroUICanvas.SetActive(false); stats = new SessionStats(); //Stats txt objects maxLvlTxt = mainMenuCanvas.transform.Find("StatsUI/MaxLvLUI/NumText").GetComponent <Text>(); maxLvlTxt.text = "--"; lastLvlTxt = mainMenuCanvas.transform.Find("StatsUI/LastLvLUI/NumText").GetComponent <Text>(); lastLvlTxt.text = "--"; prevCorrectTxt = mainMenuCanvas.transform.Find("StatsUI/Correct%UI/NumText").GetComponent <Text>(); prevCorrectTxt.text = "--"; }
public PlaceDiceBet CalculateNextDiceBet(DiceBet PreviousBet, bool Win) { decimal Lastbet = PreviousBet.TotalAmount; SessionStats Stats = this.Stats; if (Win) { if ((Stats.WinStreak) % (AlembertStretchWin + 1) == 0) { Lastbet += AlembertIncrementWin; } } else { if ((Stats.LossStreak) % (AlembertStretchLoss + 1) == 0) { Lastbet += AlembertIncrementLoss; } } if (Lastbet < MinBet) { Lastbet = MinBet; } return(new PlaceDiceBet(Lastbet, High, PreviousBet.Chance)); }
public override void Extend(SessionStats session) { if (_filter.Test(session)) { base.Extend(session); } }
private static void UpdateCarDrivenDistance(SessionStats current) { if (current.CarId == null) { return; } (CarsManager.Instance.GetWrapperById(current.CarId)?.Value as CarObject)?.RaiseTotalDrivenDistanceChanged(); }
private static void UpdateTrackDrivenDistance(SessionStats current) { if (current.TrackId == null) { return; } (TracksManager.Instance.GetWrappedByIdWithLayout(current.TrackId)?.Value as TrackObject)? .GetLayoutById(current.TrackId)?.RaiseTotalDrivenDistanceChanged(); }
public void StartSession(int level) { Debug.Log("Starting Session"); lvl = level; lastPlayerHealth = PLAYER_START_HEALTH; uiMathTable.Clear(); currentStats = new SessionStats(); StartLevel(true); }
public void EndSession(bool winLoss) { _sessionTimer.Stop(); _sessionStats.Time = _sessionTimer.Elapsed; _sessionStats.Win = winLoss; AddSessionStats(winLoss); SaveToFile(_globalStatsPath, _globalStats); _sessionStats = new SessionStats(); }
private void OnStart(object sender, EventArgs e) { if (_current != null) { Apply(_current); } _current = new WatchingSessionStats(); Last = _current; }
public virtual void Extend([NotNull] SessionStats session) { /* per car/track */ if (Storage == null) { Storage = new Storage(); } UpdateMaxDistancePerCar(session); UpdateMaxDistancePerTrack(session); /* max speed per car */ if (session.MaxSpeed > Storage.GetDouble(KeyMaxSpeedPerCarPrefix + session.CarId)) { Storage.Set(KeyMaxSpeedPerCarPrefix + session.CarId, session.MaxSpeed); } /* extremums */ if (session.MaxSpeed > MaxSpeed) { MaxSpeed = session.MaxSpeed; MaxSpeedCarId = session.CarId; } if (session.LongestAirborne > LongestAirborne) { LongestAirborne = session.LongestAirborne; LongestAirborneCarId = session.CarId; } if (session.LongestWheelie > LongestWheelie) { LongestWheelie = session.LongestWheelie; LongestWheelieCarId = session.CarId; } if (session.LongestTwoWheels > LongestTwoWheels) { LongestTwoWheels = session.LongestTwoWheels; LongestTwoWheelsCarId = session.CarId; } /* summary */ Distance += session.Distance; FuelBurnt += session.FuelBurnt; Time += session.Time; GoneOffroadTimes += session.GoneOffroad; TotalAirborne += session.TotalAirborne; TotalWheelie += session.TotalWheelie; TotalTwoWheels += session.TotalTwoWheels; TotalTyreWear += session.TotalTyreWear; TotalCrashes += session.TotalCrashes; SessionsCount++; }
private void AppendSession(SessionStats current) { if (IsSessionsStorageReady) { GetSessionsStorage().Add(new SessionsStatsEntry(current)); } using (var writer = File.AppendText(_sessionsFilename)) { writer.WriteLine(current.Serialize()); } }
public void DisplaySessionStats(float Session) { DisplayStats = StatsManager.sessionKeeper.Sessions[(int)Session]; WinOrLoss.text = DisplayStats.WinOrLoss.ToString(); SessionDate.text = DisplayStats.SessionDate; HighestLevel.text = DisplayStats.HighestLevel.ToString(); MobsKilled.text = DisplayStats.MobsKilled.ToString(); ExperienceGained.text = DisplayStats.ExperienceGained.ToString(); WavesCompleted.text = DisplayStats.WavesCompleted.ToString(); }
private void ExtendOveralls(SessionStats current) { var storage = GetMainStorage(); Overall.Extend(current); storage.SetObject(KeyOverall, Overall); foreach (var holded in _holdedList) { holded.Extend(current); } }
private static void UpdateCarDrivenDistanceAndMaxSpeed(SessionStats current) { var car = current.CarId == null ? null : CarsManager.Instance.GetWrapperById(current.CarId)?.Value as CarObject; if (car == null) { return; } car.RaiseMaxSpeedAchievedChanged(); car.RaiseTotalDrivenDistanceChanged(); }
static async Task WriteSessionStats(string sessionPath, SessionStats stats) { try { await File.WriteAllTextAsync( Path.Combine(sessionPath, "session.txt"), JsonConvert.SerializeObject(stats)); } catch (Exception ex) { Console.WriteLine($"Error writing to session info: {ex.Message}"); } }
public void UpdateStats(SessionStats inStats) { if (inStats.maxlvl > stats.maxlvl) { stats.maxlvl = inStats.maxlvl; maxLvlTxt.text = stats.maxlvl.ToString(); } //Now get last percentage stats.lvlCorrect = inStats.lvlCorrect; stats.lvlWrong = inStats.lvlWrong; prevCorrectTxt.text = ((int)(stats.GetWinPct() * 100f)).ToString(); //And last lvl lastLvlTxt.text = inStats.maxlvl.ToString(); }
public MyVersusMatchResults(Session session, VersusRoundResults roundResults) : base(session, roundResults) { Vector2[] vectorArray; Vector2[] vectorArray2; this.session = session; this.roundResults = roundResults; base.Position = new Vector2(0f, 240f); if (TFGame.PlayerAmount == 2) { vectorArray = new Vector2[] { new Vector2(-160f, 120f), new Vector2(480f, 120f) }; vectorArray2 = new Vector2[] { new Vector2(110f, 120f), new Vector2(210f, 120f) }; } else if (TFGame.PlayerAmount == 3) { vectorArray = new Vector2[] { new Vector2(-160f, 120f), new Vector2(160f, 360f), new Vector2(480f, 120f) }; vectorArray2 = new Vector2[] { new Vector2(80f, 120f), new Vector2(160f, 120f), new Vector2(240f, 120f) }; } else { vectorArray = new Vector2[] { new Vector2(-320f, 120f), new Vector2(-280f, 120f), new Vector2(-240f, 120f), new Vector2(-200f, 120f), new Vector2(-160f, 120f), new Vector2(-120f, 120f), new Vector2(-80f, 120f), new Vector2(-40f, 120f) }; vectorArray2 = new Vector2[] { new Vector2(20f, 120f), new Vector2(60f, 120f), new Vector2(100f, 120f), new Vector2(140f, 120f), new Vector2(180f, 120f), new Vector2(220f, 120f), new Vector2(260f, 120f), new Vector2(300f, 120f) }; } int winner = session.GetWinner(); for (int i = 0; i < 8; i++) { if (TFGame.Players[i] && (winner == session.GetScoreIndex(i))) { session.MatchStats[i].Won = true; SaveData.Instance.Stats.Wins[TFGame.Characters[i]] += (ulong)1L; SessionStats.RegisterArcherWin(i); } else { session.MatchStats[i].Won = false; } } List <AwardInfo>[] awards = VersusAwards.GetAwards(session.MatchSettings, session.MatchStats); SessionStats.RegisterArcherPlays(); playerResults = new List <VersusPlayerMatchResults>(); for (int j = 0; j < 8; j++) { if (TFGame.Players[j]) { var entity = new VersusPlayerMatchResults(session, this, j, vectorArray[playerResults.Count], vectorArray2[playerResults.Count], awards[j]); session.CurrentLevel.Add(entity); playerResults.Add(entity); } } }
private void BroadcastStats() { //Send broadcast stats SessionStats stats = new SessionStats { maxSpeedReached = movementManager.GetMaxSpeedReached(), maxSpeed = movementManager.maxSpeed, timePlayed = properTime, distortedTime = relativeExTime - properTime, score = gameMode.sessionScore, obstaclesHit = sessionObstaclesHit }; PersistentPrefs.GetInstance().CheckAchievements(stats); }
private void UpdateMaxDistancePerTrack([NotNull] SessionStats session) { var drivenDistance = Storage.GetDouble(KeyDistancePerTrackPrefix + session.TrackId) + session.Distance; Storage.Set(KeyDistancePerTrackPrefix + session.TrackId, drivenDistance); if (session.TrackId == MaxDistancePerTrackTrackId) { MaxDistancePerTrack += session.Distance; } else if (drivenDistance > MaxDistancePerTrack) { MaxDistancePerTrack = drivenDistance; MaxDistancePerTrackTrackId = session.TrackId; } }
private void UpdateMaxDistancePerCar([NotNull] SessionStats session) { var drivenDistance = Storage.GetDouble(KeyDistancePerCarPrefix + session.CarId) + session.Distance; Storage.Set(KeyDistancePerCarPrefix + session.CarId, drivenDistance); if (session.CarId == MaxDistancePerCarCarId) { MaxDistancePerCar += session.Distance; } else if (drivenDistance > MaxDistancePerCar) { MaxDistancePerCar = drivenDistance; MaxDistancePerCarCarId = session.CarId; } }
public StatTracker() { m_eventLog = new List<EventLog>(); m_playerCache = new Dictionary<string, Player>(); m_itemCache = new Dictionary<string, string>(); m_currentEvent = new EventLog(); m_player = new Player(); m_sessionStats = new SessionStats(); m_userID = ""; m_sessionStarted = false; m_lastEventFound = false; m_initialized = false; m_initializing = false; m_countEvents = false; m_preparingSession = false; m_activeSeconds = 0; m_currentEvent.Initialize(); }
private void Apply(SessionStats current) { if (current?.CarId == null || current.TrackId == null || current.Time == TimeSpan.Zero) { return; } Logging.Debug($@"Session stats: Penalties: {current.Penalties} Distance: {current.DistanceKm:F1} km Driven time: {current.Time.ToProperString()} Max speed: {current.MaxSpeed:F1} kmh Avg speed: {current.AverageSpeed:F1} kmh Fuel burnt: {current.FuelBurnt:F2}l ({current.FuelConsumption:F2} liters per 100 km) Gone offroad: {current.GoneOffroad} time(s)"); ExtendOveralls(current); AppendSession(current); UpdateCarDrivenDistance(current); UpdateTrackDrivenDistance(current); }
public SessionStatsEventArgs(SessionStats stats) { Stats = stats; }
private void Start() { sessionStats = GameObject.FindWithTag("GameInfo").GetComponent <SessionStats>(); SceneManager.sceneUnloaded += UnloadedScene; StartCoroutine(GameTimer()); }
public void StartSession() { _sessionStats = new SessionStats(); _sessionTimer.Restart(); }
public static SessionStats Deserialize(string data) { try { using (var textReader = new StringReader(data)) { var reader = new JsonTextReader(textReader); var r = new SessionStats(); var currentProperty = string.Empty; reader.MatchNext(JsonToken.StartObject); while (reader.Until(JsonToken.EndObject)) { switch (reader.TokenType) { case JsonToken.PropertyName: currentProperty = reader.Value.ToString(); break; case JsonToken.String: switch (currentProperty) { case nameof(CarId): r.CarId = reader.Value.ToString(); break; case nameof(TrackId): r.TrackId = reader.Value.ToString(); break; case nameof(Time): r.Time = TimeSpan.Parse(reader.Value.ToString()); break; case nameof(BestLap): r.BestLap = TimeSpan.Parse(reader.Value.ToString()); break; default: throw new Exception($"Unknown key: {currentProperty} (String)"); } break; case JsonToken.Date: switch (currentProperty) { case nameof(StartedAt): r.StartedAt = DateTime.Parse(reader.Value.ToString()); break; default: throw new Exception($"Unknown key: {currentProperty} (Date)"); } break; case JsonToken.Float: case JsonToken.Integer: var val = double.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture); switch (currentProperty) { case nameof(MaxSpeed): r.MaxSpeed = val; break; case nameof(Distance): r.Distance = val; break; case nameof(FuelBurnt): r.FuelBurnt = val; break; case nameof(LongestAirborne): r.LongestAirborne = val; break; case nameof(TotalAirborne): r.TotalAirborne = val; break; case nameof(LongestWheelie): r.LongestWheelie = val; break; case nameof(TotalWheelie): r.TotalWheelie = val; break; case nameof(LongestTwoWheels): r.LongestTwoWheels = val; break; case nameof(TotalTwoWheels): r.TotalTwoWheels = val; break; case nameof(TotalTyreWear): r.TotalTyreWear = val; break; case nameof(GoneOffroad): r.GoneOffroad = (int)val; break; case nameof(TotalCrashes): r.TotalCrashes = (int)val; break; case nameof(BestLapId): r.BestLapId = (int?)val; break; default: throw new Exception($"Unknown key: {currentProperty} (Integer/Float)"); } break; case JsonToken.Boolean: switch (currentProperty) { case nameof(Penalties): r.Penalties = bool.Parse(reader.Value.ToString()); break; default: throw new Exception($"Unknown key: {currentProperty} (Boolean)"); } break; default: throw new Exception($"Unexpected token: {reader.TokenType}"); } } return r; } } catch (Exception e) { Logging.Error(e); return JsonConvert.DeserializeObject<SessionStats>(data); } }
private void InitSessions() { StatsManager.SaveFilePath = Path.Combine(Application.persistentDataPath, "saveGame.json"); StatsManager.LoadSessions(); CurrentSession = new SessionStats(); }
/// <summary> /// This is the call back method called by the FaspManager on any event /// </summary> /// <param name="asperaEvent">The event for callback.</param> /// <param name="sessionStats">The Session levels statistics for the Session that triggered this event</param> /// <param name="fileStats">Statistics of the last file transferred in this session</param> public void fileSessionEvent(TransferEvent asperaEvent, SessionStats sessionStats, FileStats fileStats) { Console.WriteLine("Job Name: " + sessionStats.Cookie); Console.WriteLine("\tJob State: " + sessionStats.State); Console.WriteLine("\tTarget Rate: " + sessionStats.TargetRateKbps + "Kbps"); if (sessionStats.ElapsedUSec > 0) Console.WriteLine("\tAvg Actual Rate: " + (sessionStats.TotalTransferredBytes * 8 * 1000 / sessionStats.ElapsedUSec) + "Kbps"); Console.WriteLine("\tSession Downloaded: " + (sessionStats.TotalTransferredBytes / 1000) + "KB"); if (fileStats != null) { Console.WriteLine("\tFileName: " + fileStats.name); Console.WriteLine("\tFile Downloaded: " + (fileStats.writtenBytes / 1000) + "KB"); } Console.Write("\n"); // And stop the fasp manager if (asperaEvent == TransferEvent.SESSION_STOP || asperaEvent == TransferEvent.SESSION_ERROR) { currentFile.IsUploaded = true; currentFile.UploadEndTime = DateTime.Now; try { if (FaspManager.getInstance().getSessionIDList().Count == 1) { //FaspManager.destroy(); MoveFileToArchive(currentFile); } } catch (Exception) { } } if (asperaEvent == TransferEvent.SESSION_ERROR) { Console.WriteLine(sessionStats.ErrorDescription); } }
public void UpdateSessionStats(SessionStats Stats) { Scope.SetVariable("Stats", Stats); }
public void UpdateSessionStats(SessionStats Stats) { Runtime.SetValue("Stats", Stats); Runtime.SetValue("Balance", Balance); }
public SessionsStatsEntry([NotNull] SessionStats data) { _parsedData = data; _serialized = data.Serialize(); }
private void UpdateSessionStats(SessionStats stats) { _sessionRepository.UpdateSessionStats(stats.Id, stats.WordsSubmitted, stats.RequestsPerformed, stats.TotalClientsCount); }
public void UpdateSessionStats(SessionStats Stats) { CurrentRuntime.Globals["Stats"] = Stats; CurrentRuntime.Globals["Balance"] = this.Balance; }
private static SessionStats Deserialize(string data) { try { using (var textReader = new StringReader(data)) { var reader = new JsonTextReader(textReader); var r = new SessionStats(); var currentProperty = string.Empty; reader.MatchNext(JsonToken.StartObject); while (reader.Until(JsonToken.EndObject)) { switch (reader.TokenType) { case JsonToken.PropertyName: currentProperty = reader.Value.ToString(); break; case JsonToken.String: switch (currentProperty) { case nameof(CarId): r.CarId = reader.Value.ToString(); break; case nameof(TrackId): r.TrackId = FixTrackId(reader.Value.ToString()); break; case nameof(Time): r.Time = TimeSpan.Parse(reader.Value.ToString()); break; case nameof(BestLap): r.BestLap = TimeSpan.Parse(reader.Value.ToString()); break; default: throw new Exception($"Unknown key: {currentProperty} (String)"); } break; case JsonToken.Date: switch (currentProperty) { case nameof(StartedAt): r.StartedAt = DateTime.Parse(reader.Value.ToString()); break; default: throw new Exception($"Unknown key: {currentProperty} (Date)"); } break; case JsonToken.Float: case JsonToken.Integer: var val = double.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture); switch (currentProperty) { case nameof(MaxSpeed): r.MaxSpeed = val; break; case nameof(Distance): r.Distance = val; break; case nameof(FuelBurnt): r.FuelBurnt = val; break; case nameof(LongestAirborne): r.LongestAirborne = val; break; case nameof(TotalAirborne): r.TotalAirborne = val; break; case nameof(LongestWheelie): r.LongestWheelie = val; break; case nameof(TotalWheelie): r.TotalWheelie = val; break; case nameof(LongestTwoWheels): r.LongestTwoWheels = val; break; case nameof(TotalTwoWheels): r.TotalTwoWheels = val; break; case nameof(TotalTyreWear): r.TotalTyreWear = val; break; case nameof(GoneOffroad): r.GoneOffroad = (int)val; break; case nameof(TotalCrashes): r.TotalCrashes = (int)val; break; case nameof(BestLapId): r.BestLapId = (int?)val; break; default: throw new Exception($"Unknown key: {currentProperty} (Integer/Float)"); } break; case JsonToken.Boolean: switch (currentProperty) { case nameof(Penalties): r.Penalties = bool.Parse(reader.Value.ToString()); break; default: throw new Exception($"Unknown key: {currentProperty} (Boolean)"); } break; default: throw new Exception($"Unexpected token: {reader.TokenType}"); } } return(r); } } catch (Exception e) { Logging.Error(e); return(JsonConvert.DeserializeObject <SessionStats>(data)); } }
public void Extend(SessionStats session) { /* extremums */ { var drivenDistance = _associatedStorage.GetDouble(KeyDistancePerCarPrefix + session.CarId) + session.Distance; _associatedStorage.Set(KeyDistancePerCarPrefix + session.CarId, drivenDistance); if (session.CarId == MaxDistancePerCarCarId) { MaxDistancePerCar += session.Distance; } else if (drivenDistance > MaxDistancePerCar) { MaxDistancePerCar = drivenDistance; MaxDistancePerCarCarId = session.CarId; } } { var drivenDistance = _associatedStorage.GetDouble(KeyDistancePerTrackPrefix + session.TrackId) + session.Distance; _associatedStorage.Set(KeyDistancePerTrackPrefix + session.TrackId, drivenDistance); if (session.TrackId == MaxDistancePerTrackTrackId) { MaxDistancePerTrack += session.Distance; } else if (drivenDistance > MaxDistancePerTrack) { MaxDistancePerTrack = drivenDistance; MaxDistancePerTrackTrackId = session.TrackId; } } if (session.MaxSpeed > MaxSpeed) { MaxSpeed = session.MaxSpeed; MaxSpeedCarId = session.CarId; } if (session.LongestAirborne > LongestAirborne) { LongestAirborne = session.LongestAirborne; LongestAirborneCarId = session.CarId; } if (session.LongestWheelie > LongestWheelie) { LongestWheelie = session.LongestWheelie; LongestWheelieCarId = session.CarId; } if (session.LongestTwoWheels > LongestTwoWheels) { LongestTwoWheels = session.LongestTwoWheels; LongestTwoWheelsCarId = session.CarId; } /* summary */ Distance += session.Distance; FuelBurnt += session.FuelBurnt; Time += session.Time; GoneOffroadTimes += session.GoneOffroad; TotalAirborne += session.TotalAirborne; TotalWheelie += session.TotalWheelie; TotalTwoWheels += session.TotalTwoWheels; TotalTyreWear += session.TotalTyreWear; TotalCrashes += session.TotalCrashes; SessionsCount++; }