123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using CommonAI.Zone;
- using CommonAI.ZoneClient;
- using CommonLang.Geometry;
- using ET.Client;
- using ET.EventType;
- using System;
- namespace ET
- {
- //战斗中,每一帧要干的活
- public partial class BattleMgr
- {
- public void doUpdate()
- {
- SyncUnitPos();
- }
- private Vector3 VecTmp = new Vector3();
- private void SyncUnitPos()
- {
- if (UnitMgr.Instance != null)
- {
- foreach (var obj in UnitMgr.Instance.AllUnits)
- {
- if (obj is BattleUnit)
- {
- var zo = obj.ZoneObject;
- VecTmp.Set(zo.X, zo.Y, zo.Z);
- if (!VecTmp.Equal(obj.LastPos, 0.01f) || MathF.Abs(obj.LastRotation - zo.Direction) > 0.01f)
- {
- EventSystem.Instance.Publish<SyncUnitPosEvent>(SyncUnitPosEvent.Static.Clone(zo.ObjectID, VecTmp, zo.Direction));
- obj.LastPos.Set(VecTmp);
- obj.LastRotation = zo.Direction;
- }
- }
- else if(obj is BattleSpell)
- {
- var zs = obj.ZoneObject as ZoneSpell;
- /*
- if (zs.Info.MType == CommonAI.Zone.SpellTemplate.MotionType.Foxfire)
- {
- if (zs.Target.ObjectID == 0 || zs.PassTimeMS > zs.Info.LifeTimeMS + 5000)
- {
- PostMsg2Layer(new RemoveObjectEvent(zs.ObjectID));
- return;
- }
- }
- else if (zs.PassTimeMS > zs.Info.LifeTimeMS + 150)
- {
- PostMsg2Layer(new RemoveObjectEvent(zs.ObjectID));
- return;
- }*/
- VecTmp.Set(zs.X, zs.Y, zs.Z);
- if (!VecTmp.Equal(obj.LastPos, 0.01f) || MathF.Abs(obj.LastRotation - zs.Direction) > 0.01f)
- {
- EventSystem.Instance.Publish<SyncUnitPosEvent>(SyncUnitPosEvent.Static.Clone(zs.ObjectID, VecTmp, zs.Direction, zs.RotationX));
- obj.LastPos.Set(VecTmp);
- obj.LastRotation = zs.Direction;
- }
- }
- }
- }
- }
- }
- }
|