Esempio n. 1
0
        protected override GameAction PrepareNextActionOverride(out JobStatus progress)
        {
            var action = new SleepAction(m_bed);

            progress = JobStatus.Ok;
            return(action);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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 =>
            {
            });
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        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;
            }
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
0
 protected override GameAction PrepareNextActionOverride(out JobStatus progress)
 {
     var action = new SleepAction(m_bed);
     progress = JobStatus.Ok;
     return action;
 }
Esempio n. 9
0
 public SleepEDA(TestStep sleepTestStep)
 {
     _sleepAction        = sleepTestStep.WebAction.Action as SleepAction;
     ComArgs.SigTestStep = sleepTestStep;
 }
Esempio n. 10
0
        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);
        }
Esempio n. 12
0
 public Cat ChangeSleep(SleepAction action)
 {
     _cat.ApplyAction(action);
     return(_cat);
 }
Esempio n. 13
0
 public void OnActionSourceSleep(SleepAction e)
 {
     Console.WriteLine("action source is sleeping....");
 }