public void Results(bool levelCleared) { int score; timer1.Stop(); TimeLeft.Stop(); if (levelCleared == true) { score = correct * time * stats.Accuracy / 100; MessageBox.Show("Level Cleared Successfully!!\nCorrect: " + correct + "\nWrong: " + wrong + "\nAccuracy: " + stats.Accuracy + "\nHighScore: " + score, "Level Cleared!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { score = score = correct * time * stats.Accuracy / 100; MessageBox.Show("Level Not Cleared\nCorrect: " + correct + "\nWrong: " + wrong + "\nAccuracy: " + stats.Accuracy + "\nHighScore: " + score, "LEVEL NOT CLEARED!", MessageBoxButtons.OK, MessageBoxIcon.Information); } highscore(score); this.Visible = false; }
public void WrongMessage() { LogTextBox.Invoke(new Action(() => LogTextBox.AppendText("RECIEVER> Server has sent a bad message!\r\n"))); TimeLeft.Invoke(new Action(() => TimeLeft.Text = "")); SessionID.Invoke(new Action(() => SessionID.Text = "")); SetReadyToSend(false); }
/// <summary> /// Returns true if EntityEventOportunity instances are equal /// </summary> /// <param name="other">Instance of EntityEventOportunity to be compared</param> /// <returns>Boolean</returns> public bool Equals(EntityEventOportunity other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Type == other.Type || Type.Equals(other.Type) ) && ( TimeLeft == other.TimeLeft || TimeLeft.Equals(other.TimeLeft) ) && ( EndTime == other.EndTime || EndTime.Equals(other.EndTime) )); }
// Update is called once per frame void Update() { if (Rewinding) { TimeLeft += Time.deltaTime; } else { TimeLeft -= Time.deltaTime; } if (TimeLeft < HurryUpThreshold && !hurryUpEventWasRaised) { OnHurryUp?.Raise(); hurryUpEventWasRaised = true; } if (TimeLeft < 0 && !timerEndedEventWasRaised) { OnTimerEnded?.Raise(); timerEndedEventWasRaised = true; } text.color = TimeLeft > HurryUpThreshold ? NormalColor : HurryUpColor; TimeLeft = Mathf.Clamp(TimeLeft, 0, StartingTimeSeconds); text.text = TimeLeft.ToString("0.00"); }
public void SetZeitStatus() { DateTime heute = DateTime.Now; TimeSpan timeLeftNow = abgabe.Subtract(heute); TimeSpan timeDiff = TimeLeft.Subtract(timeLeftNow); int percent = 100; if (timeLeft.Days > 0) { percent = (timeDiff.Days * 100) / timeLeft.Days; } if (percent > 0 && percent <= 25) { zeitStatus = ZeitStatus.red; } else { if (percent > 25 && percent <= 65) { zeitStatus = ZeitStatus.yellow; } else { zeitStatus = ZeitStatus.green; } } timeLeft = timeLeftNow; }
private void Start() { soundController = SoundController.FindSoundController(); //gameController = FindObjectOfType<GameController>(); timeLeft = FindObjectOfType <TimeLeft>(); //initialTime = timeLeft.timeLeft; }
// Use this for initialization void Start () { EndBG.SetActive(false); tl = FindObjectOfType<TimeLeft>(); text = GetComponentInChildren<Text>(); foreach (Transform child in transform) { child.gameObject.SetActive(false); } lost = false; prevSavedScore = false; StartCoroutine(LoseCheck()); }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { var oldSecs = TimeLeft.TotalSeconds; if (TimeLeft.TotalSeconds > 0) { TimeLeft = TimeLeft.Subtract(oneSecond); } Tick?.Invoke(this, new TimerTickEventArgs(oldSecs - TimeLeft.TotalSeconds)); }
/// <summary> /// Fired every time timer's cycle elapses /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HandleTimer(object sender, ElapsedEventArgs e) { TimeLeft = TimeLeft.Subtract(new TimeSpan(0, 0, 1)); OnTimerUpdated.Invoke(); if (TimeLeft.Equals(TimeSpan.Zero)) { TimesUp(); } }
/// <summary> /// Handles the cutdown /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HandleTimer(object sender, ElapsedEventArgs e) { // Every second substract one second from time left property TimeLeft = TimeLeft.Subtract(new TimeSpan(0, 0, 1)); // If we reach 0, time has run out and so the test if (TimeLeft.TotalSeconds == 0) { mTestTimer.Stop(); TimesUp(); } }
private void RaceTimerTick(object sender, EventArgs e) { TimeLeft = TimeLeft.Subtract(TimeSpan.FromSeconds(1)); if (TimeLeft == TimeSpan.Zero) { prepareNextStep(); CommandManager.InvalidateRequerySuggested(); } OnPropertyChanged(nameof(TimeLeft)); }
public DayBlock() { InitializeComponent(); PropertyChanged += (sender, args) => { switch (args.PropertyName) { case nameof(TimeLeft): TimeRemainingHeader.Text = Day == 0 ? "Time Remaining:" : "Total Time:"; TimeRemainingLabel.Text = TimeLeft.ToString("#.#") + " hour" + (TimeLeft.ToString("#.#") == "1" ? "" : "s"); break; case nameof(DayName): DayNameLabel.Text = DayName; break; case nameof(Day): case nameof(Tasks): TimeRemainingHeader.Text = Day == 0 ? "Time Remaining:" : "Total Time:"; for (int i = TasksLayout.Children.Count - 1; i >= 0; i--) { //Unsub from TouchedEvent if (TasksLayout.Children[i] is TaskSlider task) { task.TouchedEvent -= WasTouched; } TasksLayout.Children.RemoveAt(i); } Constraint xConstraint = Constraint.Constant(0); TasksLayout.Children.Add(new BoxView { Color = Color.FromHex("#60000000"), HeightRequest = 1, Margin = 0 }, xConstraint, Constraint.Constant(0), Constraint.RelativeToParent(parent => parent.Width)); if (Tasks != null) { for (int i = 0; i < Tasks.Count; i++) { TaskSlider taskSlider = Tasks[i]; taskSlider.TouchedEvent += WasTouched; taskSlider.Day = Day; taskSlider.Priority = i; View last = TasksLayout.Children[TasksLayout.Children.Count - 1]; double PosAfterLastYConstraint(RelativeLayout parent, View view) => view.Y + view.Height + 10; TasksLayout.Children.Add(taskSlider, xConstraint, Constraint.RelativeToView(last, PosAfterLastYConstraint)); } } break; } }; }
public void OnTick() { TimeLeft = TimeLeft.Subtract(new TimeSpan(0, 1, 0)); if (TimeLeft.TotalMinutes == 10) { TenMinuteWarningAlert(); } if (TimeLeft.TotalMinutes == 0) { ExecuteResetTimerCommand(); } }
// Use this for initialization void Start() { startingPoint = GameObject.FindGameObjectWithTag("StartingPoint").transform; inplayUIController = FindObjectOfType <InplayUIController>(); soundController = SoundController.FindSoundController(); timeLeft = FindObjectOfType <TimeLeft>(); initialTime = timeLeft.timeLeft; player = FindObjectOfType <PlayerMovement>(); scoreScript = FindObjectOfType <ScoreScript>(); initialScore = scoreScript.Score; }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; // Suitable nullity checks etc, of course :) hashCode = hashCode * 59 + Type.GetHashCode(); hashCode = hashCode * 59 + TimeLeft.GetHashCode(); hashCode = hashCode * 59 + EndTime.GetHashCode(); return(hashCode); } }
public void EndGame() { bool levelCleared; if (txtDisp == txtTarget) { levelCleared = true; } else { levelCleared = false; } TimeLeft.Stop(); Results(levelCleared); }
public void keyboard_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == richTextBox1.Text[0]) { temp.Push(richTextBox1.Text[0]); richTextBox1.Text = richTextBox1.Text.Remove(0, 1); activeColor = Color.Yellow; stats.Update(true); } else { wrong++; stats.Update(false); activeColor = Color.Red; if (displayMsg.Text != "" && e.KeyChar != Convert.ToChar(Keys.Back)) { displayMsg.Text = displayMsg.Text.Remove(0, 1); } } if (e.KeyChar == Convert.ToChar(Keys.Back) && temp.Count != 0) { richTextBox1.Text = richTextBox1.Text.Insert(0, Convert.ToString(temp.Pop())); } if (e.KeyChar == Convert.ToChar(Keys.Menu) || e.KeyChar == Convert.ToChar(Keys.Tab) || e.KeyChar == Convert.ToChar(Keys.ControlKey) || e.KeyChar == Convert.ToChar(Keys.Enter) || e.KeyChar == Convert.ToChar(Keys.Escape) || e.KeyChar == Convert.ToChar(Keys.Back)) { wrong--; activeColor = Color.Yellow; } if (richTextBox1.Text == "") { richTextBox1.Text = GetRandomWord(); displayMsg.Text = ""; correct++; TimeLeft.Stop(); TimeLeft.Start(); } CorrectLbl.Text = "Correct: " + correct; WrongLbl.Text = "Health: " + (20 - wrong); AccuracyLbl.Text = "Accuracy: " + stats.Accuracy + "%"; }
public override int GetHashCode() { int hash = 1; if (TimeLeft != 0L) { hash ^= TimeLeft.GetHashCode(); } if (Message.Length != 0) { hash ^= Message.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void SetTimeLeft() { if (TimeLeft == 0) { Active = false; } else { TimeLeft = TimeLeft - 1; if (TimeLeft <= 3) { for (int i = 0; i < Subscribers.Count; i++) { Subscribers[i].Gavel("Time left: " + TimeLeft.ToString()); } } } }
void timer_Tick(object sender, EventArgs e) { TimeLeft = TimeLeft.Subtract(_tickInterval); IntervalLeft = IntervalLeft.Subtract(_tickInterval); if (IntervalLeft.TotalMilliseconds <= 0) { PlayInterval(); IntervalLeft = Interval; } else if (IntervalLeft.TotalMilliseconds % 500 == 0) { PlayTick(); } if (TimeLeft.TotalMilliseconds <= 0) { WorkoutFinished = true; _workoutTimer.Stop(); } }
private void Timer1_Tick(object sender, EventArgs e) { timeLabel.ForeColor = Color.White; timeLabel.Font = new Font("Calibri", 25, FontStyle.Bold); timeLabel.BackColor = Color.Black; if (TimeLeft > 0) { if (!timeLabel.Visible) { timeLabel.Visible = true; } TimeLeft -= 1; timeLabel.Text = TimeLeft.ToString(); } else { timer1.Stop(); timeLabel.Text = "0"; timeLabel.Visible = false; GameCycle.ChangeGame(); } }
public async Task <string> AuctionStart(string product_name) { IsRunning = true; Clients.Caller.DisableButtons(); end = Models.Timer.GetTimer(); auctionInfo = context.AuctionInfos.Where(a => a.Product == product_name).First(); CurrentAuction = new Models.Auction() { AuctionStart = DateTime.Now, Price = 100, AuctionInfo = auctionInfo }; Clients.All.ReceiveInfo(CurrentAuction.Price, "", auctionInfo.Product); while (TimeLeft > TimeSpan.Zero) { Clients.All.TimeReceiver(TimeLeft.ToString().Substring(0, 8)); Thread.Sleep(1000); } string info; if (participant.Email == "") { info = "Никто не приобрел продукт " + CurrentAuction.AuctionInfo.Product; Models.Timer.ResetTimer(); Clients.AllExcept(Context.ConnectionId).AuctionEnd(info); Clients.Caller.EnableButtons(); return(info); } await End(); info = new StringBuilder().Append("Пользователь ") .Append(CurrentAuction.User.Email) .Append(" приобрел ") .Append(CurrentAuction.AuctionInfo.Product) .Append(" за ") .Append(CurrentAuction.Price) .ToString(); Clients.AllExcept(Context.ConnectionId).AuctionEnd(info); Clients.Caller.EnableButtons(); return(info); }
private void Pause(object sender, EventArgs e) { timer1.Stop(); TimeLeft.Stop(); }
private void Resume(object sender, EventArgs e) { timer1.Start(); TimeLeft.Start(); }
private void RpcUpdateTimeLeft(float time, bool forceUpdate) { TimeLeft.Update(time, forceUpdate); }
public override string ToString() { return(TimeLeft.ToString()); }
private void Awake() { timeLeft = GameObject.FindGameObjectWithTag("UITag").GetComponent <TimeLeft>(); respawn = GameObject.FindGameObjectWithTag("GameManagerTag").GetComponent <Respawn>(); }
public void Draw(SpriteBatch spriteBatch, GameTime gameTime) { string scoreHUDText = ScoreHUDCounter.ToString(); string coinHUDText = CoinHUDCounter.ToString(); string worldHUDText = CurrentWorld.ToString() + "-" + CurrentStage.ToString(); // Sets our timeCounter such that our HUD Timer decrements every half of a second. if (gameTime.TotalGameTime.Milliseconds % GameValues.HUDDrawDelay == 0 && !FreezeHUD) { if (timeCounter < TimerLife) { if (timeCounter == GameValues.HUDTimeWarningAmount) { TimeIsLow = true; SoundManager.Instance.PlayTimeWarning(); } timeCounter++; } else { new TimeUpCommand(GameStateMachine.Instance.PlayableObjects).Execute(); } } string timerHUDText = ""; if (GameStateMachine.Instance.GameState.ToString() == "SuperMario.GameStates.TimeScoreAnimationState") { timerHUDText = TimeLeft.ToString(); } else if (GameStateMachine.Instance.GameState.ToString() == "SuperMario.GameStates.ExitGameState" || GameStateMachine.Instance.GameState.ToString() == "SuperMario.GameStates.GameWonState") { timerHUDText = GameValues.HUDEmptyTimeCounter; } else { timerHUDText = (TimerLife - timeCounter).ToString(); } // Pads all our HUD values with 0's. for (int i = 1; scoreHUDText.Length < GameValues.HUDScoreMaxLength; i++) { scoreHUDText = "0" + scoreHUDText; } for (int i = 1; coinHUDText.Length < GameValues.HUDCoinMaxLength; i++) { coinHUDText = "0" + coinHUDText; } for (int i = 1; timerHUDText.Length < GameValues.HUDTimerMaxLength; i++) { timerHUDText = "0" + timerHUDText; } //if (GameStateMachine.Instance.GameState.ToString() == "SuperMario.GameStates.GameOverState") if (GameStateMachine.Instance.GameState.ToString() == "SuperMario.GameStates.MarioRespawnState") { if (!(Mario.Instance.Lives > GameValues.MarioStartingLives)) { UpdateGameStats(scoreHUDText, coinHUDText, worldHUDText, timerHUDText, Mario.Instance.Lives - 1); } } else if (GameStateMachine.Instance.GameState.ToString() == "SuperMario.GameStates.GameOverState" && gameOver) { UpdateGameStats(scoreHUDText, coinHUDText, worldHUDText, timerHUDText, Mario.Instance.Lives); gameOver = false; } scoreHUDText = "MARIO\n" + scoreHUDText; coinHUDText = "\nx" + coinHUDText; worldHUDText = "WORLD\n " + worldHUDText; timerHUDText = "TIME\n " + timerHUDText; Vector2 scoreHUDOrigin = HudFont.MeasureString(scoreHUDText) / 2; Vector2 coinHUDOrigin = HudFont.MeasureString(coinHUDText) / 2; Vector2 worldHUDOrigin = HudFont.MeasureString(worldHUDText) / 2; Vector2 timerHUDOrigin = HudFont.MeasureString(timerHUDText) / 2; int xPositionPadding = (int)Position.X / 4; int yPositionPadding = (int)Position.Y; // Sets the distance between each line of text on the HUD. HudFont.LineSpacing = 3 * ((int)HudFont.MeasureString(scoreHUDText).Y / 7); sprite.UpdateSpritePosition(new Vector2(Position.X - HudFont.MeasureString(coinHUDText).X - xPositionPadding, yPositionPadding + 5)); sprite.Draw(spriteBatch, gameTime); spriteBatch.DrawString(HudFont, scoreHUDText, new Vector2(Position.X - (3 * xPositionPadding), yPositionPadding), Color.White, 0, scoreHUDOrigin, 1.0f, SpriteEffects.None, 0.5f); spriteBatch.DrawString(HudFont, scoreHUDText, new Vector2(Position.X - (3 * xPositionPadding), yPositionPadding), Color.White, 0, scoreHUDOrigin, 1.0f, SpriteEffects.None, 0.5f); spriteBatch.DrawString(HudFont, coinHUDText, new Vector2(Position.X - xPositionPadding, yPositionPadding), Color.White, 0, coinHUDOrigin, 1.0f, SpriteEffects.None, 0.5f); spriteBatch.DrawString(HudFont, worldHUDText, new Vector2(Position.X + xPositionPadding, yPositionPadding), Color.White, 0, worldHUDOrigin, 1.0f, SpriteEffects.None, 0.5f); spriteBatch.DrawString(HudFont, timerHUDText, new Vector2(Position.X + (3 * xPositionPadding), yPositionPadding), Color.White, 0, timerHUDOrigin, 1.0f, SpriteEffects.None, 0.5f); }
public String GetScript() { StringBuilder sb = new StringBuilder(); String scriptCallBackTimerDeclaration = #region Call Back Timer Public Declaration @" //Define a custom object 'Timer' Timer = new Object(); Timer.Interval={0}; Timer.TimeOut={1}; Timer.TimeLeft={1}; Timer.SynchronizeStopWatch={2}; Timer.CountDown= {{ Async:0, Sync:1 }}; Timer.RefCallBackTimer; Timer.RefCountDownTimer; Timer.Display; Timer.MilliSecond=0; Timer.Second=0; Timer.Minute=0; Timer.Hour=0; Timer.IsPostBackOnTimeOut='{3}'; "; #endregion //String Format Error: To work around the method, simply replace each curly brace "{" with double braces "{{". //After String.Format the double braces will be converted into single braces. scriptCallBackTimerDeclaration = String.Format(scriptCallBackTimerDeclaration, (Interval * 1000).ToString(), TimeLeft.ToString(), ServerSideTimeSynchronize ? 1 : 0, DoPostBackOnTimeOut.ToString().ToLower()); String scriptCountDownTimer = #region Count Down Timer @" Timer.Initialize=function() { Timer.StopCountDownTimer(); Timer.UpdateCountDownTimer(); Timer.RefCountDownTimer=setTimeout('Timer.ShowCountDownTimer()',100); Timer.StopCallBackTimer(); Timer.StartCallBackTimer(); } Timer.StopCountDownTimer=function() { clearTimeout(Timer.RefCountDownTimer); } Timer.UpdateCountDownTimer=function () { Timer.Hour=Math.floor(Timer.TimeLeft/3600); Timer.Minute = Math.floor((Timer.TimeLeft -(Timer.Hour*3600)) / 60); Timer.Second = Timer.TimeLeft - ((Timer.Minute * 60)+(Timer.Hour*3600)); Timer.MilliSecond=0; } Timer.ShowCountDownTimer = function() { if(Timer.Hour>0 || Timer.Minute>0 || Timer.Second>0) { if (Timer.MilliSecond<=0) { Timer.MilliSecond=9; Timer.Second-=1; Timer.TimeLeft-=1; } else Timer.MilliSecond-=1; if (Timer.Second<=0) { Timer.MilliSecond=9; Timer.Second=59; Timer.Minute-=1; Timer.TimeLeft-=1; } if (Timer.Minute<=-1) { Timer.Minute=59; Timer.Hour-=1; } if(Timer.Hour<=-1) { Timer.MilliSecond=0; Timer.Second=0; Timer.Minute=0; Timer.Hour=0; } } else { Timer.TimeLeft=-9; if(Timer.IsPostBackOnTimeOut=='true') Timer.CallTimeOutHandler(); else Timer.CallServer(); Timer.StopCallBackTimer(); } Timer.Display=document.getElementById('__DControls__Timer__Display'); Timer.Display.innerHTML =Timer.Hour+':'+ Timer.Minute+':'+Timer.Second+'.'+Timer.MilliSecond; if(Timer.TimeLeft>0) Timer.RefCountDownTimer=setTimeout('Timer.ShowCountDownTimer()',100); else { if(Timer.IsPostBackOnTimeOut=='true') Timer.CallTimeOutHandler(); } } "; #endregion String scriptCallBackTimerMembers = #region Call Back Timer Members @" Timer.CallTimeOutHandler=function() { __doPostBack('TimeOutPostBack','-9'); } Timer.StopCallBackTimer=function() { clearTimeout(Timer.RefCallBackTimer); } Timer.StartCallBackTimer=function() { if(Timer.TimeLeft>0) { if(Timer.TimeLeft*1000<Timer.Interval || Timer.Interval<=0) Timer.RefCallBackTimer=window.setTimeout('Timer.CallServer()', Timer.TimeLeft*1000); else if(Timer.Interval>0) Timer.RefCallBackTimer=window.setTimeout('Timer.CallServer()', Timer.Interval); } else { Timer.StopCallBackTimer(); } } Timer.CallServer=function() { CallTheServer(Timer.TimeLeft, ''); } function ReceiveServerData(Result, context) { if(Timer.SynchronizeStopWatch==Timer.CountDown.Sync) { Timer.TimeLeft=Result; Timer.Initialize(); } else { Timer.StartCallBackTimer(); } } function ProcessCallBackError(arg, context) { Timer.StopCallBackTimer(); alert('Error : Call Back Method Failed'+' Arg : '+arg+' Context : '+context); } Timer.Initialize(); "; #endregion // sb.Append("<script type=\"text/javascript\">"); if (DisableRightClick) { sb.Append("document.oncontextmenu = new Function('return false');"); } sb.Append(scriptCallBackTimerDeclaration); sb.Append(scriptCountDownTimer.Replace("__DControls__Timer__Display", this.ClientID)); sb.Append(scriptCallBackTimerMembers); // sb.Append("</script>"); return(sb.ToString()); }
public string GetRestrictionText() { return("Time per turn: " + TimeLeft.ToString("0.00")); }
public void Timing(object sender, TimeLeft e) { ShowMessage($"Listener {Number}: Start timer\n\tSender: {sender}\n\tSeconds: {e.Seconds} timeleft."); }