public void OnSaveNameBtnPress() { int total = 0; total = PlayerPrefs.GetInt("saved_total"); //set the total variable to the previously saved value PlayerPrefs.SetString("UserName" + total, ((playerNameTxtbox.GetComponent("InputField") as InputField).text)); PlayerPrefs.SetString("DisplayName", ((playerNameTxtbox.GetComponent("InputField") as InputField).text)); //set the new total value PlayerPrefs.SetString("UserName", ((playerNameTxtbox.GetComponent("InputField") as InputField).text) + total); //set the new total value total += 1; PlayerPrefs.SetInt("saved_total", total); //set the new total value PlayerPrefs.Save(); playerNameTxtbox.transform.parent.gameObject.SetActive(false); Time.timeScale = 1; if (toggleDecay.GetComponent <Toggle>().isOn) { PlayerPrefs.SetInt("Decay", 1); } if (toggleImmigration.GetComponent <Toggle>().isOn) { PlayerPrefs.SetInt("Immigration", 1); } if (toggleFloods.GetComponent <Toggle>().isOn) { floodManager.GetComponent <FloodingManager>().enabled = true; } LogfileWriter.GetInstance().Createfile(); }
/// <summary> /// Initializes a new instance of the <see cref="StfLogger"/> class. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool Init() { LogInfoDetails = new Dictionary <string, string>(); AddLoglevelToRunReport = new Dictionary <StfLogLevel, bool>(); NumberOfLoglevelMessages = new Dictionary <StfLogLevel, int>(); ThreadUtils = new ThreadUtils(); foreach (StfLogLevel loglevel in Enum.GetValues(typeof(StfLogLevel))) { NumberOfLoglevelMessages.Add(loglevel, 0); AddLoglevelToRunReport.Add(loglevel, true); } LogFileHandle = new LogfileWriter { OverwriteLogFile = OverwriteLogFile }; SetDefaultConfiguration(); FileName = Configuration.LogFileName; LogLevel = Configuration.LogLevel; OverwriteLogFile = Configuration.OverwriteLogFile; // setting the default AID logging function LogAutomationIdObjectUserFunction = (level, obj, message) => LogOneHtmlMessage( level, $"AutomationId: [{obj.ToString()}] - Message: [{message}]"); LogFileInitialized = false; return(true); }
internal void UpdateScoreManager() { timeDistribution.UpdateAverages(); PlayerPrefs.SetInt("TotalPopulation" + (PlayerPrefs.GetInt("saved_total") - 1), totalPopulation); //set the new total value PlayerPrefs.SetInt("TotalBabies" + (PlayerPrefs.GetInt("saved_total") - 1), agentsCreator.HowManyAgentsWereBorned); //set the new total value PlayerPrefs.SetInt("DeathsAge" + (PlayerPrefs.GetInt("saved_total") - 1), deathsHandler.HowManyAgentsDied); //set the new total value PlayerPrefs.SetInt("DeathsEaten" + (PlayerPrefs.GetInt("saved_total") - 1), deathsHandler.HowManyAgentsWereEaten); //set the new total value PlayerPrefs.SetInt("DeathsStarved" + (PlayerPrefs.GetInt("saved_total") - 1), deathsHandler.HowManyAgentsWereStarved); //set the new total value PlayerPrefs.SetInt("TotalDeaths" + (PlayerPrefs.GetInt("saved_total") - 1), totalAgentsDied); //set the new total value PlayerPrefs.SetFloat("AverageFood" + (PlayerPrefs.GetInt("saved_total") - 1), timeDistribution.AverageFoodTime); //set the new total value PlayerPrefs.SetFloat("AverageBridges" + (PlayerPrefs.GetInt("saved_total") - 1), timeDistribution.AverageBridgesTime); //set the new total value PlayerPrefs.SetFloat("AverageHouses" + (PlayerPrefs.GetInt("saved_total") - 1), timeDistribution.AverageHouseTime); //set the new total value PlayerPrefs.SetFloat("AverageProcreation" + (PlayerPrefs.GetInt("saved_total") - 1), timeDistribution.AverageProcreationTime); //set the new total value PlayerPrefs.Save(); scoreManager.SetScore(PlayerPrefs.GetString("UserName"), PlayerPrefs.GetString("DisplayName"), totalPopulation, agentsCreator.HowManyAgentsWereBorned, new int[] { deathsHandler.HowManyAgentsDied, deathsHandler.HowManyAgentsWereEaten, deathsHandler.HowManyAgentsWereStarved, totalAgentsDied }, new float[] { timeDistribution.AverageFoodTime, timeDistribution.AverageBridgesTime, timeDistribution.AverageHouseTime, timeDistribution.AverageProcreationTime }); if (daysPassed < timeDistribution.DaysPassed) { daysPassed = timeDistribution.DaysPassed; LogfileWriter.GetInstance().WriteLogline(daysPassed, totalPopulation, agentsCreator.HowManyAgentsWereBorned, new int[] { deathsHandler.HowManyAgentsDied, deathsHandler.HowManyAgentsWereEaten, deathsHandler.HowManyAgentsWereStarved, totalAgentsDied }, new float[] { timeDistribution.FoodTime, timeDistribution.BridgesTime, timeDistribution.HousesTime, timeDistribution.ProcreationTime }, new float[] { timeDistribution.AverageFoodTime, timeDistribution.AverageBridgesTime, timeDistribution.AverageHouseTime, timeDistribution.AverageProcreationTime }); } }
public static LogfileWriter GetInstance() { if (instance == null) { instance = new LogfileWriter(); } return(instance); }
internal void WriteLogAfterFlood() { LogfileWriter.GetInstance().WriteFloodLine(daysPassed, "AfterFlood"); LogfileWriter.GetInstance().WriteLogline(daysPassed, totalPopulation, agentsCreator.HowManyAgentsWereBorned, new int[] { deathsHandler.HowManyAgentsDied, deathsHandler.HowManyAgentsWereEaten, deathsHandler.HowManyAgentsWereStarved, totalAgentsDied }, new float[] { timeDistribution.FoodTime, timeDistribution.BridgesTime, timeDistribution.HousesTime, timeDistribution.ProcreationTime }, new float[] { timeDistribution.AverageFoodTime, timeDistribution.AverageBridgesTime, timeDistribution.AverageHouseTime, timeDistribution.AverageProcreationTime }); LogfileWriter.GetInstance().WriteFloodLine(daysPassed, "AfterFlood"); }
/// <summary> /// The create summary log. /// </summary> /// <param name="nameOfSummaryfile"> /// The name of summaryfile. /// </param> /// <param name="logDir"> /// The log dir. /// </param> /// <param name="filePattern"> /// The file pattern. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool CreateSummaryLog(string nameOfSummaryfile, string logDir, string filePattern) { var logFiles = Directory.GetFiles(logDir, filePattern); summaryLogFile = new LogfileWriter { LogFileName = nameOfSummaryfile, OverwriteLogFile = true }; if (logFiles.Length == 0) { return(true); } // use the first logfile, to figure out how to setup the header for datadriven parameters var dataDrivenParameters = GetDataDrivenParameter(logFiles[0]); if (!OpenSummaryLogFile(nameOfSummaryfile, dataDrivenParameters)) { return(false); } // we use the value for the first logfile, to control the column for the rest of the logfiles. // In that way we dont need to set it for all data rows var iterationDescriptionColumnToUse = GetIterationDescriptionColumn(dataDrivenParameters); foreach (var logfile in logFiles) { var runStatus = RunStatusUtils.GetRunStatus(logfile); dataDrivenParameters = GetDataDrivenParameter(logfile); var iterationDescription = GetIterationDescription(iterationDescriptionColumnToUse, logfile, dataDrivenParameters); LogSummaryForOneLogfile(logfile, runStatus, dataDrivenParameters, iterationDescription); } return(CloseSummaryLogFile()); }
static void Main(string[] args) { // Assemble your system here from all the classes Door _door = new Door(); RfidReaderSimulator _rfid = new RfidReaderSimulator(); UsbChargerSimulator _usbCharger = new UsbChargerSimulator(); DisplayOutput _displayOutput = new DisplayOutput(); DisplaySimulator _display = new DisplaySimulator(_displayOutput); ChargeControl _chargeControl = new ChargeControl(_display, _usbCharger); LogOutput _logOutput = new LogOutput(); LogfileWriter _logfile = new LogfileWriter(_logOutput); StationControl _stationControl = new StationControl(_chargeControl, _door, _rfid, _display, _logfile); bool finish = false; System.Console.WriteLine("Indtast:\n" + "(E) Exit\n" + "(O) Open\n" + "(C) Close\n" + "(R) Read RF-ID"); do { string input = null; // Gate the blocking ReadLine function if (Console.KeyAvailable) { input = Console.ReadLine(); } if (string.IsNullOrEmpty(input)) { continue; } input = input.ToUpper(); switch (input[0]) { case 'E': finish = true; break; case 'O': _door.DoorOpened(); break; case 'C': _door.DoorClosed(); break; case 'R': System.Console.WriteLine("Indtast RFID id: "); string idString = System.Console.ReadLine(); int id = Convert.ToInt32(idString); _rfid.ScanRfidTag(id); break; default: break; } System.Console.WriteLine("Indtast:\n" + "(E) Exit\n" + "(O) Open\n" + "(C) Close\n" + "(R) Read RF-ID"); } while (!finish); }
public void Setup() { output = Substitute.For <ILogOutput>(); uut = new LogfileWriter(output); }