瀏覽代碼

修复头顶血条值未实时变动
修复启动时的更新检测UI资源未释放的问题

大爷 1 年之前
父節點
當前提交
255ef0f3e4

二進制
Unity/Assets/Res/CodeDll/Hotfix.dll.bytes


二進制
Unity/Assets/Res/CodeDll/Hotfix.pdb.bytes


二進制
Unity/Assets/Res/CodeDll/Model.dll.bytes


二進制
Unity/Assets/Res/CodeDll/Model.pdb.bytes


二進制
Unity/Assets/Res/CodeDll/Unity.Mono.dll.bytes


二進制
Unity/Assets/Res/CodeDll/Unity.Mono.pdb.bytes


+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Client/battle/BattleMgr_Update.cs

@@ -28,7 +28,7 @@ namespace ET
                         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));
+                            EventSystem.Instance.Publish<SyncUnitPosEvent>(SyncUnitPosEvent.Clone(zo.ObjectID, VecTmp, zo.Direction));
                             obj.LastPos.Set(VecTmp);
                             obj.LastRotation = zo.Direction;
                         }
@@ -53,7 +53,7 @@ namespace ET
                         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));
+                            EventSystem.Instance.Publish(SyncUnitPosEvent.Clone(zs.ObjectID, VecTmp, zs.Direction, zs.RotationX));
                             obj.LastPos.Set(VecTmp);
                             obj.LastRotation = zs.Direction;
                         }

+ 5 - 4
Unity/Assets/Scripts/Codes/Hotfix/Client/battle/unit/BattleUnit.cs

@@ -133,25 +133,26 @@ public class BattleUnit : BattleObject
 
     private void OnHPChanged()
     {
+        var hp = ZUnit.HP;
+        var pg = hp * 100f / ZUnit.MaxHP;
+
         if (ZUnit.Info.Properties is XmdsUnitProperties prop)
         {
             if (prop.GameStatusType == XmdsUnitProperties.StatusType.SpecialElite)
             {
-                var hp = ZUnit.HP;
-                var pg = (float)ZUnit.HP * 100 / ZUnit.MaxHP;
                 EventSystem.Instance.Publish<HPRefresh>(HPRefresh.Static.Clone(HPRefresh.Index.Tower, pg, hp));
                 //Log.Debug($"tower({ZUnit.ObjectID}@{ZUnit.Info.Name}) hp: {ZUnit.HP}/{ZUnit.MaxHP}");
 
             }
             else if (prop.GameStatusType == XmdsUnitProperties.StatusType.SpecialBoss)
             {
-                var hp = ZUnit.HP;
-                var pg = (float)ZUnit.HP * 100 / ZUnit.MaxHP;
                 EventSystem.Instance.Publish<HPRefresh>(HPRefresh.Static.Clone(HPRefresh.Index.Boss, pg, hp));
                 //Log.Debug($"Boss({ZUnit.ObjectID}) hp: {ZUnit.HP}/{ZUnit.MaxHP}");
             }
         }
         //Log.Debug($"hp({ZUnit.ObjectID}) change: {ZUnit.HP}");
+
+        EventSystem.Instance.Publish(SyncUnitHpEvent.Clone(Id, pg));
     }
 
     protected virtual void OnActionChanged(ZoneUnit unit, UnitActionStatus status, object evt)

+ 0 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Camera/CameraMgr.cs

@@ -21,7 +21,6 @@ namespace ET.Client
         {
             protected override async ETTask OnEvent(SceneLoadFinish a)
             {
-                GRoot.inst.RemoveChildren();
                 var playable = MainCamera.GetComponent<PlayableDirector>();
                 if (playable != null)
                 {

+ 9 - 6
Unity/Assets/Scripts/Codes/HotfixView/Client/Global/GlobalViewMgr.cs

@@ -21,13 +21,16 @@ namespace ET.Client
 
             BattleCamera = GameObject.Find( "/Global/BattleCamera" ).GetComponent<Camera>();
             CameraMgr.Init();
-            //self.UICamera = GameObject.Find("/Global/UICamera").GetComponent<Camera>();
 
-            /*var uiContentScale = self.Global.GetComponent<UIContentScaler>();
-            uiContentScale.scaleMode = UIContentScaler.ScaleMode.ScaleWithScreenSize;
-            uiContentScale.designResolutionX = 1600;
-            uiContentScale.designResolutionY = 2500;
-            uiContentScale.screenMatchMode = UIContentScaler.ScreenMatchMode.MatchWidthOrHeight;*/
+            CreateHeadBar().Coroutine();
+        }
+
+        private async ETTask CreateHeadBar()
+        {
+            //加入所有headbar的parent view
+            var root = await UIHelper.Create("HeadBar", "HeadBarRoot", 0);
+            HeadbarView = root;
+            root.visible = false;
         }
     }
 }

