コード例 #1
0
    //---------------------------------------------------------------------------------------------------------------
    private void Update(TimeScaleLayer layer, float timeScale)
    {
        activeTimers
        .FindAll(t => t.Layer == layer)
        .ForEach(t => t.Update(timeScale));

        activeTimers.RemoveAll(t => !t.IsWorking);
    }
コード例 #2
0
        public Timer(float time, Action callback, TimeScaleLayer layer)
        {
            initTimeNeeded = timeNeeded = time;
            Callback       = callback;

            timePassed = 0;

            IsWorking = true;
            IsPaused  = false;
            Layer     = layer;
        }
コード例 #3
0
    //---------------------------------------------------------------------------------------------------------------
    /// <summary>
    /// Creates and returns timer.
    /// </summary>
    /// <param name="time">MS</param>
    /// <param name="callback">This method is to be called once timer will finishes. Callback instance should exist when it happens, otherwise error will occur.</param>
    /// <param name="layer">Assignes timer to specific layer if set.</param>
    /// <returns></returns>
    public Timer Start(float time, Action callback, TimeScaleLayer layer = TimeScaleLayer.Common, bool StartPaused = false)
    {
        if (time < 0)
        {
            time = 0;
        }
        Timer timer = new Timer(time, callback, layer);

        if (StartPaused)
        {
            timer.Pause();
        }

        activeTimers.Add(timer);

        return(timer);
    }
コード例 #4
0
 public Timer SetLayer(TimeScaleLayer newLayer)
 {
     Layer = newLayer;
     return(this);
 }
コード例 #5
0
 //---------------------------------------------------------------------------------------------------------------
 //Pause time flow of all timers of specific TimeScaleLayer, however paused timers unlike stopped or halted timers will not be deleted during next Update and could be resumed.
 public void PauseAll(TimeScaleLayer layer)
 {
     activeTimers.FindAll(t => t.Layer == layer)
     .ForEach(t => t.Pause());
 }
コード例 #6
0
 //---------------------------------------------------------------------------------------------------------------
 public void ResumeAll(TimeScaleLayer layer)
 {
     activeTimers.FindAll(t => t.Layer == layer)
     .ForEach(t => t.Resume());
 }
コード例 #7
0
 //---------------------------------------------------------------------------------------------------------------
 public void StopAll(TimeScaleLayer layer)
 {
     activeTimers.FindAll(t => t.Layer == layer)
     .ForEach(t => t.Stop());
 }
コード例 #8
0
 public TimeScaleData(TimeScaleLayer layer)
 {
     Layer  = layer;
     Signal = new Signal <float>();
     scale  = 1;
 }
コード例 #9
0
 public float GetScale(TimeScaleLayer layer)
 {
     return(datas.Find(d => d.Layer == layer).GetScale());
 }
コード例 #10
0
 public void SetScale(TimeScaleLayer layer, float scale, float time = 0)
 {
     datas.Find(d => d.Layer == layer).SetScale(scale, time);
 }
コード例 #11
0
 public void ListenUpdate(TimeScaleLayer layer, Action <float> action)
 {
     datas.Find(d => d.Layer == layer).Listen(action);
 }