public void processEvent(EventObject eventObject) { int nID = eventObject.getEventType(); int num = nID; if (num != 10) { if (num == 57) { TimerEventObject timeEventObj = eventObject as TimerEventObject; if (null != timeEventObj) { this.OnTimer(timeEventObj); } } } else { PlayerDeadEventObject playerDeadEventObject = eventObject as PlayerDeadEventObject; if (playerDeadEventObject != null && null != playerDeadEventObject.getPlayer()) { this.OnRoleDead(playerDeadEventObject.getPlayer()); } } }
public void Remove(TimerEventObject obj) { if (null != obj) { obj.enable = 0; } }
public TimerEventObject Add(int start, int interval, TimerEventObject.TimerProc proc, object o, int p1, int p2) { TimerEventObject obj = new TimerEventObject(); obj.proc = proc; if (interval <= 0) { interval = 1; } obj.interval = interval; obj.obj = o; obj.p1 = p1; obj.p2 = p2; obj.enable = 1; obj.circle = (short)(start / socket_size_); int index = start % socket_size_ + socket_index_; if (index >= socket_size_) { index = index - socket_size_; } list_[index].AddTail(obj); return(obj); }
public void Clear() { for (int i = 0; i < socket_size_; i++) { PList head = list_[i]; for (PListNode pos = head.next; pos != head; pos = pos.next) { TimerEventObject obj = (TimerEventObject)pos; obj.enable = 0; obj.proc = null; obj.obj = null; } head.Init(); } }
public void Process() { PList head = list_[socket_index_]; int cur_index = socket_index_; socket_index_++; if (socket_index_ >= socket_size_) { socket_index_ = 0; } PListNode pos = null, n = null; for (pos = head.next, n = pos.next; pos != head; pos = n, n = pos.next) { TimerEventObject obj = (TimerEventObject)pos; if (obj.circle <= 0) { head.Remove(pos); if ((0 != obj.enable) && obj.proc(obj.obj, obj.p1, obj.p2)) { obj.circle = (short)(obj.interval / socket_size_); int index = obj.interval % socket_size_ + cur_index; if (index == cur_index) { obj.circle--; } if (index >= socket_size_) { index = index - socket_size_; } list_[index].Add(pos); } else { obj.proc = null; obj.obj = null; } } else { obj.circle--; } } }
public void OnTimer(TimerEventObject eventObj) { GameClient client = eventObj.Client; if (client.ClientData.CurrentArmorV < client.ClientData.ArmorV) { if (!client.buffManager.IsBuffEnabled(114)) { double rate = Global.Clamp((double)eventObj.DeltaTicks / 1000.0, 0.0, 5.0); int max = (int)RoleAlgorithm.GetExtProp(client, 119); int recover = (int)((double)max * RoleAlgorithm.GetExtProp(client, 121) * rate); client.ClientData.CurrentArmorV += recover; if (client.ClientData.CurrentArmorV > max) { client.ClientData.CurrentArmorV = max; } GameManager.ClientMgr.NotifyOthersLifeChanged(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, true, false, 4); } } }