private void Awake() { initialFontColor = trust.color; gameManager = GetComponent <GameManager>(); timeHandler = GetComponent <TimeHandler>(); populationHandler = GetComponent <PopulationHandler>(); }
public static void handleTraining(string action) { int stamina = PlayerData.playerData.stamina; if (stamina > 0) { if (action == "strength") { PlayerData.playerData.playerPower.strength += 1; } else if (action == "agility") { PlayerData.playerData.playerPower.agility += 1; } else if (action == "fortitude") { PlayerData.playerData.playerPower.fortitude += 1; } else if (action == "will") { PlayerData.playerData.playerPower.will += 1; } TimeHandler.handleCycleChange("training"); } else if (stamina == 0) { Debug.Log("Rest up, " + PlayerData.playerData.playerPower.powerName); } }
public Timer Create(TimeHandler callback, TimeArgHandler argcallback, float frequency, int repeate, params System.Object[] args) { Timer ti = new Timer(callback, argcallback, frequency, repeate, args); _Timers.Add(ti); return(ti); }
protected virtual void UpdateExecutionWaitingTimeToStart() { if (TimeHandler.HasTimeJustPassed(GetParameters().plannedStartingTime)) { SetPhase(Task.TaskPhase.Execution); } }
private static void InitializeAll() { TimeHandler.Start(); ModlogQueue = new( (ModlogMessageType.Moderation, HomeGuild.GetChannel(ToUInt64(Config["insanitybot.identifiers.commands.modlog_channel_id"]))), (ModlogMessageType.Administration, HomeGuild.GetChannel(ToUInt64(Config["insanitybot.identifiers.commands.admin_log_channel_id"])))); }
private void RemoveNotification() { if (_spammingText.gameObject.activeInHierarchy && TimeHandler.GetMilliseconds() - _timeOfSpamming >= _taskSettings.InfoTime) { _spammingText.gameObject.SetActive(false); } }
public void AddWeatherGraph(string cityName, string parameters, DateTime startTime, DateTime endTime, string graphName, WeatherType.ParameterEnum parameterType, int interval) { if (cityName == null || cityName == "") { throw new Exception("Please give a name of cities in Finland"); } Dictionary <string, IDataSeries> combined_graphs = new Dictionary <string, IDataSeries>(); try { TimeHandler.IsTimeValid(startTime, endTime); IsPlotNameValid(graphName); combined_graphs = FMI.GetAllData(startTime, endTime, interval, graphName, cityName, parameters, parameterType); } catch (AggregateException ae) { Console.WriteLine("FMIAction failed:"); foreach (var ex in ae.InnerExceptions) { Console.WriteLine(ex.Message); throw new Exception(ex.Message); } } foreach (var graph in combined_graphs) { graph.Value.Name = graphName + " (" + graph.Value.Name + ")"; DataPlot.Data.Add(graph.Value); } }
public void CleanUp() { Handler = null; ArgHandler = null; Iscomplete = true; Repeate = 1; Frequency = 0; }
public void ModifyDate() { DateTime dt; DateTime.TryParse(string.Concat(TbDate.Text, " ", TbClock.Text), out dt); TimeHandler.SetCurrentDateTime(dt); UpdateDateTimeDisplay(); }
private void Awake() { isGameRunning = false; isGameLost = false; timeHandler = GetComponent <TimeHandler>(); populationHandler = GetComponent <PopulationHandler>(); onGameEnded = new GameEndedEvent(); }
public void UpdateDateTimeDisplay() { var dt = TimeHandler.GetCurrentDateTime(); MainCalendar.SelectedDate = dt; TbClock.Text = dt.TimeOfDay.ToString(); TbDate.Text = dt.ToShortDateString(); }
public Timer(TimeHandler handler, TimeArgHandler arghandler, float frequency, int reapeate, System.Object[] args) { this.Handler = handler; this.ArgHandler = arghandler; this.Frequency = frequency; this.Repeate = reapeate; this.Args = args; LastTickTime = Time.time; }
public static void setTotalTimeCell(int i_Column, DataGridViewRow i_NewRow) { i_NewRow.Cells[i_Column].Value = TimeHandler.calcTime( (string)i_NewRow.Cells[(int)eColumn.Arrival].Value, (string)i_NewRow.Cells[(int)eColumn.Leaving].Value); i_NewRow.Cells[i_Column].Style.BackColor = ((string)i_NewRow.Cells[i_Column].Value).StartsWith("-") ? Color.LightCoral : Form.DefaultBackColor; }
protected virtual void EnterExecutionWaitingTimeToStart() { if (!GetParameters().plannedStartingTime.isInitialized) { SetPhase(Task.TaskPhase.Execution); } else if (TimeHandler.HasTimeJustPassed(GetParameters().plannedStartingTime)) { SetPhase(Task.TaskPhase.Execution); } }
private void Awake() { if (_instance == null) { _instance = this; } else { Debug.LogWarning("Several TimeHandler objects in scene!"); } }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
private void ShowNotification() { if (++_numberOfSpamming >= 3) { _currentDisplayStatus = DisplayStatus.GoToMainMenu; } else { _timeOfSpamming = TimeHandler.GetMilliseconds(); _spammingText.gameObject.SetActive(true); } }
private void ResetDay() { currentDay = TimeHandler.currentDay; currentFrame = 0; currentTime = 0.0f; currentMemTotal = 0.0f; minimumFPS = Mathf.Infinity; maximumFPS = 0.0f; maximumMemory = 0.0f; minimumMemory = Mathf.Infinity; TimeHandler.PauseGame(); }
// Update is called once per frame void Update() { if (ItemLocked) { TextMeshProUGUI[] texts = this.transform.parent.GetComponentsInChildren <TextMeshProUGUI>(); //texts[1].color = Color.magenta; texts[1].text = TimeHandler.PrintTime(_time - DateTime.Now); if (DateTime.Now > _time) { //texts[1].color = Color.green; texts[1].text = "Ready"; ItemLocked = false; _inv.PrintMessage(ItemIns.Item.Name + " Is ready", Color.green); } } }
// Update is called once per frame void Update() { if (Input.GetButtonDown("Pause")) { TimeHandler.PauseGame(); } if (Input.GetButtonDown("ChangeSpeedUp")) { TimeHandler.ChangeTimeScale(timeScaleChangeIncrement); } else if (Input.GetButtonDown("ChangeSpeedDown")) { TimeHandler.ChangeTimeScale(-timeScaleChangeIncrement); } }
// Update is called once per frame void Update() { if (_characterManager.UserPlayer.GetLockUntil() > DateTime.Now) { var timer = _characterManager.UserPlayer.GetLockUntil() - DateTime.Now; _startText.text = TimeHandler.PrintTime(timer); _buyText.text = "Use " + TimeHandler.GemTimeValue(timer) + " Gem(s)"; } else { _startText.text = "Now"; _startButton.interactable = true; _buyButton.SetActive(false); } }
static void Main(string[] args) { ProductList = new List <Product>(); CampaignList = new List <Campaign>(); OrderList = new List <Order>(); Console.WriteLine("Please enter one of 1, 2, 3, 4 or 5 values for select scenario file"); string scenarioFileNumber = Console.ReadLine(); var fileNumbers = new List <string> { "1", "2", "3", "4", "5" }; if (fileNumbers.Contains(scenarioFileNumber)) { try { var timehandler = new TimeHandler { Time = 0 }; var CommandList = new List <string>(); var opr = new Operations(); CommandList = opr.ReadCommandsFromScenarioFile(scenarioFileNumber); if (CommandList.Count == 0) { Console.WriteLine("No command in file!"); } else { foreach (string line in CommandList) { Console.WriteLine(opr.ExecuteCommand(line, timehandler, ProductList, CampaignList, OrderList)); } } } catch (Exception exc) { Console.WriteLine("Unexpected error occurred. Error detail : " + exc.Message); } } else { Console.WriteLine("Please enter one of 1, 2, 3 or 4 values for select scenario file."); } Console.ReadLine(); }
private void SpendGem() { var gem = TimeHandler.GemTimeValue(_time - DateTime.Now); if (_characterManager.UserPlayer.Gem > gem) { _characterManager.AddCharacterSetting("Gem", -gem); } else { _messagePanelHandler.ShowMessage("You don't have enough Gem ! ", MessagePanel.PanelType.Ok); SceneSettings.GoToShopScene("Gem"); return; } _characterManager.SetCharacterResearchingTime(); _time = DateTime.Now; }
public void StartSimulation() { while (simulationsDay > 0) { Console.WriteLine(simulatorDate.ToString()); simulatorDate = simulatorDate.AddMinutes(6); TimeHandler.Invoke(); Thread.Sleep(tickPerSecond); simulationsDay--; if (simulatorDate.Hour == 17) { simulatorDate = GetDateTime(); } } }
void Update() { if (timeAnalysis) { if (!TimeHandler.gamePaused && !firstUpdate) { if (endOfDay) { ResetDay(); } if (currentDay != TimeHandler.currentDay) { for (int i = 0; i < 14; i++) { if (SpawnBaseTypes.classNumbers[i] > 0) { sleepTimeShow[i] = sleepTimeShow[i] / SpawnBaseTypes.classNumbers[i]; restTimeShow[i] = restTimeShow[i] / SpawnBaseTypes.classNumbers[i]; workTimeShow[i] = workTimeShow[i] / SpawnBaseTypes.classNumbers[i]; recreationTimeShow[i] = recreationTimeShow[i] / SpawnBaseTypes.classNumbers[i]; socialTimeShow[i] = socialTimeShow[i] / SpawnBaseTypes.classNumbers[i]; travelTimeShow[i] = travelTimeShow[i] / SpawnBaseTypes.classNumbers[i]; } } endOfDay = true; TimeHandler.PauseGame(); return; } sleepTimeShow = sleepTime; restTimeShow = restTime; workTimeShow = workTime; recreationTimeShow = recreationTime; socialTimeShow = socialTime; travelTimeShow = travelTime; } if (firstUpdate) { firstUpdate = false; } } }
private void SpendGem() { var timer = _characterManager.UserPlayer.GetLockUntil() - DateTime.Now; var gem = TimeHandler.GemTimeValue(timer); print("Process GEM " + gem + " of " + _characterManager.UserPlayer.Gem); if (_characterManager.UserPlayer.Gem > gem) { _characterManager.AddCharacterSetting("Gem", -gem); } else { _messagePanelHandler.ShowMessage("You don't have enough Gem ! ", MessagePanel.PanelType.Ok); _storeButton.SetActive(true); _buyButton.SetActive(false); return; } _characterManager.SetLockTill(); }
public string ExecuteCommand(string command, TimeHandler timeHandler, List <Product> productList, List <Campaign> campaignList, List <Order> orderList) { string commandResult = string.Empty; char[] seperators = { ' ' }; List <string> cmdArr = command.Split(seperators).ToList().Where(x => !string.IsNullOrEmpty(x)).ToList(); string commandName = cmdArr[0]; // first parameter is always command name.. like create_product if (commandName == "increase_time") { timeHandler.IncreaseTime(Convert.ToInt32(cmdArr[1])); commandResult = string.Format("Time is {0}:00", timeHandler.Time.ToString().PadLeft(2, '0')); } else { cmdArr.RemoveAt(0); // the remaining array elements are parameters of the command FactoryCreator CommandCreator = new FactoryCreator(); BaseCommands commandModel = CommandCreator.CommandFactory(commandName); if (commandModel != null) { string checkResult = commandModel.CheckParameters(cmdArr, productList, campaignList, orderList); if (string.IsNullOrEmpty(checkResult)) { commandResult = commandModel.GetCommandResult(cmdArr, productList, campaignList, orderList, timeHandler); } else { commandResult = checkResult; } } else { commandResult = "The command is not defined in the system"; } } return(commandResult); }
internal NodaTimeTypeHandlerResolver(NpgsqlConnector connector) { _databaseInfo = connector.DatabaseInfo; _timestampHandler = LegacyTimestampBehavior ? new LegacyTimestampHandler(PgType("timestamp without time zone")) : new TimestampHandler(PgType("timestamp without time zone")); _timestampTzHandler = LegacyTimestampBehavior ? new LegacyTimestampTzHandler(PgType("timestamp with time zone")) : new TimestampTzHandler(PgType("timestamp with time zone")); _dateHandler = new DateHandler(PgType("date")); _timeHandler = new TimeHandler(PgType("time without time zone")); _timeTzHandler = new TimeTzHandler(PgType("time with time zone")); _intervalHandler = new IntervalHandler(PgType("interval")); // Note that the range handlers are absent on some pseudo-PostgreSQL databases (e.g. CockroachDB), and multirange types // were only introduced in PG14. So we resolve these lazily. _arrayNullabilityMode = connector.Settings.ArrayNullabilityMode; }
public void AddPowerGraphAction(PowerType powerType, DateTime startTime, DateTime endTime, string graphName) { if (powerType == null) { throw new Exception("Please choose the category"); } if (TimeHandler.DataTooBig(startTime, endTime, powerType.Interval)) { return; } startTime = TimeHandler.ConvertToLocalTime(startTime); endTime = TimeHandler.ConvertToLocalTime(endTime); try { TimeHandler.IsTimeValid(startTime, endTime); IsPlotNameValid(graphName); var series_task = Task.Run(() => Fingrid.Get(powerType, startTime, endTime)); try { series_task.Wait(); var series = series_task.Result; series.Name = graphName + " (" + powerType.Source + ")"; DataPlot.Data.Add(series); } catch (AggregateException e) { Console.WriteLine("Cannot add data to plot"); foreach (var ex in e.InnerExceptions) { Console.WriteLine(ex.Message); } throw new Exception("Cannot add data to plot"); } } catch (Exception e) { throw e; } }
private void ArrivalOrLeavingPressed(DataGridViewCellEventArgs i_E, int i_Day) { string msg = (string)monthGridView.Rows[i_Day].Cells[i_E.ColumnIndex].Value; string hours = TimeHandler.getHoursStr(msg); string minutes = TimeHandler.getMinutesStr(msg); msg = new GetTimeDataForm(hours, minutes).ShowDialog(); if (msg == null) { return; } if ((eColumn)i_E.ColumnIndex == eColumn.Arrival) { m_TimeWatch.AllDays[i_Day].ArrivalTime = new TimeData(msg); } else if ((eColumn)i_E.ColumnIndex == eColumn.Leaving) { m_TimeWatch.AllDays[i_Day].LeavingTime = new TimeData(msg); } }
public JsonResult Update([FromBody] UpdateTimeCommand command, [FromServices] TimeHandler handler) { if (command is null) { return new JsonResult(NotFound()) { StatusCode = 404 } } ; try { var time = (GenericCommandResult)handler.Handle(command); if (!time.Success) { return new JsonResult(BadRequest()) { StatusCode = 400, Value = new GenericCommandResult(false, time.Message, command.Notifications) } } ; var data = (Time)time.Data; return(Json(new TimeDTO(data.Id, data.Project, data.User, data.Started_at, data.Ended_at))); } catch (Exception ex) { return(new JsonResult(BadRequest()) { StatusCode = 400, Value = new GenericCommandResult(false, ex.Message, command.Notifications) }); } } }