/// <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; }
/// <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; }
/// <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); }
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); }
/// <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); }