Ejemplo n.º 1
0
    public void Open(System.Action onOpen = null)
    {
        transitioning = true;
        animator.Play("opening");
        audio.PlayOneShot(soundOpen);
        TimerParams timerParams = new TimerParams
        {
            unscaledTime     = Global.Paused,
            repeat           = false,
            duration         = (1.0f / animationRate) * openFrame,
            UpdateDelegate   = null,
            CompleteDelegate = delegate
            {
                // if the door is toggled open/close, then set transitioning to false here
                // if it auto-closes on a timer, then transitioning should only end after closed.
                //transitioning = false;
                isOpen           = true;
                cd.enabled       = false;
                obstacle.enabled = false;
                if (onOpen != null)
                {
                    onOpen();
                }
            }
        };

        timer.Start(timerParams);
    }
Ejemplo n.º 2
0
 public void OpenAndClose(float duration, System.Action onOpen, System.Action onClose)
 {
     Open(delegate
     {
         if (onOpen != null)
         {
             onOpen();
         }
         TimerParams tp = new TimerParams
         {
             unscaledTime     = Global.Paused,
             repeat           = false,
             duration         = duration,
             CompleteDelegate = delegate
             {
                 Close(null);
                 if (onClose != null)
                 {
                     onClose();
                 }
             }
         };
         doorTimer.Start(tp);
     });
 }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        public Task RegisterTimer()
        {
            var timerParams = new TimerParams
            {
                IntParam    = 100,
                StringParam = "timer test",
            };

            var serializedTimerParams = JsonSerializer.SerializeToUtf8Bytes(timerParams);

            return(this.RegisterTimerAsync("TestTimer", nameof(this.TimerCallback), serializedTimerParams, TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(3)));
        }
Ejemplo n.º 4
0
 public void Start(TimerParams param)
 {
     if (!active)
     {
         NewTimers.Add(this);
     }
     active       = true;
     unscaledTime = param.unscaledTime;
     StartTime    = time;
     if (param.repeat)
     {
         Interval          = param.interval;
         IntervalStartTime = StartTime;
         Duration          = param.interval * param.loops;
     }
     else
     {
         Duration = param.duration;
     }
     OnUpdate   = param.UpdateDelegate;
     OnComplete = param.CompleteDelegate;
 }