From 89a2460de1ca95accc091e010301c15908899357 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Wed, 11 Jan 2023 23:42:41 +0800 Subject: [PATCH] =?UTF-8?q?HPMP=E5=8F=98=E5=8C=96=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomsComponent/BattleMgrComponent.cs | 2 ++ .../Event/BattleEvent/HPMPChangeEventArgs.cs | 32 +++++++++++++++++++ .../BattleEvent/HPMPChangeEventArgs.cs.meta | 11 +++++++ Assets/Scripts/Main/UI/MainUI/MainUI.cs | 17 ++++++++++ 4 files changed, 62 insertions(+) create mode 100644 Assets/Scripts/Main/Event/BattleEvent/HPMPChangeEventArgs.cs create mode 100644 Assets/Scripts/Main/Event/BattleEvent/HPMPChangeEventArgs.cs.meta diff --git a/Assets/Scripts/Main/CustomsComponent/BattleMgrComponent.cs b/Assets/Scripts/Main/CustomsComponent/BattleMgrComponent.cs index c0d0bb7..fc3e5b9 100644 --- a/Assets/Scripts/Main/CustomsComponent/BattleMgrComponent.cs +++ b/Assets/Scripts/Main/CustomsComponent/BattleMgrComponent.cs @@ -100,6 +100,8 @@ namespace Game UnderAttack.BaseData.life.curHP -= DamageHP; UnderAttack.BaseData.life.curHP = Math.Max(UnderAttack.BaseData.life.curHP, 0); + AppEntry.Event.Fire(null, HPMPChangeEventArgs.Create(UnderAttack.RoleType, UnderAttack.RoleID)); + if (UnderAttack.BaseData.life.curHP > 0) UnderAttack.Anime.PlayHit(); else diff --git a/Assets/Scripts/Main/Event/BattleEvent/HPMPChangeEventArgs.cs b/Assets/Scripts/Main/Event/BattleEvent/HPMPChangeEventArgs.cs new file mode 100644 index 0000000..f6a65d0 --- /dev/null +++ b/Assets/Scripts/Main/Event/BattleEvent/HPMPChangeEventArgs.cs @@ -0,0 +1,32 @@ +using Axibug; +using Axibug.Event; + +namespace Game +{ + public class HPMPChangeEventArgs : LogicEventArgs + { + public static readonly int EventId = typeof(HPMPChangeEventArgs).GetHashCode(); + + public E_NODE_TYPE roleType = E_NODE_TYPE.N_FREE; + public int RoleID = 0; + + /// + /// 获取加载数据表成功事件编号。 + /// + public override int Id { get { return EventId; } } + + public static HPMPChangeEventArgs Create(E_NODE_TYPE type,int roleID) + { + HPMPChangeEventArgs s = ReferencePool.Acquire(); + s.RoleID = roleID; + s.roleType = type; + return s; + } + + public override void Clear() + { + roleType = E_NODE_TYPE.N_FREE; + RoleID = 0; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Main/Event/BattleEvent/HPMPChangeEventArgs.cs.meta b/Assets/Scripts/Main/Event/BattleEvent/HPMPChangeEventArgs.cs.meta new file mode 100644 index 0000000..cfc0d5a --- /dev/null +++ b/Assets/Scripts/Main/Event/BattleEvent/HPMPChangeEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a03fb589092408848b244a23325483ad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Main/UI/MainUI/MainUI.cs b/Assets/Scripts/Main/UI/MainUI/MainUI.cs index 53c9a30..f457c0f 100644 --- a/Assets/Scripts/Main/UI/MainUI/MainUI.cs +++ b/Assets/Scripts/Main/UI/MainUI/MainUI.cs @@ -10,6 +10,8 @@ using UnityEngine.UI; using Game; using TMPro; using Axibug.Runtime; +using Axibug.Event; +using Axibug; namespace Game { @@ -43,6 +45,7 @@ namespace Game //UIAutoBuild_EventReg //UIAutoBuild_EventReg Reflush(); + AppEntry.Event.Subscribe(HPMPChangeEventArgs.EventId, OnHPMPChangeEventArgs); } void OnDisable() @@ -55,6 +58,20 @@ namespace Game { } + #region 浜嬩欢 + + private void OnHPMPChangeEventArgs(object sender, LogicEventArgs e) + { + HPMPChangeEventArgs msg = (HPMPChangeEventArgs)e; + if (msg == null) throw new GameException("OnHPMPChangeEventArgs is null"); + if (msg.RoleID == GamePlayEntry.MainPlayer.Player.RoleID) + { + Reflush(); + } + } + + #endregion + // 姣忔鏄剧ず閮芥墽琛, 鍙畾涔夊弬鏁 public override void Show(params object[] _params) {