public void Update(IEventArgs args) { foreach (string key in currentBufs.Keys) { List <EffectBuf> list = currentBufs[key]; for (int i = list.Count - 1; i >= 0; i--) { if (args.Rule.ServerTime - list[i].startTime > list[i].time && list[i].time > 0) { list.Remove(list[i]); } } } float[] effects = new float[lastEffects.Length]; foreach (string key in currentBufs.Keys) { List <EffectBuf> list = currentBufs[key]; if (list.Count > 0) { EffectBuf buf = currentBufs[key][0]; effects[(int)buf.type] += buf.level; } } for (int i = 0; i < effects.Length; i++) { float last = lastEffects[i]; float current = effects[i]; if (last != current) { SimpleProto sp = null; switch ((EffectType)i) { case EffectType.SpeedUp: player.stateInterface.State.SetSpeedAffect(current); sp = FreePool.Allocate(); sp.Key = FreeMessageConstant.PlayerMoveSpeedSet; sp.Fs.Add(current); FreeMessageSender.SendMessage(player, sp); break; case EffectType.SlowDown: player.stateInterface.State.SetSpeedAffect(current * -1); sp = FreePool.Allocate(); sp.Key = FreeMessageConstant.PlayerMoveSpeedSet; sp.Fs.Add(current * -1); FreeMessageSender.SendMessage(player, sp); break; default: break; } } } lastEffects = effects; }
public void AddEffect(string effect, float level, int time, IEventArgs args) { EffectBuf buf = bufs[effect].Clone(args); buf.level = level; buf.time = time; if (!currentBufs.ContainsKey(effect)) { currentBufs.Add(effect, new List <EffectBuf>()); } EffectBuf removed = null; foreach (EffectBuf eb in currentBufs[effect]) { if (eb.level == level) { removed = eb; break; } } if (removed != null) { currentBufs[effect].Remove(removed); } currentBufs[effect].Add(buf); currentBufs[effect].Sort(); }
public override void DoAction(IEventArgs args) { EffectBuf buf = new EffectBuf(); buf.key = args.GetString(key); buf.type = (EffectType)effectType; PlayerEffectBuf.RegisterEffectBuf(buf); }
public static void RegisterEffectBuf(EffectBuf buf) { if (bufs.ContainsKey(buf.key)) { bufs.Remove(buf.key); } bufs.Add(buf.key, buf); }
public void RemoveEffect(string effect, float level) { if (currentBufs.ContainsKey(effect)) { EffectBuf removed = null; foreach (EffectBuf buf in currentBufs[effect]) { if (buf.level == level) { removed = buf; } } currentBufs[effect].Remove(removed); } }