Example #1
0
    //
    public void setCoolDownTimer(string name, int endTime, ValueChange valueChange, CoolDownEnd coolDownEnd)
    {
        Dictionary <string, object> timerDict = new Dictionary <string, object>();

        timerDict["endTime"]         = endTime;
        timerDict["valueChangeFunc"] = valueChange;
        timerDict["coolDownEndFunc"] = coolDownEnd;
        rigsterData[name]            = timerDict;
    }
Example #2
0
 private void chkTimer()
 {
     if (rigsterData.Count > 0)
     {
         foreach (KeyValuePair <string, Dictionary <string, object> > post_arg in rigsterData)
         {
             int         nowTime     = ((Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds);
             int         endTime     = (int)post_arg.Value["endTime"];
             ValueChange valueChange = (ValueChange)post_arg.Value["valueChangeFunc"];
             CoolDownEnd coolDownEnd = (CoolDownEnd)post_arg.Value["coolDownEndFunc"];
             //CoolDownEnd
             if (nowTime >= endTime)
             {
                 coolDownEnd(post_arg.Key);
                 //removeTimer(post_arg.Key);
                 return;
             }
             valueChange(endTime - nowTime, post_arg.Key);
         }
     }
 }