From 45ca5330aff85b2b75511eb9153d0259c1e1f38f Mon Sep 17 00:00:00 2001 From: cd <-> Date: Sun, 4 Jun 2023 16:25:01 +0800 Subject: [PATCH] =?UTF-8?q?headbar=20=E8=A1=80=E6=9D=A1=E5=92=8C=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E6=9D=A1=E5=88=86=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Game/Scripts/UI/Sub/PageHeadbar.cs | 90 ++++++++++++------ .../Assets/Game/Scripts/UI/UIPoolManager.cs | 10 +- .../Scripts/UI/_ViewGen/Battle/ViewHeadbar.cs | 2 + .../UI/_ViewGen/Battle/ViewInteract.cs | 2 + .../Scripts/UI/_ViewGen/Battle/Viewc_blood.cs | 4 - .../Assets/Resources/UIRes/Battle_fui.bytes | Bin 28306 -> 28316 bytes uiproject/.objs/workspace.json | 2 +- .../assets/Battle/Headbar/Comp/Interact.xml | 2 + .../assets/Battle/Headbar/Comp/c_blood.xml | 18 ++-- uiproject/assets/Battle/Headbar/Headbar.xml | 9 +- 10 files changed, 87 insertions(+), 52 deletions(-) diff --git a/client/Assets/Game/Scripts/UI/Sub/PageHeadbar.cs b/client/Assets/Game/Scripts/UI/Sub/PageHeadbar.cs index fb49eb2..a76cdbd 100644 --- a/client/Assets/Game/Scripts/UI/Sub/PageHeadbar.cs +++ b/client/Assets/Game/Scripts/UI/Sub/PageHeadbar.cs @@ -20,10 +20,14 @@ namespace Game private readonly Dictionary>> _hitBuffDict = new Dictionary>>(); + private readonly Dictionary> _interactDict = + new Dictionary>(); + protected override void OnCreate() { CreateUI(false); } + protected override void OnOpen() { //打开时创建所有非主角实体的血条 @@ -37,6 +41,7 @@ namespace Game SetHpBar(entity.ID(), true); SetHitNum(entity.ID(), true); + SetInteract(entity.ID(), true); } EventManager.Instance.AddEvent(EEvent.EntityAlive, OnEntityAlive); @@ -93,7 +98,7 @@ namespace Game { var headBarItem = kvp.Value; var posScreen = GetScreenPos(Util.EntityViewPos(entity)); - headBarItem.MComponent.SetPosition(posScreen.x, posScreen.y - 80, posScreen.z); + headBarItem.Component.SetPosition(posScreen.x, posScreen.y - 80, posScreen.z); } } @@ -106,7 +111,7 @@ namespace Game var posScreen = GetScreenPos(Util.EntityViewPos(entity)); foreach (var item in hitNumList) { - item.MComponent.SetPosition(posScreen.x, posScreen.y, posScreen.z); + item.Component.SetPosition(posScreen.x, posScreen.y, posScreen.z); } } } @@ -120,10 +125,20 @@ namespace Game var posScreen = GetScreenPos(Util.EntityViewPos(entity)); foreach (var item in hitNumList) { - item.MComponent.SetPosition(posScreen.x, posScreen.y - 40, posScreen.z); + item.Component.SetPosition(posScreen.x, posScreen.y - 40, posScreen.z); } } } + foreach (var kvp in _interactDict) + { + var entity = Util.GetEntity(kvp.Key); + if (entity != null) + { + var interactItem = kvp.Value; + var posScreen = GetScreenPos(Util.EntityViewPos(entity)); + interactItem.Component.SetPosition(posScreen.x, posScreen.y - 80, posScreen.z); + } + } } /// @@ -157,7 +172,7 @@ namespace Game if (hp.DmgShowTime <= 0) { hp.DmgShowTime = 0; - var lastItem = hitNumList[hitNumList.Count - 1].MComponent as ViewHitNum; + var lastItem = hitNumList[hitNumList.Count - 1].Component as ViewHitNum; lastItem.m_step2.Play(); if (GameRandom.Roll(0.5f)) { @@ -178,7 +193,7 @@ namespace Game } var item = hitNumList[i]; - var hitInfo = hitNumList[i].MComponent as ViewHitNum; + var hitInfo = hitNumList[i].Component as ViewHitNum; if (!hitInfo.m_step2.playing) { item.Destroy(); @@ -212,7 +227,7 @@ namespace Game for (int i = hitNumList.Count - 1; i >= 0; i--) { var item = hitNumList[i]; - var hitInfo = hitNumList[i].MComponent as ViewHitBuff; + var hitInfo = hitNumList[i].Component as ViewHitBuff; if (entity.pause.IsPause) { hitInfo.m_step1.SetPaused(true); @@ -239,6 +254,43 @@ namespace Game SetHpBar(param.Entity, param.IsAlive); SetHitNum(param.Entity, param.IsAlive); + SetInteract(param.Entity, param.IsAlive); + } + + private void SetInteract(int entityID, bool isAlive = true) + { + var entity = Util.GetEntity(entityID); + if (!entity.hasInteract) + { + return; + } + + if (isAlive) + { + if (!_interactDict.ContainsKey(entityID)) + { + var interactBar = UIManager.Instance.Creator.CreateUIItem(ViewInteract.URL); + _interactDict[entityID] = interactBar; + var interactComp = interactBar.Component; + + var interact = entity.interact; + BindData(interact.IsActive, + (_, now) => { interactComp.m_showInteract.selectedIndex = now ? 1 : 0; }); + BindData(interact.IsTarget, + (_, now) => { interactComp.m_isTarget.selectedIndex = now ? 1 : 0; }); + } + } + else + { + if (_interactDict.ContainsKey(entityID)) + { + _interactDict[entityID].Destroy(); + _interactDict.Remove(entityID); + var interact = entity.interact; + UnbindData(interact.IsActive); + UnbindData(interact.IsTarget); + } + } } private void SetHitNum(int entityID, bool isAlive = true) @@ -274,9 +326,8 @@ namespace Game private void SetHpBar(int entityID, bool isAlive = true) { var entity = Util.GetEntity(entityID); - if (entity.IsMaster()) + if (!entity.hasHp) { - //排除主角 return; } @@ -287,7 +338,7 @@ namespace Game //创建血条UI var hpBar = UIManager.Instance.Creator.CreateUIItem(Viewc_blood.URL); _hpBarDict[entityID] = hpBar; - var hpComp = hpBar.MComponent; + var hpComp = hpBar.Component; if (entity.hasHp) { var hp = entity.hp; @@ -352,14 +403,6 @@ namespace Game } }); } - - if (entity.hasInteract) - { - var interact = entity.interact; - BindData(interact.IsActive, (_, now) => { hpComp.m_showInteract.selectedIndex = now ? 1 : 0; }); - BindData(interact.IsTarget, - (_, now) => { hpComp.m_Interact.m_isTarget.selectedIndex = now ? 1 : 0; }); - } } } else @@ -387,13 +430,6 @@ namespace Game UnbindData(ai.IsHungryFull); UnbindData(ai.AttackPermit); } - - if (entity.hasInteract) - { - var interact = entity.interact; - UnbindData(interact.IsActive); - UnbindData(interact.IsTarget); - } } } } @@ -422,14 +458,14 @@ namespace Game { hp.LastDmg = dmg; var hitNum = UIManager.Instance.Creator.CreateUIItem(ViewHitNum.URL); - var item = hitNum.MComponent as ViewHitNum; + var item = hitNum.Component as ViewHitNum; hitList.Add(hitNum); targetItem = item; } else { hp.LastDmg += dmg; - targetItem = hitList[hitList.Count - 1].MComponent as ViewHitNum; + targetItem = hitList[hitList.Count - 1].Component as ViewHitNum; } targetItem.m_num.text = $"{hp.LastDmg}"; @@ -447,7 +483,7 @@ namespace Game var hitList = _hitBuffDict[entityID]; var hitNum = UIManager.Instance.Creator.CreateUIItem(ViewHitBuff.URL); hitList.Add(hitNum); - var item = hitNum.MComponent as ViewHitBuff; + var item = hitNum.Component as ViewHitBuff; item.m_name.text = text; item.m_step1.Play(); } diff --git a/client/Assets/Game/Scripts/UI/UIPoolManager.cs b/client/Assets/Game/Scripts/UI/UIPoolManager.cs index c047591..18540e6 100644 --- a/client/Assets/Game/Scripts/UI/UIPoolManager.cs +++ b/client/Assets/Game/Scripts/UI/UIPoolManager.cs @@ -5,14 +5,14 @@ namespace Game public class UIPoolItem : ObjectPoolItemBase { } public class UIPoolItem : UIPoolItem where T : GComponent, new() { - public T MComponent; + public T Component; protected override void OnCreate() { - MComponent.visible = true; + Component.visible = true; } protected override void OnDestroy() { - MComponent.visible = false; + Component.visible = false; } } public class UIPoolManager : ObjectPoolBase @@ -25,10 +25,10 @@ namespace Game var contentItem = UIPackage.GetItemByURL(url); var pkgName = contentItem.owner.name; var compName = contentItem.name; - string typeName = $"{contentItem.owner.name}_{contentItem.name}"; + var typeName = $"{contentItem.owner.name}_{contentItem.name}"; var poolObj = Create>(typeName, (item) => { - item.MComponent = CreateUIComponent(pkgName, compName) as T; + item.Component = CreateUIComponent(pkgName, compName) as T; }); return poolObj; } diff --git a/client/Assets/Game/Scripts/UI/_ViewGen/Battle/ViewHeadbar.cs b/client/Assets/Game/Scripts/UI/_ViewGen/Battle/ViewHeadbar.cs index e3bb4b5..5d7a049 100644 --- a/client/Assets/Game/Scripts/UI/_ViewGen/Battle/ViewHeadbar.cs +++ b/client/Assets/Game/Scripts/UI/_ViewGen/Battle/ViewHeadbar.cs @@ -12,6 +12,7 @@ namespace Game.Battle public Viewc_blood m_c_blood; public ViewHitNum m_c_hitNum; public ViewHitBuff m_c_hitBuff; + public ViewInteract m_c_Interact; public const string URL = "ui://2qo7xpdcoi571q"; @@ -33,6 +34,7 @@ namespace Game.Battle m_c_blood = (Viewc_blood)this.GetChild("c_blood"); m_c_hitNum = (ViewHitNum)this.GetChild("c_hitNum"); m_c_hitBuff = (ViewHitBuff)this.GetChild("c_hitBuff"); + m_c_Interact = (ViewInteract)this.GetChild("c_Interact"); } } } \ No newline at end of file diff --git a/client/Assets/Game/Scripts/UI/_ViewGen/Battle/ViewInteract.cs b/client/Assets/Game/Scripts/UI/_ViewGen/Battle/ViewInteract.cs index a2495f7..72094e3 100644 --- a/client/Assets/Game/Scripts/UI/_ViewGen/Battle/ViewInteract.cs +++ b/client/Assets/Game/Scripts/UI/_ViewGen/Battle/ViewInteract.cs @@ -8,6 +8,7 @@ namespace Game.Battle public partial class ViewInteract : GComponent { public Controller m_isTarget; + public Controller m_showInteract; public GLoader m_n18; public const string URL = "ui://2qo7xpdco85f57"; @@ -26,6 +27,7 @@ namespace Game.Battle base.ConstructFromXML(xml); m_isTarget = this.GetController("isTarget"); + m_showInteract = this.GetController("showInteract"); m_n18 = (GLoader)this.GetChild("n18"); } } diff --git a/client/Assets/Game/Scripts/UI/_ViewGen/Battle/Viewc_blood.cs b/client/Assets/Game/Scripts/UI/_ViewGen/Battle/Viewc_blood.cs index f3f76e2..300d593 100644 --- a/client/Assets/Game/Scripts/UI/_ViewGen/Battle/Viewc_blood.cs +++ b/client/Assets/Game/Scripts/UI/_ViewGen/Battle/Viewc_blood.cs @@ -12,7 +12,6 @@ namespace Game.Battle public Controller m_showExtra; public Controller m_moduleType; public Controller m_attackStatus; - public Controller m_showInteract; public ViewbloodBarEnemy m_bloodBarEnemy; public ViewshieldBarEnemy m_shieldBarEnemy; public ViewstunBarEnemy m_stunBarEnemy; @@ -21,7 +20,6 @@ namespace Game.Battle public GTextField m_n14; public GGraph m_n15; public GImage m_n17; - public ViewInteract m_Interact; public const string URL = "ui://2qo7xpdcjrii21"; @@ -43,7 +41,6 @@ namespace Game.Battle m_showExtra = this.GetController("showExtra"); m_moduleType = this.GetController("moduleType"); m_attackStatus = this.GetController("attackStatus"); - m_showInteract = this.GetController("showInteract"); m_bloodBarEnemy = (ViewbloodBarEnemy)this.GetChild("bloodBarEnemy"); m_shieldBarEnemy = (ViewshieldBarEnemy)this.GetChild("shieldBarEnemy"); m_stunBarEnemy = (ViewstunBarEnemy)this.GetChild("stunBarEnemy"); @@ -52,7 +49,6 @@ namespace Game.Battle m_n14 = (GTextField)this.GetChild("n14"); m_n15 = (GGraph)this.GetChild("n15"); m_n17 = (GImage)this.GetChild("n17"); - m_Interact = (ViewInteract)this.GetChild("Interact"); } } } \ No newline at end of file diff --git a/client/Assets/Resources/UIRes/Battle_fui.bytes b/client/Assets/Resources/UIRes/Battle_fui.bytes index 086fb8ca3fea31e18df738f25a34ea22f0134a77..81873d5517634cba7c79999b49f4d7a2cdfef4f5 100644 GIT binary patch delta 3089 zcmaJ@3s}@u7C&e141W-k0cLm&uVHu%FCB)5`iX!c2_i%&iiSu&$S*}v(ly;AA7ws5 zJ=ShQfwiW#)@tJ;l?^o42kR?SQj1J$ad+D`U8~(~3-;VU4~6C1JKvc(_jjK6-gD2L zEp1rWhI_Z_6P5@lhbO_Kvjcd{WO|fIJKb4MLz#v#H8GOMl+QGcPU?eENA3FO(V3cy z3`!;2E`&w2-D8YW#r)H-nE425vAI#Orw=Zn6wgEW3;NcxNLkAAXJ8rSdQB0_;g_`A zYliJvFvAK+hH8$)VgtO|*@*~(r(FZ>c6(=fI)EgA=P1?SCsx8LDmFZ;tY(un@H~BP zNT#=<^|ZjKh)T}p8RHZ90<{_Qm9?z#BCMkZpF(9l^AEuW=10&e??6$-x!%{@_<-h1 zeKh@@_Y0_jO|Y4Yd}rYnYV@@z#420iWoq|5Bwm4EQG;JT{+f=BH@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B- zI#k9}_ixlHVU{6&+-mkz1z!!D;i!Sckz@L(!@%SnQE}qYmvv7 zN)|orlZ3LOltJ(T6&`aRj4M=lRUa&WUbE6}_RTk@86 z`--b;Hq+|TC{yK#l({KspsPq2F+g diff --git a/uiproject/.objs/workspace.json b/uiproject/.objs/workspace.json index e240612..d74c755 100644 --- a/uiproject/.objs/workspace.json +++ b/uiproject/.objs/workspace.json @@ -2,7 +2,7 @@ "hidden_packages": [], "active_doc": [ "2qo7xpdc", - "teeb53" + "jrii24" ], "expanded_nodes": [ "6tegmf7n", diff --git a/uiproject/assets/Battle/Headbar/Comp/Interact.xml b/uiproject/assets/Battle/Headbar/Comp/Interact.xml index 3079cc0..95f6871 100644 --- a/uiproject/assets/Battle/Headbar/Comp/Interact.xml +++ b/uiproject/assets/Battle/Headbar/Comp/Interact.xml @@ -1,8 +1,10 @@ + + diff --git a/uiproject/assets/Battle/Headbar/Comp/c_blood.xml b/uiproject/assets/Battle/Headbar/Comp/c_blood.xml index e7b540d..44dcd4d 100644 --- a/uiproject/assets/Battle/Headbar/Comp/c_blood.xml +++ b/uiproject/assets/Battle/Headbar/Comp/c_blood.xml @@ -2,18 +2,17 @@ - - + + - - + - + - + @@ -23,11 +22,11 @@ - + - + @@ -40,8 +39,5 @@ - - - \ No newline at end of file diff --git a/uiproject/assets/Battle/Headbar/Headbar.xml b/uiproject/assets/Battle/Headbar/Headbar.xml index 2e31cba..9da4f4b 100644 --- a/uiproject/assets/Battle/Headbar/Headbar.xml +++ b/uiproject/assets/Battle/Headbar/Headbar.xml @@ -2,11 +2,12 @@ - + - - - + + + + \ No newline at end of file