+ 1 - 11
Unity/Assets/Scripts/Codes/HotfixView/Client/Scene/GameObjectPool.cs

@@ -359,17 +359,7 @@ namespace ET.Client
                 return ret;
             }
 
-            var root = GlobalViewMgr.Instance.HeadbarView;
-            if (root == null)
-            {
-                //加入所有headbar的parent view
-                root = await UIHelper.Create("HeadBar", "HeadBarRoot", 0);
-                GlobalViewMgr.Instance.HeadbarView = root;
-                root.visible = false;
-            }
-
-            var view = await UIHelper.Create("HeadBar", "normalbar", -1, root);
-            return view;
+            return await UIHelper.Create("HeadBar", "normalbar", -1, GlobalViewMgr.Instance.HeadbarView);
         }
 
         public void RecycleHeadBar(GComponent view)

+ 2 - 2
Unity/Assets/Scripts/Codes/HotfixView/Client/UI/UILogin/ShowLoginUIEventHandle.cs

@@ -19,8 +19,8 @@ namespace ET.Client
             var view = await UIHelper.Create( "Login" );
             InitLogin( view );
 
-            var preView = GRoot.inst.GetChildAt( 0 );
-            GRoot.inst.RemoveChild( preView, true );
+            var preView = GRoot.inst.GetChild("CheckForResUpdate");
+            if(preView != null) GRoot.inst.RemoveChild( preView, true );
             UIPackage.RemovePackage( "CheckForResUpdate" );
         }
 

+ 2 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Unit/OnNewZoneObject.cs

@@ -53,7 +53,7 @@ namespace ET.Client
             go.transform.rotation = RenderUtils.UnityRotationFromBattle(zu.Direction);
 
             var render = ModelViewComponent.Instance.AddChildWithId<UnitRenderComponet, GameObject>(unit.Id, go, true);
-            CreateHeadbar(render, zu).Coroutine();
+            await CreateHeadbar(render, zu);
             if (unit is BattleActor)
             {
                 CameraMgr.FollowMe(go.transform.position);
@@ -125,6 +125,7 @@ namespace ET.Client
             var progresshp = view.GetChild("bar_hp") as GProgressBar;
             progresshp.max = 100;
             progresshp.min = 0;
+            render.HPBar = progresshp;
 
             name.text = render.GameObject.name;
             progresshp.value = zu.HP * 100 / zu.MaxHP;

+ 30 - 0
Unity/Assets/Scripts/Codes/HotfixView/Client/Unit/UnitRenderSystem.cs

@@ -98,6 +98,22 @@ namespace ET.Client
             //StartSeek(p.X, p.Y, 0, null, false);
         }
     }
+    [Event]
+    public class SyncUnitHpEventHandler : BEvent<EventType.SyncUnitHpEvent>
+    {
+        protected override async ETTask OnEvent(SyncUnitHpEvent args)
+        {
+            if (GlobalViewMgr.Instance.HeadbarView.visible)
+            {
+                var unitRender = ModelViewComponent.Instance.GetChild<UnitRenderComponet>(args.Id);
+                if (unitRender != null)
+                {
+                    unitRender.SyncHeadBarHP(args.Value);
+                }
+            }
+            await ETTask.CompletedTask;
+        }
+    }
 
     [FriendOf(typeof(UnitRenderComponet))]
     public static class UnitRenerSystem
@@ -176,6 +192,20 @@ namespace ET.Client
                 }
             }
         }
+        public static void SyncHeadBarHP(this UnitRenderComponet self, float value, bool bTween = false)
+        {
+            if (self.HPBar != null)
+            {
+                if (bTween)
+                {
+                    self.HPBar.TweenValue(value, 0.6f);
+                }
+                else
+                {
+                    self.HPBar.value = value;
+                }
+            }
+        }
         public static void PauseAnimation(this UnitRenderComponet self)
         {
             self.AniData.Pause();

+ 1 - 0
Unity/Assets/Scripts/Codes/ModelView/Client/Unit/UnitRenderComponet.cs

@@ -25,6 +25,7 @@ namespace ET.Client
         public IceFrozen FrozenComponent;
         public AnimatorCommand DoingCmd;
         public GComponent HeadBar;
+        public GProgressBar HPBar;
         public Transform TransHeadInfo;
 
         public Transform TransChest;

+ 2 - 1
Unity/Assets/Scripts/Loader/MonoBehaviour/CheckResUpdate.cs

@@ -1,4 +1,4 @@
-using FairyGUI;
+using FairyGUI;
 using UnityEngine;
 
 namespace ET
@@ -8,6 +8,7 @@ namespace ET
         void Start()
         {
             var view = UIPackage.CreateObject("CheckForResUpdate", "CheckForResUpdate").asCom;
+            view.name = "CheckForResUpdate";
             GRoot.inst.AddChild(view);
 
             var progress = view.GetChild("processbar").asProgress;