Ejemplo n.º 1
0
    /// <summary>
    /// Adds an IUpdater to the dictionary of IPeriodicUpdaters to periodically update.
    /// </summary>
    /// <param name="updater"> The IPeriodicUpdater to update in given intervals. </param>
    /// <param name="firstUpdateNow"> Whether the first PeriodicUpdate should occur now. </param>
    public void AddPeriodicUpdater(IPeriodicUpdater updater, bool firstUpdateNow = false)
    {
        if (firstUpdateNow)
        {
            updater.PeriodicUpdate();
        }

        periodicUpdaters[updater] = new KeyValuePair <float, bool>(updater.UpdateInterval, false);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Executed once the time has been waited, which executes the updaters update method.
    /// </summary>
    /// <param name="updater"> The updater to update. </param>
    /// <param name="waitTime"> The time interval between each update. </param>
    private void OnTimeWaited(IPeriodicUpdater updater, float waitTime)
    {
        if (!periodicUpdaters.ContainsKey(updater))
        {
            return;
        }

        periodicUpdaters[updater] = new KeyValuePair <float, bool>(waitTime, false);
        updater.PeriodicUpdate();
    }