Esempio n. 1
0
    /// <summary>
    /// Stop time calc
    /// </summary>
    /// <param name="key">item key</param>
    private void StopCalc(string key)
    {
        if (!TimeCalc.ContainsKey(key))
        {
            Debug.LogError("key:" + key + " not exist.");
            return;
        }

        TimeCalc.GetTimeCalc(key).IsOverTime = true;
        TimeCalc.GetTimeCalc(key).StartTime  = -1;
    }
Esempio n. 2
0
    /// <summary>
    /// Start time calc
    /// </summary>
    /// <param name="key">item key</param>
    private void StartCalc(string key)
    {
        if (!TimeCalc.ContainsKey(key))
        {
            Debug.LogError("key:" + key + " not exist.");
            return;
        }

        TimeCalc.GetTimeCalc(key).IsOverTime = false;
        TimeCalc.GetTimeCalc(key).StartTime  = Time.realtimeSinceStartup;
    }
Esempio n. 3
0
    /// <summary>
    /// Remove time calc dictionary item.
    /// </summary>
    /// <param name="key">item key</param>
    /// <returns>is remove succeed</returns>
    public bool RemoveFromTimeCalc(string key)
    {
        StopCalc(key);

        if (!TimeCalc.ContainsKey(key))
        {
            Debug.LogError("Cannot remove key:" + key + " to time calc cause key not exist.");
            return(false);
        }

        TimeCalc.m_timeCalcList.Remove(TimeCalc.GetTimeCalc(key));
        return(true);
    }
Esempio n. 4
0
    public float GetCalcTime(string key)
    {
        if (!TimeCalc.ContainsKey(key))
        {
            Debug.LogError("key:" + key + " not exist.");
            return(-1);
        }

        if (TimeCalc.GetTimeCalc(key).StartTime < 0)
        {
            Debug.LogError("Time calc key:" + key + " stopped or never start.");
            return(-1);
        }

        return(Time.realtimeSinceStartup - TimeCalc.GetTimeCalc(key).StartTime);
    }
Esempio n. 5
0
    /// <summary>
    /// Is over time
    /// </summary>
    /// <param name="key">item key</param>
    /// <returns>is over</returns>
    public bool IsCalcTimeOver(string key)
    {
        if (!TimeCalc.ContainsKey(key))
        {
            Debug.LogError("key:" + key + " not exist.");
            return(false);
        }

        if (TimeCalc.GetTimeCalc(key).StartTime < 0)
        {
            Debug.LogError("Time calc key:" + key + " stopped or never start.");
            return(false);
        }

        return(TimeCalc.GetTimeCalc(key).IsOverTime);
    }
Esempio n. 6
0
    /// <summary>
    /// Add time calc dictionary item, delegate execute every frame.
    /// </summary>
    /// <param name="key">item key</param>
    /// <param name="duration">time over duration</param>
    /// <param name="l_timeCalcIntDelegate">delegate</param>
    /// <returns>is add succeed</returns>
    public bool AddFrameDelegateToTimeCalc(string key, float duration, DelegateHelper.FloatDelegate l_floatDelegate = null)
    {
        if (TimeCalc.ContainsKey(key))
        {
            Debug.LogError("Cannot add key:" + key + " to time calc cause key already exist.");
            return(false);
        }

        TimeCalc.m_timeCalcList.Add(new TimeCalc()
        {
            key = key, IsOverTime = true, StartTime = -1, OverTimeDuration = duration, m_TimeCalcFloatDelegate = l_floatDelegate, DelegateMode = 4
        });

        StartCalc(key);
        return(true);
    }
Esempio n. 7
0
 /// <summary>
 /// IsTimeCalcKeyExist
 /// </summary>
 /// <param name="key">item key</param>
 /// <returns>is key exist</returns>
 public bool IsTimeCalcKeyExist(string key)
 {
     return(TimeCalc.ContainsKey(key));
 }