From 074ab30011eed20dd83715bbd1a047cb83a68a8b Mon Sep 17 00:00:00 2001 From: chenyuqi <1357020360@qq.com> Date: Tue, 29 Apr 2025 15:10:33 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=8B=86=E5=88=86Mono=E3=80=91?= =?UTF-8?q?=E6=8F=90=E4=BA=A4UINode=E9=83=A8=E5=88=86=E5=AD=90=E7=B1=BB?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/Common => Framework/UI}/UINode.cs | 42 +- .../UI/Common => Framework/UI}/UINode.cs.meta | 0 .../Code/Scripts/Framework/UI/UIWindow.cs | 18 + .../Code/Scripts/GameWrapper/UINode.meta | 8 + .../UINode}/UIBatteryAndSignalNode.cs | 0 .../UINode}/UIBatteryAndSignalNode.cs.meta | 0 .../GameWrapper/UINode/UIHeadItemNode.cs | 673 ++++++++++++++++++ .../UINode}/UIHeadItemNode.cs.meta | 0 .../UINode}/UIHeadItemNodeBase.cs | 0 .../UINode}/UIHeadItemNodeBase.cs.meta | 0 .../GameWrapper/UINode/UIHerosHeadItemNode.cs | 35 + .../UINode}/UIHerosHeadItemNode.cs.meta | 0 .../UINode/UIVehicleHeadItemNode.cs | 25 + .../UINode}/UIVehicleHeadItemNode.cs.meta | 0 ...HeadItemNode.cs => UIHeadItemNodeLogic.cs} | 96 +-- .../UI/Common/UIHeadItemNodeLogic.cs.meta | 3 + .../FightReady/UIHeadItemNodeLogicBase.cs | 13 + .../UIHeadItemNodeLogicBase.cs.meta | 3 + ...temNode.cs => UIHerosHeadItemNodeLogic.cs} | 36 +- .../UIHerosHeadItemNodeLogic.cs.meta | 3 + .../FightReady/UITeamFightController.cs | 115 ++- ...mNode.cs => UIVehicleHeadItemNodeLogic.cs} | 27 +- .../UIVehicleHeadItemNodeLogic.cs.meta | 3 + .../UI/LevelFight/UIPassGameController.cs | 5 +- .../LevelFight/UI_PassGame_SweepController.cs | 8 +- .../UI/PVP/UI_DefendSettingController.cs | 17 +- .../Gameplay/UI/Team/UI_TeamInfoController.cs | 15 +- .../Gameplay/UI/UI_PVPSettlementController.cs | 4 +- .../Scripts/Gameplay/UI/UI_PatioController.cs | 16 +- ProjectNLD/Assets/PhxhSDK | 2 +- 30 files changed, 1021 insertions(+), 146 deletions(-) rename ProjectNLD/Assets/Code/Scripts/{Gameplay/UI/Common => Framework/UI}/UINode.cs (74%) rename ProjectNLD/Assets/Code/Scripts/{Gameplay/UI/Common => Framework/UI}/UINode.cs.meta (100%) create mode 100644 ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode.meta rename ProjectNLD/Assets/Code/Scripts/{Gameplay/UI/Common => GameWrapper/UINode}/UIBatteryAndSignalNode.cs (100%) rename ProjectNLD/Assets/Code/Scripts/{Gameplay/UI/Common => GameWrapper/UINode}/UIBatteryAndSignalNode.cs.meta (100%) create mode 100644 ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHeadItemNode.cs rename ProjectNLD/Assets/Code/Scripts/{Gameplay/UI/Common => GameWrapper/UINode}/UIHeadItemNode.cs.meta (100%) rename ProjectNLD/Assets/Code/Scripts/{Gameplay/UI/LevelFight/FightReady => GameWrapper/UINode}/UIHeadItemNodeBase.cs (100%) rename ProjectNLD/Assets/Code/Scripts/{Gameplay/UI/LevelFight/FightReady => GameWrapper/UINode}/UIHeadItemNodeBase.cs.meta (100%) create mode 100644 ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHerosHeadItemNode.cs rename ProjectNLD/Assets/Code/Scripts/{Gameplay/UI/LevelFight/FightReady => GameWrapper/UINode}/UIHerosHeadItemNode.cs.meta (100%) create mode 100644 ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIVehicleHeadItemNode.cs rename ProjectNLD/Assets/Code/Scripts/{Gameplay/UI/LevelFight/FightReady => GameWrapper/UINode}/UIVehicleHeadItemNode.cs.meta (100%) rename ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/{UIHeadItemNode.cs => UIHeadItemNodeLogic.cs} (85%) create mode 100644 ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIHeadItemNodeLogic.cs.meta create mode 100644 ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/UIHeadItemNodeLogicBase.cs create mode 100644 ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/UIHeadItemNodeLogicBase.cs.meta rename ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/{UIHerosHeadItemNode.cs => UIHerosHeadItemNodeLogic.cs} (95%) create mode 100644 ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/UIHerosHeadItemNodeLogic.cs.meta rename ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/{UIVehicleHeadItemNode.cs => UIVehicleHeadItemNodeLogic.cs} (89%) create mode 100644 ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/UIVehicleHeadItemNodeLogic.cs.meta diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UINode.cs b/ProjectNLD/Assets/Code/Scripts/Framework/UI/UINode.cs similarity index 74% rename from ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UINode.cs rename to ProjectNLD/Assets/Code/Scripts/Framework/UI/UINode.cs index 52fa07ce69b..f199b96e818 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UINode.cs +++ b/ProjectNLD/Assets/Code/Scripts/Framework/UI/UINode.cs @@ -9,6 +9,8 @@ using Object = UnityEngine.Object; public class UINode: MonoBehaviour { protected List LoadedAssets = new List(); + protected bool isAutoCraete = true; + //private UINodeLogic _nodeLogic; public static UINode LoadNode() { return null; @@ -16,11 +18,16 @@ public class UINode: MonoBehaviour protected void ClearBind(Button button) { - button.onClick.RemoveAllListeners(); + if (button) + { + button.onClick.RemoveAllListeners(); + } } protected void BindButton(Button button, Action func) { + if (!button) + return; button.onClick.AddListener(() => { func?.Invoke(); @@ -29,6 +36,8 @@ public class UINode: MonoBehaviour protected void BindButton(Button button, Action func, T param) { + if (!button) + return; button.onClick.AddListener(() => { func?.Invoke(param); @@ -37,6 +46,8 @@ public class UINode: MonoBehaviour protected void BindButton(Button button, Action func, T param1, TK param2) { + if (!button) + return; button.onClick.AddListener(() => { func?.Invoke(param1, param2); @@ -45,6 +56,12 @@ public class UINode: MonoBehaviour protected T _GetComponent(string path) where T: Behaviour { + if (!transform) + return null; + if (!transform.Find(path)) + { + return null; + } var compGo = transform.Find(path).gameObject; if (compGo) { @@ -57,6 +74,10 @@ public class UINode: MonoBehaviour protected GameObject _FindObj(string path) { + if (!transform.Find(path)) + { + return null; + } var compGo = transform.Find(path).gameObject; if (compGo) { @@ -77,11 +98,19 @@ public class UINode: MonoBehaviour return asset; } - + + private void Awake() + { + OnAwake(); + } + public virtual void OnAwake() { - + if (isAutoCraete) + { + //_nodeLogic = UIManager.Instance.CreateNewNode(this); + } } public virtual void OnStart() { @@ -90,7 +119,7 @@ public class UINode: MonoBehaviour public virtual void OnUpdate() { - + //_nodeLogic.OnUpdate(); } public virtual void SetData(object data) @@ -108,6 +137,11 @@ public class UINode: MonoBehaviour } + public virtual void Destroy() + { + //UIManager.Instance.DestroyNode(_nodeLogic); + } + public virtual void OnRelease() { for (int i = 0; i < LoadedAssets.Count; i++) diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UINode.cs.meta b/ProjectNLD/Assets/Code/Scripts/Framework/UI/UINode.cs.meta similarity index 100% rename from ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UINode.cs.meta rename to ProjectNLD/Assets/Code/Scripts/Framework/UI/UINode.cs.meta diff --git a/ProjectNLD/Assets/Code/Scripts/Framework/UI/UIWindow.cs b/ProjectNLD/Assets/Code/Scripts/Framework/UI/UIWindow.cs index abbc470c34d..e557b05d1a2 100644 --- a/ProjectNLD/Assets/Code/Scripts/Framework/UI/UIWindow.cs +++ b/ProjectNLD/Assets/Code/Scripts/Framework/UI/UIWindow.cs @@ -882,6 +882,24 @@ public abstract class UIWindow } return component; } + + public T AddComponent(string path = "") where T : Behaviour + { + var trans = transform.Find(path); + if (trans) + { + var component = trans.GetComponent(); + if (component == null) + { + component = trans.gameObject.AddComponent(); + //DebugUtil.LogError("{0}未找到组件{1}: {2}", mWindowName, typeof(T).Name, path); + } + return component; + } + + DebugUtil.LogError("{0}未找到路径: {1}", mWindowName, path); + return null; + } #endregion public void HideWindow(bool isOnlyHide = false) { diff --git a/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode.meta b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode.meta new file mode 100644 index 00000000000..8858579ce4d --- /dev/null +++ b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: addf2cbf139c33949a0780c876dc8ba1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIBatteryAndSignalNode.cs b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIBatteryAndSignalNode.cs similarity index 100% rename from ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIBatteryAndSignalNode.cs rename to ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIBatteryAndSignalNode.cs diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIBatteryAndSignalNode.cs.meta b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIBatteryAndSignalNode.cs.meta similarity index 100% rename from ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIBatteryAndSignalNode.cs.meta rename to ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIBatteryAndSignalNode.cs.meta diff --git a/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHeadItemNode.cs b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHeadItemNode.cs new file mode 100644 index 00000000000..ad26e281784 --- /dev/null +++ b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHeadItemNode.cs @@ -0,0 +1,673 @@ +using System; +using cfg.CharacterCfg; +using Framework; +using Gameplay; +using PhxhSDK; +using TMPro; +using UnityEngine; +using UnityEngine.UI; + +/// +/// 角色及载具头像UI设置基类 +/// +public class UIHeadItemNode : MonoBehaviour +{ + protected uint uid; + protected UIHeadInfo uiheadInfo; + + public GameObject root; + public Image imgBg; + public Image imgTeamProBg; + public Image imgTeamProName; + public Image imgHead; + public Image imgPro; + public Image imgMorale; + public Image imgMoraleFill; + public Image imgStateInBattle; + public TMP_Text txtLevel; + public Image imgRarity; + public TMP_Text txtName; + public Image imgSelect; + public Button buttonHead; + public TMP_Text txtLeadership; + public UIButtonLongPress buttonLongPress; + + public GameObject contentFight; + public GameObject GoPro; + public GameObject CostLeadershipGo; + + public TMP_Text txtLevelForEditTeam; + public GameObject LevelGoForEditTeam; + + public ButtonUpDrag buttonUpDrag; + + protected GameObject _debugContent; + protected TMP_Text _debugRoleID; + + private void Awake() + { + // OnAwake(); + // EventManager.Instance.Register(EventManager.EventName.DebugHeadRoleID, _OnDebugRoleID); + } + + // Start is called before the first frame update + void Start() + { + + } + + private void OnDestroy() + { + //EventManager.Instance.Unregister(EventManager.EventName.DebugHeadRoleID, _OnDebugRoleID); + //base.OnRelease(); + } + + // public override void OnAwake() + // { + // base.OnAwake(); + // _GetComponents(); + // } + // + // public override void OnStart() + // { + // base.OnStart(); + // _GetComponents(); + // } + + // public override void SetData(object data) + // { + // uiheadInfo = data as UIHeadInfo; + // if (uiheadInfo == null) + // { + // DebugUtil.LogError($"{name} SetData data is null!!! "); + // return; + // } + // uid = uiheadInfo.Uid; + // } + // + // private void _GetComponents() + // { + // root = gameObject; + // imgBg = _GetComponent("Content/ImageBg"); + // imgTeamProBg = _GetComponent("Content/ImageJob"); + // imgTeamProName = _GetComponent("Content/ImageJob/ImageName"); + // imgHead = _GetComponent("Content/ImageHead"); + // imgPro = _GetComponent("Content/ImageProfession/Image_Job"); + // imgMorale = _GetComponent("Content/FightContent/ImageMoraleStatusBar"); + // imgStateInBattle = _GetComponent("Content/FightContent/ImageState"); + // imgMoraleFill = _GetComponent("Content/FightContent/ImageMoraleStatusBar/ImageBattleMorale"); + // imgRarity = _GetComponent("Content/ImageRarity"); + // txtLevel = _GetComponent("Content/TextLevel"); + // txtName = _GetComponent("Content/TextName"); + // imgSelect = _GetComponent("Content/ImageSelected"); + // GoPro = _FindObj("Content/ImageProfession"); + // txtLeadership = _GetComponent("Content/Image_CostBg/Text_CommandCost"); + // + // CostLeadershipGo = _FindObj("Content/Image_CostBg"); + // contentFight = transform.Find("Content/FightContent").gameObject; + // buttonUpDrag = buttonHead.GetComponent(); + // + // // For Team Edit + // LevelGoForEditTeam = _FindObj("Content/Image_LevelBg"); + // txtLevelForEditTeam = _GetComponent("Content/Image_LevelBg/TextLevel"); + // + // //Debug + // _debugContent = transform.Find("Debug").gameObject; + // _debugRoleID = _GetComponent("Debug/RoleID"); + // } + // + // public void GetComponents() + // { + // _GetComponents(); + // } + // + // #region Refresh + // + // public void Refresh(bool isAsync = true) + // { + // if (isAsync) + // { + // _RefreshAsync(); + // } + // else + // { + // _Refresh(); + // } + // + // _RefreshCostLeadership(); + // + // _RefreshCommon(); + // _BindClickCb(); + // + // _RefreshDebug(); + // } + // + // private void _Refresh() + // { + // if (uiheadInfo.IsFight) + // { + // + // + // } + // else + // { + // contentFight.SetActive(false); + // } + // + // _RefreshHead(); + // _RefreshProfession(); + // } + // + // private async void _RefreshAsync() + // { + // if (uiheadInfo.IsFight) + // { + // + // } + // else + // { + // if (!contentFight) + // { + // contentFight = transform.Find("Content/FightContent").gameObject; + // } + // contentFight.SetActive(false); + // } + // + // _RefreshHeadAsync(); + // _RefreshProfessionAsync(); + // } + // + // /// + // /// 异步方法 + // /// + // private async void _RefreshHeadAsync() + // { + // if (!uiheadInfo.IsShowHead) + // { + // imgHead.gameObject.SetActive(false); + // return; + // } + // imgHead.gameObject.SetActive(true); + // + // if (!uiheadInfo.IsAutoSetHead) return; + // if (!ValueValidator.IsIdValid(uid)) return; + // var characterInfo = CharacterDataInfoManager.Instance.GetCharacterInfo(uid); + // var spritePath = CommonUtils.GetCharacterPicPath((int)uid, CommonUtils.ECharacterPicPathType.HeadPic, + // (int)characterInfo.SkinID, uiheadInfo.IsCommander);//CommonUtils.GetDefaultHeadPathByUid(uid); + // var sprite = await LoadAssetAsync(spritePath); + // if (sprite) + // { + // imgHead.sprite = sprite; + // } + // } + // + // private async void _RefreshProfessionAsync() + // { + // if (uiheadInfo.IsShowPro) + // { + // GoPro.SetActive(true); + // var job = CommonUtils.GetProfessionByUid(uid); + // var jobData = TableManager.Instance.Tables.JobAttri.GetOrDefault((int)job); + // var spritePath = jobData.IconPath; + // var sprite = await LoadAssetAsync(spritePath); + // if (sprite) + // { + // imgPro.sprite = sprite; + // } + // } + // else + // { + // GoPro.SetActive(false); + // } + // } + // + // /// + // /// 同步方法 + // /// + // private void _RefreshHead() + // { + // if (!uiheadInfo.IsShowHead) + // { + // imgHead.gameObject.SetActive(false); + // return; + // } + // imgHead.gameObject.SetActive(true); + // + // if (!uiheadInfo.IsAutoSetHead) return; + // if (!ValueValidator.IsIdValid(uid)) return; + // + // var config = CharacterDataInfoManager.Instance.GetCharacterInfo(uid); + // var spritePath = CommonUtils.GetCharacterPicPath((int)uid, CommonUtils.ECharacterPicPathType.HeadPic, (int)config.SkinID);//CommonUtils.GetDefaultHeadPathByUid(uid); + // var sprite = AssetManager.Instance.GetPreLoadResult(spritePath); + // if (sprite) + // { + // imgHead.sprite = sprite; + // } + // } + // + // private void _RefreshCostLeadership() + // { + // if (uiheadInfo.IsShowLeadership) + // { + // CostLeadershipGo.SetActive(true); + // var leadership = CharacterDataInfoManager.Instance.GetSpendLeadership(uid); + // txtLeadership.text = leadership.ToString(); + // } + // else + // { + // CostLeadershipGo.SetActive(false); + // } + // } + // + // private void _RefreshProfession() + // { + // if (uiheadInfo.IsShowPro) + // { + // GoPro.gameObject.SetActive(true); + // var job = CommonUtils.GetProfessionByUid(uid); + // var jobData = TableManager.Instance.Tables.JobAttri.GetOrDefault((int)job); + // var spritePath = jobData.IconPath; + // var sprite = AssetManager.Instance.GetPreLoadResult(spritePath); + // if (sprite) + // { + // imgPro.sprite = sprite; + // } + // } + // else + // { + // GoPro.SetActive(false); + // } + // } + // + // /// + // /// 共有的显示刷新逻辑 + // /// + // private void _RefreshCommon() + // { + // _RefreshRarity(); + // _RefreshLevel(); + // _RefreshName(); + // _RefreshBg(); + // } + // + // private void _RefreshBg() + // { + // imgBg.gameObject.SetActive(uiheadInfo.IsShowBg); + // } + // private void _RefreshRarity() + // { + // imgRarity.gameObject.SetActive(uiheadInfo.IsShowRarity); + // } + // + // private void _RefreshName() + // { + // if (!uiheadInfo.IsShowName) + // { + // txtName.gameObject.SetActive(false); + // return; + // } + // + // txtName.gameObject.SetActive(true); + // if (!ValueValidator.IsIdValid(uid)) return; + // + // var data = TableManager.Instance.Tables.CharacterAttri.GetOrDefault((int)uid); + // if (data != null) + // { + // txtName.text = CommonUtils.GetCharacterName(data.RoleID); //CommonUtils.GetLocalizeText(data.Name); + // } + // } + // + // //绑定点击回调 + // private void _BindClickCb() + // { + // if (buttonLongPress != null && uiheadInfo.LongPress != null) + // { + // buttonLongPress.onLongPress = uiheadInfo.LongPress; + // if (uiheadInfo.ClickCb is Action action) + // { + // buttonLongPress.onClick = action; + // } + // } + // else if(uiheadInfo.ClickCb is Action action) + // { + // ClearBind(buttonHead); + // BindButton(buttonHead, action); + // + // } + // } + // + // private void _RefreshLevel() + // { + // if (!uiheadInfo.IsShowLevel && !uiheadInfo.IsShowNewLevel) + // { + // LevelGoForEditTeam.SetActive(false); + // txtLevel.gameObject.SetActive(false); + // return; + // } + // + // if (uiheadInfo.IsShowLevel && !uiheadInfo.IsShowNewLevel) + // { + // txtLevel.gameObject.SetActive(true); + // LevelGoForEditTeam.gameObject.SetActive(false); + // if (CharacterDataInfoManager.Instance.DataDic.TryGetValue(uid, out var charInfo)) + // { + // txtLevel.text = "LV " + charInfo.Level; + // } + // return; + // } + // + // if (uiheadInfo.IsShowLevel && uiheadInfo.IsShowNewLevel) + // { + // txtLevel.gameObject.SetActive(false); + // LevelGoForEditTeam.gameObject.SetActive(true); + // if (CharacterDataInfoManager.Instance.DataDic.TryGetValue(uid, out var charInfo)) + // { + // txtLevelForEditTeam.text = charInfo.Level.ToString(); + // } + // return; + // } + // } + // + // //设置点击回调的参数 + // public void SetClickCbParam(T param) + // { + // if (uiheadInfo.ClickCb != null) + // { + // ClearBind(buttonHead); + // var clickCb = uiheadInfo.ClickCb; + // if (clickCb is Action action) + // { + // BindButton(buttonHead, action, param); + // } + // } + // } + // + // //设置点击回调的参数 + // public void SetClickCbParam(T param1,TK param2) + // { + // if (uiheadInfo.ClickCb != null) + // { + // ClearBind(buttonHead); + // var clickCb = uiheadInfo.ClickCb; + // if (clickCb is Action action) + // { + // BindButton(buttonHead, action, param1, param2); + // } + // } + // } + // + // /// + // /// 提供手动设置头像接口 + // /// + // /// + // public void SetHeadImage(bool isAsync = true) + // { + // if (!uiheadInfo.IsShowHead) + // { + // imgHead.gameObject.SetActive(false); + // return; + // } + // if (!ValueValidator.IsIdValid(uid)) return; + // + // imgHead.gameObject.SetActive(true); + // if (isAsync) + // { + // _RefreshHeadAsync(); + // return; + // } + // + // _RefreshHead(); + // } + // + // public async void SetHeadImageAsync(string spritePath) + // { + // + // var sprite = await LoadAssetAsync(spritePath); + // imgHead.sprite = sprite; + // } + // + // public void SetHeadImage(string spritePath) + // { + // var sprite = AssetManager.Instance.GetPreLoadResult(spritePath); + // imgHead.sprite = sprite; + // } + // + // public void SetActive(bool active = true) + // { + // root.SetActive(active); + // } + // + // //设置背景 + // public void SetBgImage(string spritePath, bool isAsync = true) + // { + // if (!uiheadInfo.IsShowBg) + // { + // imgBg.gameObject.SetActive(false); + // return; + // } + // + // if(string.IsNullOrEmpty(spritePath)) + // return; + // + // imgBg.gameObject.SetActive(true); + // if (isAsync) + // { + // _SetBgImageAsync(spritePath); + // return; + // } + // + // _SetBgImage(spritePath); + // } + // + // public void HideTeamProBg() + // { + // imgTeamProBg.gameObject.SetActive(false); + // } + // + // public void SetTeamBgImage(string spritePath, string proPath, bool isAsync = true) + // { + // + // if (string.IsNullOrEmpty(spritePath) || string.IsNullOrEmpty(proPath)) + // { + // imgTeamProBg.gameObject.SetActive(false); + // return; + // } + // + // imgTeamProBg.gameObject.SetActive(true); + // if (isAsync) + // { + // _SetTeamBgImageAsync(spritePath, proPath); + // return; + // } + // + // _SetTeamBgImage(spritePath, proPath); + // } + // + // private async void _SetBgImageAsync(string spritePath) + // { + // var sprite = await LoadAssetAsync(spritePath); + // imgBg.sprite = sprite; + // } + // + // private void _SetBgImage(string spritePath) + // { + // var sprite = AssetManager.Instance.GetPreLoadResult(spritePath); + // imgBg.sprite = sprite; + // } + // + // private async void _SetTeamBgImageAsync(string spritePath, string proPath) + // { + // var sprite = await LoadAssetAsync(spritePath); + // var proSprite = await LoadAssetAsync(proPath); + // imgTeamProBg.sprite = sprite; + // imgTeamProName.sprite = proSprite; + // } + // + // private void _SetTeamBgImage(string spritePath, string proPath) + // { + // var sprite = AssetManager.Instance.GetPreLoadResult(spritePath); + // var proSprite = AssetManager.Instance.GetPreLoadResult(proPath); + // imgTeamProBg.sprite = sprite; + // imgTeamProName.sprite = proSprite; + // } + // + // /// + // /// 刷新debug部分 + // /// + // protected virtual void _RefreshDebug() + // { + // _debugRoleID.text = "ID:" + uid; + // _debugContent.gameObject.SetActive(DisplayIDForCeHua.IsDisplayID); + // } + // #endregion + // + // #region Events + // + // protected virtual void _OnDebugRoleID() + // { + // _RefreshDebug(); + // } + // + // #endregion + // + // /***************** 外部拓展接口,可继承重写 ******************/ + // /// + // /// 刷新整个Item + // /// + // /// 角色uid + // /// 是否是上阵列表Item + // public virtual void RefreshHeadItem(uint id, bool isOnfight = false) + // { + // + // } + // + // //选中时上移 + // public virtual void RefreshSelect(bool isSelect = false) + // { + // + // } + // + // public virtual void BindItemClick(Action action) + // { + // + // } + // + // public virtual void BindItemClick(Action action, T param) + // { + // //action?.Invoke(param); + // } + // + // public virtual void BindItemClick(Action action, T param0, D param1) + // { + // //action?.Invoke(param); + // } + // + // public virtual void BindItemLongPress(Action action) + // { + // + // } + // + // public virtual void BindItemLongPress(Action action, T param) + // { + // + // } + // + // public virtual void BindItemPointerUp(Action action) + // { + // + // } + // + // public virtual void BindItemUpDrag(Action action, T param) + // { + // + // } + // + // public virtual void BindItemStartDrag(Action action, T param) + // { + // + // } + // + // public virtual void BindItemEndDrag(Action action, T param) + // { + // + // } + // + // public virtual void BindItemOnDrag(Action action, T param) + // { + // + // } + // + // public virtual void RemoveAllClickListener(ButtonUpDrag button) + // { + // //button.RemoveAllListener(); + // button.RemoveAll(); + // } + // + // public virtual void RemoveClickListener() + // { + // + // } + /***************** 外部拓展接口 End ******************/ +} + +public class UIHeadInfo +{ + private uint _uid; //角色ID + private bool _isFight; //是否战斗中使用 + private bool _isSelect; //是否选中 + + public bool IsShowPro; //是否显示职业 + public bool IsShowName; //是否显示名字 + public bool IsShowRarity; //是否显示品质 + public bool IsShowLevel; //是否显示等级 + public bool IsShowHead = true; //是否显示头像 + public bool IsShowBg = true; //是否显示背景 + public Delegate ClickCb; //点击回调,如果有参数,调用node的SetClickCbParam传参 + public Action LongPress; //长按点击 + + // 针对编队中的头像 + public bool IsShowLeadership; //是否是编队中的 + public bool IsShowNewLevel; //是否展示新等级 + public bool IsCommander; //是否是为指挥官头像 + + public bool IsAutoSetHead = true; //是否自动设置头像图片 + + public uint Uid => _uid; + public bool IsFight => _isFight; + public bool IsSelect => _isSelect; + public UIHeadInfo(uint uid, bool isFight, Delegate clickCb, Action longPress = null, bool isSelect = false, bool isShowHead = true, + bool isShowPro = true, bool isShowName = true, bool isShowRarity = true, bool isShowLevel = true, + bool isShowLeadership = false, bool isShowNewLevel = false, bool isCommander = false) + { + _uid = uid; + _isFight = isFight; + ClickCb = clickCb; + LongPress = longPress; + _isSelect = isSelect; + IsShowPro = isShowPro; + IsShowName = isShowName; + IsShowRarity = isShowRarity; + IsShowHead = isShowHead; + IsShowLevel = isShowLevel; + IsShowLeadership = isShowLeadership; + IsShowNewLevel = isShowNewLevel; + IsCommander = isCommander; + } + + public UIHeadInfo(uint uid, bool isFight) + { + _uid = uid; + _isFight = isFight; + } + + public UIHeadInfo(uint uid) + { + _uid = uid; + _isFight = false; + } + + public void SetIsSelect(bool isSelect) + { + _isSelect = isSelect; + } +} \ No newline at end of file diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIHeadItemNode.cs.meta b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHeadItemNode.cs.meta similarity index 100% rename from ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIHeadItemNode.cs.meta rename to ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHeadItemNode.cs.meta diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/UIHeadItemNodeBase.cs b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHeadItemNodeBase.cs similarity index 100% rename from ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/UIHeadItemNodeBase.cs rename to ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHeadItemNodeBase.cs diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/UIHeadItemNodeBase.cs.meta b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHeadItemNodeBase.cs.meta similarity index 100% rename from ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/UIHeadItemNodeBase.cs.meta rename to ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHeadItemNodeBase.cs.meta diff --git a/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHerosHeadItemNode.cs b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHerosHeadItemNode.cs new file mode 100644 index 00000000000..6a0f6b41fb3 --- /dev/null +++ b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHerosHeadItemNode.cs @@ -0,0 +1,35 @@ + +using UnityEngine; +using UnityEngine.UI; +using TMPro; + +//角色显示设置类 +public class UIHerosHeadItemNode : UIHeadItemNodeBase +{ + public Image Image_BattleReady; + //public Image Image_BattleReadyArrow; + public Image Image_HP_BG; + public Image Image_BattleHp; + public Image Image_BattleArmor; + //public Image Image_CharacteStatusBar; + //public Image Image_CharacterShadow; + public Image Image_SkillCDFull; + public Image Image_HeadPic; + public Image Image_professionSapper; + public Image Image_StateRetreat; + public Image Image_MoraleStatusBar; + //public Image Image_StatusBarBlue; + public Image Image_BattleMorale; + public Button Button_CharacterPicRect; + //public Image Image_Dead; + public Image Image_Selected; + public GameObject GameObject_HP; + public GameObject Content; + public TMP_Text Text_Number; + public Image Image_Number; + + public ButtonUpDrag ButtonEx_CharacterPicRect; + + + +} diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/UIHerosHeadItemNode.cs.meta b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHerosHeadItemNode.cs.meta similarity index 100% rename from ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/UIHerosHeadItemNode.cs.meta rename to ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIHerosHeadItemNode.cs.meta diff --git a/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIVehicleHeadItemNode.cs b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIVehicleHeadItemNode.cs new file mode 100644 index 00000000000..3b2429eea93 --- /dev/null +++ b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIVehicleHeadItemNode.cs @@ -0,0 +1,25 @@ + +using UnityEngine; +using UnityEngine.UI; + +public class UIVehicleHeadItemNode: UIHeadItemNodeBase +{ + public Image Image_VehicleStatusBar; + public Image Image_V_BattleHp; + public Image Image_V_BattleArmor; + //public Image Image_VehicleShadow; + public Image Image_V_HeadPic; + //public Image Image_V_profession; + public Image Image_V_StateParalysis; + public Image Image_V_MoraleStatusBar; + //public Image Image_V_StatusBarBlue; + //public Image Image_V_BattleMorale; + public UIButtonEx Button_VehiclePicRect; + public ButtonUpDrag ButtonUpDrag_VehiclePicRect; + public Image Image_V_SkillCDFull; + public Image Image_Selected; + public Image Image_Order; + public Image Image_BattleReady; + public GameObject Content; + +} \ No newline at end of file diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/UIVehicleHeadItemNode.cs.meta b/ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIVehicleHeadItemNode.cs.meta similarity index 100% rename from ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/FightReady/UIVehicleHeadItemNode.cs.meta rename to ProjectNLD/Assets/Code/Scripts/GameWrapper/UINode/UIVehicleHeadItemNode.cs.meta diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIHeadItemNode.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIHeadItemNodeLogic.cs similarity index 85% rename from ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIHeadItemNode.cs rename to ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIHeadItemNodeLogic.cs index 8237dea2373..cc9c9649c7d 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIHeadItemNode.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/Common/UIHeadItemNodeLogic.cs @@ -1,5 +1,4 @@ -using System; -using cfg.CharacterCfg; +using System; using Framework; using Gameplay; using PhxhSDK; @@ -7,10 +6,7 @@ using TMPro; using UnityEngine; using UnityEngine.UI; -/// -/// 角色及载具头像UI设置基类 -/// -public class UIHeadItemNode : UINode +public class UIHeadItemNodeLogic : UINode { protected uint uid; protected UIHeadInfo uiheadInfo; @@ -64,7 +60,7 @@ public class UIHeadItemNode : UINode public override void OnAwake() { - base.OnAwake(); + //base.OnAwake(); _GetComponents(); } @@ -88,6 +84,7 @@ public class UIHeadItemNode : UINode private void _GetComponents() { root = gameObject; + var uiHeadNode = root.GetComponent(); imgBg = _GetComponent("Content/ImageBg"); imgTeamProBg = _GetComponent("Content/ImageJob"); imgTeamProName = _GetComponent("Content/ImageJob/ImageName"); @@ -102,17 +99,29 @@ public class UIHeadItemNode : UINode imgSelect = _GetComponent("Content/ImageSelected"); GoPro = _FindObj("Content/ImageProfession"); txtLeadership = _GetComponent("Content/Image_CostBg/Text_CommandCost"); - + if (uiHeadNode) + { + buttonHead = uiHeadNode.buttonHead; + } + + if (!buttonHead) + { + buttonHead = _GetComponent