BattleMgr.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. using CommonAI.Zone;
  2. using CommonAI.ZoneClient;
  3. using CommonLang;
  4. using CommonLang.Geometry;
  5. using ET.Client;
  6. using ET.EventType;
  7. using ET.Server;
  8. using Sirenix.Utilities;
  9. using System;
  10. using System.IO;
  11. using System.Linq;
  12. using XmdsCommon.Message;
  13. namespace ET
  14. {
  15. [FriendOf(typeof(UnitMgr))]
  16. public partial class BattleMgr : Singleton<BattleMgr>, ISingletonAwake, ISingletonUpdate, ILayerClient
  17. {
  18. public ZoneLayer Layer;
  19. private readonly MemoryStream writeBuffer = new MemoryStream(2048);
  20. private EventDispatcher<Event> eventHandler;
  21. private static CommonLang.Geometry.Vector3 vecTemp = new();
  22. private HashMap<int, BattleUnit> UnitTemplateIdHash = new();
  23. public void Awake()
  24. {
  25. eventHandler = new();
  26. //eventHandler = new();
  27. registerEventHandler();
  28. Layer = TemplateManager.Factory.CreateClientZoneLayer(BattleResourceMgr.Instance.GameEditorTemplates, this);
  29. Layer.ActorSyncMode = SyncMode.ForceByServer;
  30. Layer.LayerInit += LayerEvent_Init;
  31. Layer.ObjectEnter += LayerEvent_ObjectEnter;
  32. Layer.ObjectLeave += LayerEvent_ObjectLeave;
  33. Layer.MessageReceived += (ZoneLayer _, CommonLang.Protocol.IMessage msg) => {
  34. if (msg is SyncPosEvent || msg is UnitForceSyncPosEvent || msg is LaunchSkill || msg is AddSpellEvent || msg is RemoveObjectEvent || msg is AddUnitEvent || msg is PlayerFocuseTargetEvent || msg is UnitFieldChangedEvent || msg is UnitEffectEvent || msg is UnitLaunchSkillEvent || msg is PlayerSkillStopEvent || msg is UnitHitEvent)
  35. { }
  36. else
  37. {
  38. Log.Debug($"<<<BattleEvent: {msg}");
  39. }
  40. eventHandler.Notify(msg as Event);
  41. };
  42. Layer.DecorationChanged += (ZoneLayer _, ZoneEditorDecoration ed) => {
  43. Log.Error("not implements: DecorationChanged");
  44. };
  45. }
  46. public void Update(int timeMS)
  47. {
  48. //TODO: Send ping
  49. Layer.BeginUpdate(timeMS);
  50. Layer.Update();
  51. this.doUpdate();
  52. }
  53. //ILayerClient接口实现,供layer层调用
  54. //layer层在收到LockActorEvent消息后调用
  55. void ILayerClient.BattleReady(bool bok)
  56. {
  57. Log.Debug($"battle ready......{bok}");
  58. //TODO: 等GameObjectPool.cache完场景资源后,再play bgm
  59. var scnData = Layer.Data;
  60. if(!scnData.BGM.IsNullOrWhitespace() )
  61. {
  62. EventSystem.Instance.Publish<PlayBgm>(PlayBgm.Static.Clone(true, scnData.BGM));
  63. }
  64. }
  65. //ILayerClient接口实现,供layer层调用
  66. //layer层中需要发送消息到战斗服
  67. public void SendAction(CommonAI.Zone.Action action)
  68. {
  69. if(PlayerComponent.Instance == null)
  70. {
  71. Log.Error("playerComponent is null");
  72. return;
  73. }
  74. Log.Debug($">>>Send BattleMsg: {action.GetType()}");
  75. writeBuffer.Position = 0;
  76. if (BattleResourceMgr.Instance.BattleMsgDecoder.doEncode(writeBuffer, action))
  77. {
  78. PlayerComponent.Instance.ClientScene().GetComponent<SessionComponent>().Session.Send(new BattleEventPushToServer() { data = writeBuffer.ToArray() });
  79. }
  80. }
  81. //客户端自己模拟创建消息,发送到zonelayer层处理
  82. public void PostMsg2Layer(CommonLang.Protocol.IMessage msg)
  83. {
  84. Layer.ProcessMessage(msg);
  85. }
  86. //layer层在处理好战斗服推送的ClientEnterScene消息后回调
  87. protected void LayerEvent_Init(CommonAI.ZoneClient.ZoneLayer layer)
  88. {
  89. Log.Debug($"OnLayerInit- scene template ID:{layer.Data.ID}");
  90. }
  91. //单位进入战斗
  92. protected void LayerEvent_ObjectEnter(ZoneLayer layer, ZoneObject obj)
  93. {
  94. //Log.Debug($"OnObjectEnter: {obj}@{obj.ObjectID}");
  95. var unit = BattleUnitFactory.Instance.Create(obj);
  96. if(unit != null )
  97. {
  98. UnitMgr.Instance.PutUnit(obj.ObjectID, unit);
  99. if (unit is BattleActor)
  100. {
  101. UnitMgr.Instance.Actor = unit as BattleActor;
  102. }
  103. unit.OnAwake(obj);
  104. if (unit is BattleUnit bu)
  105. {
  106. var tid = (obj as ZoneUnit).TemplateID;
  107. if (ConstGame.TowerTemplateIDs.Contains(tid))
  108. {
  109. if (UnitTemplateIdHash.ContainsKey((tid)))
  110. {
  111. Log.Error($"Already exist unit({tid}) @{obj.ObjectID}");
  112. return;
  113. }
  114. UnitTemplateIdHash.Add(tid, bu);
  115. }
  116. }
  117. }
  118. else
  119. {
  120. Log.Error($"unknow object enter:{obj.Name} ID:{obj.ObjectID}");
  121. }
  122. }
  123. //单位离开战斗
  124. protected void LayerEvent_ObjectLeave(ZoneLayer layer, ZoneObject obj)
  125. {
  126. //Log.Debug($"OnObjectLeave: {obj.ObjectID}");
  127. var unit = UnitMgr.Instance.GetUnit(obj.ObjectID);
  128. if(unit == null)
  129. {
  130. Log.Error($"LayerEvent_ObjectLeave not exist:{obj.Name}:{obj.ObjectID}");
  131. return;
  132. }
  133. unit.OnSleep();
  134. UnitMgr.Instance.RemoveUnit(obj.ObjectID);
  135. if (unit is BattleUnit bu)
  136. {
  137. UnitTemplateIdHash.Remove(bu.ZUnit.TemplateID);
  138. }
  139. }
  140. public BattleUnit GetUnitByTemplateID(int tid)
  141. {
  142. return UnitTemplateIdHash.ContainsKey(tid) ? UnitTemplateIdHash[tid] : null;
  143. }
  144. private void registerEventHandler()
  145. {
  146. //actor===================
  147. eventHandler.AddListener<SetAutoBattleB2C>((ev) => {
  148. var isAutoFight = (ev as SetAutoBattleB2C).isAutoBattle != 0;
  149. Log.Debug($"AutoFight: {isAutoFight}");
  150. (UnitMgr.Instance.Actor.ZUnit as ZoneActor).IsGuard = isAutoFight;
  151. });
  152. eventHandler.AddListener<PlayerFocuseTargetEvent>((ev) =>
  153. {
  154. });
  155. eventHandler.AddListener<ShowTipsEventB2C>((ev) =>
  156. {
  157. });
  158. eventHandler.AddListener<UnitDeadEvent>((ev) =>
  159. {
  160. var e = ev as UnitDeadEvent;
  161. Log.Debug($"Unit({e.object_id}) dead");
  162. EventSystem.Instance.Publish<PlayAnimatorEvent>(PlayAnimatorEvent.Static.Clone(
  163. e.ObjectID, AnimatorEventType.Dead));
  164. var unit = UnitMgr.Instance.GetUnit(e.ObjectID);
  165. if(unit != null && unit is BattleUnit bunit)
  166. {
  167. var launcheffect = bunit.ZUnit.Info.DeadActionEffect;
  168. if (launcheffect != null)
  169. {
  170. EventSystem.Instance.Publish<PlayEffectEvent>(PlayEffectEvent.Static.Clone(launcheffect, unit.Id, CommonLang.Geometry.Vector3.Zero));
  171. }
  172. }
  173. //TODO: 过几秒后,自行清理尸体
  174. });
  175. eventHandler.AddListener<UnitRebirthEvent>((ev) =>
  176. {
  177. });
  178. eventHandler.AddListener<UnitHitEvent>((ev) =>
  179. {
  180. var e = ev as UnitHitEvent;
  181. var unit = UnitMgr.Instance.GetUnit(e.ObjectID);
  182. if(unit == null)
  183. {
  184. Log.Warning($"Ignore unit({e.ObjectID}) on hit, not exist?");
  185. return;
  186. }
  187. if (e.dmgSrc == CommonAI.Data.DamageSource.RemedyPoison)
  188. {
  189. //伤害来源于叠毒BUFF
  190. e.client_state = (byte)UnitHitEventState.PoisonBuff;
  191. }
  192. //TODO: 显示伤害飘字
  193. LaunchEffect hitEffect = e.effect;
  194. if (hitEffect != null)
  195. {
  196. float roation = 0f;
  197. if (hitEffect.IsSyncSenderRotation)
  198. {
  199. //设置特效的rotation为施法者与受击连线方向的rotation
  200. var sender = UnitMgr.Instance.GetUnit(e.senderId);
  201. if (sender != null)
  202. {
  203. Vector3 difpos = new Vector3(unit.ZoneObject.X, unit.ZoneObject.Y, 0) - new Vector3(sender.ZoneObject.X, sender.ZoneObject.Y, 0);
  204. roation = (float)-Math.Atan2(-difpos.Y, difpos.X);
  205. }
  206. }
  207. if (hitEffect.BindBody)
  208. {
  209. vecTemp.Set(0, 0, 0);
  210. }
  211. else
  212. {
  213. vecTemp.Set(unit.ZoneObject.X, unit.ZoneObject.Y, unit.ZoneObject.Z);
  214. }
  215. EventSystem.Instance.Publish<PlayEffectEvent>(PlayEffectEvent.Static.Clone(hitEffect, e.ObjectID, vecTemp, 0, roation));
  216. }
  217. });
  218. eventHandler.AddListener<PlayerPKModeChangeEventB2C>((ev) =>
  219. {
  220. //TODO:替代virtual层
  221. var e = ev as PlayerPKModeChangeEventB2C;
  222. Log.Debug($"PKMode: {e.CurMode}");
  223. });
  224. eventHandler.AddListener<PlayerBattlePropChangeEventB2C>((ev) =>
  225. {
  226. });
  227. eventHandler.AddListener<PlayerPKValueChangeEventB2C>((ev) =>
  228. {
  229. });
  230. eventHandler.AddListener<BuffActiveSkillEventB2C>((ev) =>
  231. {
  232. });
  233. eventHandler.AddListener<UnitEffectEvent>((ev) =>
  234. {
  235. var e = ev as UnitEffectEvent;
  236. vecTemp.Set(0,0,0);
  237. var unit = UnitMgr.Instance.GetUnit(e.object_id);
  238. if (unit != null && !e.effect.BindBody)
  239. {
  240. vecTemp.Set(unit.ZoneObject.X, unit.ZoneObject.Y, unit.ZoneObject.Z);
  241. }
  242. EventSystem.Instance.Publish(PlayEffectEvent.Static.Clone(e.effect, e.ObjectID, vecTemp));
  243. });
  244. eventHandler.AddListener<XmdsUnitPropEventB2C>((ev) =>
  245. {
  246. });
  247. //NPCCureEventB2C
  248. //MonsterSufferDamageInfoB2C
  249. //BattleHintNumberB2C
  250. //BattleFloatTipsEventB2C
  251. //BubbleTipsEventB2C
  252. //怪物归属权
  253. //MonsterHeirInfoChangeEventB2C
  254. eventHandler.AddListener<GameOverEvent>((ev) =>
  255. {
  256. var e = ev as GameOverEvent;
  257. EventSystem.Instance.Publish(GameoverEvent.Static.Clone(e.WinForce));
  258. });
  259. eventHandler.AddListener<CameraMoveToEvent>((ev) =>
  260. {
  261. var e = ev as CameraMoveToEvent;
  262. EventSystem.Instance.Publish(CameraEvent.Static.Clone(e.x, e.height, e.y, e.TimeMS, e.MoveSpeedSec));
  263. });
  264. eventHandler.AddListener<AddEffectEvent>((ev) => {
  265. var e = ev as AddEffectEvent;
  266. if(e.hostId == 0 || UnitMgr.Instance.HasUnit(e.hostId))
  267. {
  268. vecTemp.Set(e.x, e.y, 0);
  269. EventSystem.Instance.Publish(PlayEffectEvent.Static.Clone(e.effect, e.hostId, vecTemp));
  270. }
  271. });
  272. eventHandler.AddListener<ClientMsgEvent>((ev) =>
  273. {
  274. var e = ev as ClientMsgEvent;
  275. Log.Debug($">>>Battle client event: {e.Message}");
  276. });
  277. /*BubbleTalkEvent
  278. AddEffectEvent
  279. SyncEnvironmentVarEvent
  280. ScriptCommandEvent
  281. ScriptAddUnitEventsB2C
  282. ScriptRemoveUnitEventsB2C
  283. PlaySoundEventB2CForAll
  284. SyncFlagsEvent
  285. ChangeBGMEvent
  286. PlayDestoryEffect*/
  287. /*var e = msg as CommonAI.Zone.Event;
  288. if (e is ChatEvent)
  289. {
  290. var evt = (e as ChatEvent);
  291. var message = evt.Message;
  292. var evt_param = message.Split('|');
  293. if (evt_param.Length >= 2 && evt_param[0] == "Notice.Msg")
  294. {
  295. var dic = GameUtil.GetDBData("NoticeMsg", int.Parse(evt_param[1]));
  296. if (dic != null)
  297. {
  298. string result = "";
  299. if (evt_param.Length >= 3 && evt_param[2] != null)
  300. {
  301. //根据参数个数 依次填值
  302. string[] par = evt_param[2].Split('.');
  303. if (par != null && par.Length > 0)
  304. {
  305. switch (par.Length)
  306. {
  307. case 1:
  308. {
  309. result = Average(dic["MsgContent"] as string, par[0]);
  310. break;
  311. }
  312. case 2:
  313. {
  314. result = Average(dic["MsgContent"] as string, par[0], par[1]);
  315. break;
  316. }
  317. case 3:
  318. {
  319. result = Average(dic["MsgContent"] as string, par[0], par[1], par[2]);
  320. break;
  321. }
  322. case 4:
  323. {
  324. result = Average(dic["MsgContent"] as string, par[0], par[1], par[2], par[3]);
  325. break;
  326. }
  327. case 5:
  328. {
  329. result = Average(dic["MsgContent"] as string, par[0], par[1], par[2], par[3], par[4]);
  330. break;
  331. }
  332. }
  333. }
  334. }
  335. else
  336. {
  337. //没有参数
  338. result = (dic["MsgContent"] as string);
  339. }
  340. //
  341. EventManager.Fire("Event.OnEventHandler.star", new Dictionary<string, string>() {
  342. {"content", result}, {"keepTime", "" + (evt.KeepTimeMS/1000)}, {"content_is_text", "true"}
  343. });
  344. }
  345. else
  346. {
  347. YXJDebug.logError("config not exist >" + msg);
  348. }
  349. }
  350. else if (evt_param.Length == 2)
  351. {
  352. string funcName = "GlobalHooks." + evt_param[0];
  353. object[] param = evt_param[1].Split(',');
  354. //Client.GetMainState().GetFunction(funcName).LazyCall(param);
  355. if (param.Length == 0)
  356. Client.GetMainState().Call(funcName, Client.LogMiss);
  357. else if (param.Length == 1)
  358. Client.GetMainState().Call(funcName, param[0], Client.LogMiss);
  359. else if (param.Length == 2)
  360. Client.GetMainState().Call(funcName, param[0], param[1], Client.LogMiss);
  361. else if (param.Length == 3)
  362. Client.GetMainState().Call(funcName, param[0], param[1], param[2], Client.LogMiss);
  363. else if (param.Length == 4)
  364. Client.GetMainState().Call(funcName, param[0], param[1], param[2], param[3], Client.LogMiss);
  365. else if (param.Length == 5)
  366. Client.GetMainState().Call(funcName, param[0], param[1], param[2], param[3], param[4], Client.LogMiss);
  367. else
  368. {
  369. YXJDebug.logError("BattleClientBase.OnEventHandler Error!funcName is {0}", funcName);
  370. }
  371. }
  372. else
  373. {
  374. //位面进入退出效果
  375. if (msg == "EnterAOI")
  376. {
  377. var wwe = Camera.main.GetComponent<WaterWaveEffect>();
  378. if (wwe != null)
  379. {
  380. wwe.SetParam(40, -30, 3, 2);
  381. wwe.play();
  382. }
  383. //GameAlertManager.Instance.setAutoAnimiVisible(false);
  384. InAOI = true;
  385. }
  386. else if (msg == "LeaveAOI")
  387. {
  388. var wwe = Camera.main.GetComponent<WaterWaveEffect>();
  389. if (wwe != null)
  390. {
  391. wwe.SetParam(40, -30, 3, 2);
  392. wwe.play();
  393. }
  394. InAOI = false;
  395. }
  396. else
  397. {
  398. //普通chatevent
  399. EventManager.Fire("Event.OnEventHandler.star", new Dictionary<string, string>() {
  400. {"content", msg}, {"isImportant", "1"}, {"keepTime", "" + (evt.KeepTimeMS/1000)}
  401. });
  402. }
  403. }
  404. }
  405. else if (e is CommonAI.Zone.ZoneEvent)
  406. {
  407. if (e is BubbleTalkEvent)
  408. {
  409. BubbleTalkEvent evt = e as BubbleTalkEvent;
  410. if (evt.TalkInfos != null)
  411. {
  412. foreach (var info in evt.TalkInfos)
  413. {
  414. System.Action callback = delegate ()
  415. {
  416. if (info.TalkUnit == 0)
  417. {
  418. YXJDebug.logError("旁白气泡还没有实现>{0}", info.TalkContent);
  419. return;
  420. }
  421. ComAIUnit unit = GetUnitById(info.TalkUnit) as ComAIUnit;
  422. if (unit == null)
  423. {
  424. if (info.TalkContent != "bubblechat")
  425. {
  426. YXJDebug.logDebug(">BubbleTalkEvent unit not exist: {0}>>{1}", info.TalkUnit, info.TalkContent);
  427. }
  428. return;
  429. }
  430. if (info.TalkContent == "bubblechat")
  431. {
  432. UIBridgeManager.Instance.QuestUIBridge.BubbleTalkEventSend(unit);
  433. }
  434. else
  435. {
  436. var txt = ConfigMgr.Instance.TxtCfg.GetTextByKey("GameEditor_" + info.TalkContent);
  437. unit.AddBubbleChat(txt, info.TalkKeepTimeMS / 1000);
  438. }
  439. if (!string.IsNullOrEmpty(info.TalkActionType))
  440. {
  441. unit.PlayAnimationWhileIdle(info.TalkActionType);
  442. }
  443. };
  444. if (info.TalkDelayTimeMS > 0)
  445. {
  446. GameGlobal.Instance.StartCoroutine(WaitForSeconds(info.TalkDelayTimeMS / 1000, callback));
  447. }
  448. else
  449. {
  450. callback.Invoke();
  451. }
  452. }
  453. }
  454. }
  455. else if (e is AddEffectEvent && battleManager != null)
  456. {
  457. AddEffectEvent evt = e as AddEffectEvent;
  458. if (evt.hostId == 0 || GetUnitById(evt.hostId) != null)
  459. {
  460. Vector3 pos = battleManager.GetU3DPosByUnitCell(evt.x, evt.y);
  461. pos = ComAICell.AdjustHeight(pos);
  462. Quaternion rotation = Quaternion.Euler(0, evt.direction * Mathf.Rad2Deg + 90, 0);
  463. EffectPlayer.SetRotationOnetime(rotation); //--->这个功能加个参数不就好了 →_→
  464. EffectPlayer.Play(evt.effect, pos, false);
  465. }
  466. }
  467. else if (e is AddEffectEvent2 && battleManager != null)
  468. {
  469. AddEffectEvent2 evt = e as AddEffectEvent2;
  470. if (evt.hostId == 0 || GetUnitById(evt.hostId) != null)
  471. {
  472. Vector3 pos = battleManager.GetU3DPosByUnitCell(evt.x, evt.y);
  473. pos = ComAICell.AdjustHeight(pos);
  474. Vector3 targetPos = battleManager.GetU3DPosByUnitCell(evt.TargetX, evt.TargetY);
  475. EffectPlayer.PlayLocal(evt.effect, pos, false, 0, 0, 0, 0, evt.ET, targetPos, evt.FollowActor);
  476. }
  477. }
  478. else if (e is SyncEnvironmentVarEvent)
  479. {
  480. SyncEnvironmentVarEvent evt = e as SyncEnvironmentVarEvent;
  481. UIBridgeManager.Instance.BattleUIBridge.EnvironmentVarChange(evt.Key, evt.Value);
  482. }
  483. else if (e is ScriptCommandEvent)
  484. {
  485. ScriptCommandEvent evt = e as ScriptCommandEvent;
  486. string[] evt_param = evt.message.Split('|');
  487. if (evt_param.Length == 2)
  488. {
  489. object[] param = evt_param[1].Split(',');
  490. string funcName = "GlobalHooks." + evt_param[0];
  491. if (param.Length == 0)
  492. Client.GetMainState().Call(funcName, Client.LogMiss);
  493. else if (param.Length == 1)
  494. Client.GetMainState().Call(funcName, param[0], Client.LogMiss);
  495. else if (param.Length == 2)
  496. Client.GetMainState().Call(funcName, param[0], param[1], Client.LogMiss);
  497. else if (param.Length == 3)
  498. Client.GetMainState().Call(funcName, param[0], param[1], param[2], Client.LogMiss);
  499. else if (param.Length == 4)
  500. Client.GetMainState().Call(funcName, param[0], param[1], param[2], param[3], Client.LogMiss);
  501. else if (param.Length == 5)
  502. Client.GetMainState().Call(funcName, param[0], param[1], param[2], param[3], param[4], Client.LogMiss);
  503. else
  504. {
  505. YXJDebug.logError("BattleClientBase.OnEventHandler Error!funcName is {0}", funcName);
  506. }
  507. }
  508. }
  509. else if (e is LockActorEvent)
  510. {
  511. LockActorEvent evt = e as LockActorEvent;
  512. OnLockActorEvent(evt);
  513. }
  514. else if (e is ScriptAddUnitEventsB2C)
  515. {
  516. ScriptAddUnitEventsB2C evt = e as ScriptAddUnitEventsB2C;
  517. OnScriptAddUnitEvent(evt);
  518. }
  519. else if (e is ScriptRemoveUnitEventsB2C)
  520. {
  521. ScriptRemoveUnitEventsB2C evt = e as ScriptRemoveUnitEventsB2C;
  522. OnScriptRemoveUnitEvents(evt);
  523. }
  524. else if (e is PlaySoundEventB2CForAll)
  525. {
  526. PlaySoundEventB2CForAll evt = e as PlaySoundEventB2CForAll;
  527. XmdsSoundManager.GetXmdsInstance().PlaySound(evt.SoundName);
  528. }
  529. else if (e is SyncFlagsEvent && mDecoMgr != null)
  530. {
  531. mDecoMgr.LoadDecos();
  532. }
  533. else if (e is ChangeBGMEvent)
  534. {
  535. XmdsSoundManager.GetXmdsInstance().ChangeBGM((e as ChangeBGMEvent).FileName);
  536. }
  537. else if (e is PlayDestoryEffect)
  538. {
  539. if (EffectPlayer == null) return;
  540. PlayDestoryEffect destoryEffect = e as PlayDestoryEffect;
  541. Vector3 vec = new Vector3(destoryEffect.X, destoryEffect.Y, destoryEffect.Z);
  542. Quaternion rotation = Quaternion.Euler(0, destoryEffect.Direction * Mathf.Rad2Deg + 90, 0);
  543. LaunchEffect effect = new LaunchEffect();
  544. effect.Name = destoryEffect.EffectName;
  545. EffectPlayer.SetRotationOnetime(rotation);
  546. EffectPlayer.Play(effect, vec, true);
  547. }
  548. else
  549. {
  550. //YXJDebug.logInfo("OnEventHandler not implemented! {0}", e.ToString());
  551. }
  552. }*/
  553. }
  554. }
  555. }