protected override GameAction PrepareNextActionOverride(out JobStatus progress) { var action = new SleepAction(m_bed); progress = JobStatus.Ok; return(action); }
public static BaseAction ActionToClass(string action) { BaseAction actionClass; switch (action) { case "play": actionClass = new PlayAction(); break; case "hug": actionClass = new HugAction(); break; case "feed": actionClass = new FeedAction(); break; case "sleep": actionClass = new SleepAction(); break; default: return(null); } return(actionClass); }
internal void SetSleepTimer(DateTime t, SleepAction a) { sleepTimer?.Cancel(); sleepTime = t; sleepAction = a; var period = (t - DateTime.Now).Subtract(TimeSpan.FromSeconds(30)); sleepTimer = ThreadPoolTimer.CreateTimer(async work => { await Dispatcher.RunAsync(CoreDispatcherPriority.High, async() => { PopMessage($"In {(sleepTime - DateTime.Now).TotalSeconds.ToString("0")} seconds sleep timer will activate"); await Task.Delay(Convert.ToInt32((sleepTime - DateTime.Now).TotalMilliseconds)); switch (sleepAction) { case SleepAction.Pause: MainPageViewModel.Current.PlayPause.Execute(); break; case SleepAction.Stop: MainPageViewModel.Current.Stop.Execute(); break; case SleepAction.Shutdown: Application.Current.Exit(); break; default: break; } }); }, period.TotalSeconds < 0 ? TimeSpan.FromSeconds(1) : period, destroy => { }); }
public void ExecuteTurn() { SleepAction.CalculateScore(); EatAction.CalculateScore(); WorkAction.CalculateScore(); FreeAction.CalculateScore(); Result = new PlayerTurnResult(); Result.MoneyEarned = WorkAction.MoneyEarned; if (!WorkAction.TargetMet) { Result.WarningStrikesEarned++; } Result.SelfEsteemChange -= SleepAction.LostSelfEsteem; Result.SelfEsteemChange -= EatAction.LostSelfEsteem; }
ActionState ProcessAction(SleepAction action) { const int exhaustion_per_tick = 10; if (this.ActionTicksUsed == 1) this.ActionTotalTicks = this.Exhaustion / exhaustion_per_tick; this.Exhaustion = Math.Max(this.Exhaustion - exhaustion_per_tick, 0); if (this.ActionTicksUsed < this.ActionTotalTicks) { return ActionState.Ok; } else { SendReport(new SleepActionReport(this)); return ActionState.Done; } }
public void TryIt() { var currentDelay = (int)this.Delay.TotalMilliseconds; int retrysRemaining = this.MaxRetries; do { try { this.Action(); if (Logger.IsTraceEnabled) { Logger.TraceFormat("Action succeeded - {0}", this.Description); } return; } catch (Exception) { if (retrysRemaining <= 0) { Logger.WarnFormat("All retries of action failed - {0}", this.Description); throw; } if (Logger.IsTraceEnabled) { Logger.TraceFormat("Retrying action {0} - {1}", retrysRemaining, this.Description); } SleepAction.Invoke(currentDelay); const double epsilon = 0.0001; if (Math.Abs(this.DelayMultiplier - 1) > epsilon) { currentDelay = (int)(currentDelay * this.DelayMultiplier); } } retrysRemaining--; }while (true); }
ActionState ProcessAction(SleepAction action) { const int exhaustion_per_tick = 10; if (this.ActionTicksUsed == 1) { this.ActionTotalTicks = this.Exhaustion / exhaustion_per_tick; } this.Exhaustion = Math.Max(this.Exhaustion - exhaustion_per_tick, 0); if (this.ActionTicksUsed < this.ActionTotalTicks) { return(ActionState.Ok); } else { SendReport(new SleepActionReport(this)); return(ActionState.Done); } }
protected override GameAction PrepareNextActionOverride(out JobStatus progress) { var action = new SleepAction(m_bed); progress = JobStatus.Ok; return action; }
public SleepEDA(TestStep sleepTestStep) { _sleepAction = sleepTestStep.WebAction.Action as SleepAction; ComArgs.SigTestStep = sleepTestStep; }
public void Sleep() { SleepAction e = new SleepAction(); _sleepActionListenerList.ForEach(sleepActionListener => sleepActionListener.OnActionSourceSleep(e)); }
public void Sleep(int seconds, string url) { SleepAction sleepAction = new SleepAction(seconds, url); actions.Add(sleepAction); }
public Cat ChangeSleep(SleepAction action) { _cat.ApplyAction(action); return(_cat); }
public void OnActionSourceSleep(SleepAction e) { Console.WriteLine("action source is sleeping...."); }