BattleMgr_Update.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using CommonAI.Zone;
  2. using CommonAI.ZoneClient;
  3. using CommonLang.Geometry;
  4. using ET.Client;
  5. using ET.EventType;
  6. using System;
  7. namespace ET
  8. {
  9. //战斗中,每一帧要干的活
  10. public partial class BattleMgr
  11. {
  12. public void doUpdate()
  13. {
  14. SyncUnitPos();
  15. }
  16. private Vector3 VecTmp = new Vector3();
  17. private void SyncUnitPos()
  18. {
  19. if (UnitMgr.Instance != null)
  20. {
  21. foreach (var obj in UnitMgr.Instance.AllUnits)
  22. {
  23. if (obj is BattleUnit || obj is BattleSpell)
  24. {
  25. /*if(obj is BattleSpell spell)
  26. {
  27. var zs = spell.ZoneSpell;
  28. if (zs.Info.MType == CommonAI.Zone.SpellTemplate.MotionType.Foxfire)
  29. {
  30. if(zs.Target.ObjectID == 0 || zs.PassTimeMS > zs.Info.LifeTimeMS + 5000)
  31. {
  32. PostMsg2Layer(new RemoveObjectEvent(zs.ObjectID));
  33. return;
  34. }
  35. }
  36. else if(zs.PassTimeMS > zs.Info.LifeTimeMS + 150)
  37. {
  38. PostMsg2Layer(new RemoveObjectEvent(zs.ObjectID));
  39. return;
  40. }
  41. }*/
  42. var zo = obj.ZoneObject;
  43. VecTmp.Set(zo.X, zo.Y, zo.Z);
  44. if (!VecTmp.Equal(obj.LastPos, 0.01f) || MathF.Abs(obj.LastRotation - zo.Direction) > 0.01f)
  45. {
  46. EventSystem.Instance.Publish<SyncUnitPosEvent>(SyncUnitPosEvent.Static.Clone(zo.ObjectID, VecTmp, zo.Direction));
  47. obj.LastPos.Set(VecTmp);
  48. obj.LastRotation = zo.Direction;
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }