BattleScene.ZoneEvent.cs 1012 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using CommonLang;
  3. namespace CommonAIClient.Unity.Battle
  4. {
  5. public partial class BattleScene
  6. {
  7. private HashMap<Type, Action<CommonAI.Zone.ZoneEvent>> mZoneEvens = new HashMap<Type, Action<CommonAI.Zone.ZoneEvent>>();
  8. protected virtual void RegistAllZoneEvent()
  9. {
  10. RegistZoneEvent<CommonAI.Zone.AddEffectEvent>(ZoneEvent_AddEffectEvent);
  11. }
  12. protected void RegistZoneEvent<T>(Action<T> action) where T : CommonAI.Zone.ZoneEvent
  13. {
  14. Type type = typeof(T);
  15. Action<CommonAI.Zone.ZoneEvent> outVal = null;
  16. if (!mZoneEvens.TryGetValue(type, out outVal))
  17. {
  18. mZoneEvens.Add(type, (e) =>
  19. {
  20. action((T)e);
  21. });
  22. }
  23. }
  24. protected virtual void ZoneEvent_AddEffectEvent(CommonAI.Zone.AddEffectEvent ev)
  25. {
  26. PlayEffectWithZoneCoord(ev.effect, ev.x, ev.y, ev.direction);
  27. }
  28. }
  29. }