示例#1
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;
    }
示例#2
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;
    }
示例#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);
    }
示例#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);
    }
示例#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);
    }