diff --git a/.gitignore b/.gitignore index 7d1d397..db5372d 100644 --- a/.gitignore +++ b/.gitignore @@ -78,6 +78,7 @@ crashlytics-build.properties /Assets/StreamingAssets /Assets/StreamingAssets.meta +/Assets/StreamingAssets /UI参考 /AGENTS.md /bin diff --git a/Assets/GameMain/Configs/ResourceBuilder.xml b/Assets/GameMain/Configs/ResourceBuilder.xml index 5eb1750..f3962df 100644 --- a/Assets/GameMain/Configs/ResourceBuilder.xml +++ b/Assets/GameMain/Configs/ResourceBuilder.xml @@ -2,14 +2,18 @@ +<<<<<<< Updated upstream 5 +======= + 4 +>>>>>>> Stashed changes 33 1 UnityGameFramework.Runtime.DefaultCompressionHelper True False StarForce.Editor.StarForceBuildEventHandler - D:/Learn/GameLearn/UnityProjects/VampireLike/bin/AssetBundles + C:/UnityProjects/VampireLike/bin/AssetBundles True True True diff --git a/Assets/GameMain/Scripts/UI/GameScene/Controller/DisplayItemInfoFormController.cs b/Assets/GameMain/Scripts/UI/GameScene/Controller/DisplayItemInfoFormController.cs index 5f0161f..19ce4dc 100644 --- a/Assets/GameMain/Scripts/UI/GameScene/Controller/DisplayItemInfoFormController.cs +++ b/Assets/GameMain/Scripts/UI/GameScene/Controller/DisplayItemInfoFormController.cs @@ -1,6 +1,7 @@ using CustomEvent; using Definition.Enum; using GameFramework.Event; +using UnityEngine; using UnityGameFramework.Runtime; namespace UI @@ -38,6 +39,7 @@ namespace UI { if (rawData == null) { + Log.Error("DisplayItemInfoFormController.BuildContext() rawData is null."); return null; } @@ -92,20 +94,75 @@ namespace UI } } + private bool IsCurrentFormSender(object sender) + { + if (sender is DisplayItemInfoForm displayItemInfoForm) + { + return displayItemInfoForm == Form; + } + + if (sender is Component component && Form != null) + { + return component.transform.IsChildOf(Form.transform); + } + + return false; + } + #region Event Handlers private void DisplayItemInfoLock(object sender, GameEventArgs e) { - if (!(e is DisplayItemInfoLockEventArgs)) return; + if (!(e is DisplayItemInfoLockEventArgs)) + { + return; + } + + if (Context == null) + { + Log.Error("DisplayItemInfoFormController.DisplayItemInfoLock() Context is null."); + return; + } + + if (Form == null) + { + Log.Error("DisplayItemInfoFormController.DisplayItemInfoLock() Form is null."); + return; + } _locked = true; } private void DisplayItemInfoHide(object sender, GameEventArgs e) { - if (!(e is DisplayItemInfoHideEventArgs args)) return; + if (!(e is DisplayItemInfoHideEventArgs args)) + { + return; + } - if (!args.Force && _locked && sender is not DisplayItemInfoForm) return; + if (Context == null) + { + Log.Error("DisplayItemInfoFormController.DisplayItemInfoHide() Context is null."); + return; + } + + if (Form == null) + { + Log.Error("DisplayItemInfoFormController.DisplayItemInfoHide() Form is null."); + return; + } + + if (args.Force) + { + GameEntry.UIRouter.CloseUI(UIFormType.DisplayItemInfoForm); + _locked = false; + return; + } + + if (_locked && !IsCurrentFormSender(sender) && sender is not DisplayItem) + { + return; + } GameEntry.UIRouter.CloseUI(UIFormType.DisplayItemInfoForm); _locked = false; @@ -113,4 +170,4 @@ namespace UI #endregion } -} \ No newline at end of file +} diff --git a/Assets/GameMain/Scripts/UI/GameScene/Controller/LevelUpFormController.cs b/Assets/GameMain/Scripts/UI/GameScene/Controller/LevelUpFormController.cs index dc6fda8..ce405fe 100644 --- a/Assets/GameMain/Scripts/UI/GameScene/Controller/LevelUpFormController.cs +++ b/Assets/GameMain/Scripts/UI/GameScene/Controller/LevelUpFormController.cs @@ -32,8 +32,15 @@ namespace UI private static LevelUpFormContext BuildContext(LevelUpFormRawData rawData) { - if (rawData == null || rawData.Rewards == null) + if (rawData == null) { + Log.Error("LevelUpFormController.BuildContext() rawData is null."); + return null; + } + + if (rawData.Rewards == null) + { + Log.Error("LevelUpFormController.BuildContext() rewards are null."); return null; } @@ -143,7 +150,7 @@ namespace UI private void OnRefresh(object sender, GameEventArgs e) { - if (!(sender is LevelUpForm)) + if (sender != Form) { return; } @@ -158,6 +165,11 @@ namespace UI private void OnLevelUpPropSelected(object sender, GameEventArgs e) { + if (sender != Form) + { + return; + } + if (!(e is LevelUpPropSelectedEventArgs args)) { return; diff --git a/Assets/GameMain/Scripts/UI/GameScene/Controller/ShopFormController.cs b/Assets/GameMain/Scripts/UI/GameScene/Controller/ShopFormController.cs index f305048..59b2a7b 100644 --- a/Assets/GameMain/Scripts/UI/GameScene/Controller/ShopFormController.cs +++ b/Assets/GameMain/Scripts/UI/GameScene/Controller/ShopFormController.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using CustomEvent; using Definition.DataStruct; using Definition.Enum; -using Entity; using CustomUtility; using Entity.Weapon; using GameFramework.Event; @@ -47,6 +46,7 @@ namespace UI { if (rawData == null) { + Log.Error("ShopFormController.BuildContext() rawData is null."); return null; } @@ -171,8 +171,15 @@ namespace UI private static void AppendDisplayItemContext(DisplayListAreaContext listContext, DisplayItemContext newItem) { - if (listContext == null || newItem == null) + if (listContext == null) { + Log.Error("ShopFormController.AppendDisplayItemContext() listContext is null."); + return; + } + + if (newItem == null) + { + Log.Warning("ShopFormController.AppendDisplayItemContext() newItem is null."); return; } @@ -243,8 +250,15 @@ namespace UI private void RefreshGoodsItems(ShopRefreshResult result) { - if (Context == null || result == null) + if (result == null) { + Log.Error("ShopFormController.RefreshGoodsItems() result is null."); + return; + } + + if (Context == null) + { + Log.Error("ShopFormController.RefreshGoodsItems() Context is null."); return; } @@ -253,6 +267,7 @@ namespace UI if (Form == null) { + Log.Error("ShopFormController.RefreshGoodsItems() Form is null."); return; } @@ -262,8 +277,15 @@ namespace UI private void ApplyGoodsPurchased(ShopPurchaseResult result) { - if (Context == null || result == null) + if (result == null) { + Log.Error("ShopFormController.ApplyGoodsPurchased() result is null."); + return; + } + + if (Context == null) + { + Log.Error("ShopFormController.ApplyGoodsPurchased() Context is null."); return; } @@ -287,6 +309,104 @@ namespace UI Form?.ApplyGoodsPurchased(result.GoodsIndex, result.DisplayItem); } + private bool IsCurrentFormEventSender(object sender) + { + if (sender is ShopForm shopForm) + { + return shopForm == Form; + } + + if (sender is Component component && Form != null) + { + return component.transform.IsChildOf(Form.transform); + } + + return false; + } + + private bool TryGetWeaponInfoRawData(int index, Vector3 targetPos, out DisplayItemInfoFormRawData rawData) + { + rawData = null; + + if (_rawData?.WeaponItems == null) + { + Log.Error("ShopFormController.TryGetWeaponInfoRawData() WeaponItems is null."); + return false; + } + + if (Context == null) + { + Log.Error("ShopFormController.TryGetWeaponInfoRawData() Context is null."); + return false; + } + + if (index < 0 || index >= _rawData.WeaponItems.Count) + { + Log.Error($"ShopFormController.TryGetWeaponInfoRawData() invalid weapon index: {index}."); + return false; + } + + WeaponBase weapon = _rawData.WeaponItems[index]; + if (weapon?.WeaponData == null) + { + Log.Error($"ShopFormController.TryGetWeaponInfoRawData() weapon data is null at index {index}."); + return false; + } + + var weaponData = weapon.WeaponData; + rawData = new DisplayItemInfoFormRawData + { + TargetPos = targetPos, + Index = index, + IconAssetName = weaponData.IconAssetName, + Title = weaponData.Title, + Rarity = weaponData.Rarity, + TypeText = "武器", + Description = ItemDescUtility.CreateWeaponDescription(weaponData), + Price = Mathf.FloorToInt(weaponData.Price * Context.WeaponRecycleRate), + IsWeapon = true + }; + return true; + } + + private bool TryGetPropInfoRawData(int index, Vector3 targetPos, out DisplayItemInfoFormRawData rawData) + { + rawData = null; + + if (_rawData?.PropItems == null) + { + Log.Error("ShopFormController.TryGetPropInfoRawData() PropItems is null."); + return false; + } + + if (index < 0 || index >= _rawData.PropItems.Count) + { + Log.Error($"ShopFormController.TryGetPropInfoRawData() invalid prop index: {index}."); + return false; + } + + PropItem propItem = _rawData.PropItems[index]; + if (propItem == null) + { + Log.Error($"ShopFormController.TryGetPropInfoRawData() prop item is null at index {index}."); + return false; + } + + rawData = new DisplayItemInfoFormRawData + { + TargetPos = targetPos, + Index = index, + IconAssetName = propItem.IconAssetName, + Title = propItem.Title, + Rarity = propItem.Rarity, + TypeText = "道具", + Description = ItemDescUtility.CreatePropDescription(propItem), + Price = 0, + IsWeapon = false + }; + return true; + } + #endregion #region Event Handlers @@ -350,32 +470,30 @@ namespace UI private void DisplayItemShow(object sender, GameEventArgs e) { - if (!(e is DisplayItemShowEventArgs args) || _rawData == null) return; - - DisplayItemInfoFormRawData rawData = new(); - rawData.TargetPos = args.TargetPos; - rawData.Index = args.Index; - if (args.IsWeapon) + if (!(e is DisplayItemShowEventArgs args)) { - var weaponData = _rawData.WeaponItems[args.Index].WeaponData; - rawData.IconAssetName = weaponData.IconAssetName; - rawData.Title = weaponData.Title; - rawData.Rarity = weaponData.Rarity; - rawData.TypeText = "武器"; - rawData.Description = ItemDescUtility.CreateWeaponDescription(weaponData); - rawData.Price = Mathf.FloorToInt(weaponData.Price * Context.WeaponRecycleRate); - rawData.IsWeapon = true; + return; } - else + + if (!IsCurrentFormEventSender(sender)) { - var propItem = _rawData.PropItems[args.Index]; - rawData.IconAssetName = propItem.IconAssetName; - rawData.Title = propItem.Title; - rawData.Rarity = propItem.Rarity; - rawData.TypeText = "道具"; - rawData.Description = ItemDescUtility.CreatePropDescription(propItem); - rawData.Price = 0; - rawData.IsWeapon = false; + return; + } + + if (_rawData == null) + { + Log.Error("ShopFormController.DisplayItemShow() _rawData is null."); + return; + } + + DisplayItemInfoFormRawData rawData; + bool success = args.IsWeapon + ? TryGetWeaponInfoRawData(args.Index, args.TargetPos, out rawData) + : TryGetPropInfoRawData(args.Index, args.TargetPos, out rawData); + + if (!success) + { + return; } GameEntry.UIRouter.OpenUI(UIFormType.DisplayItemInfoForm, rawData); @@ -383,10 +501,19 @@ namespace UI private void WeaponRecycle(object sender, GameEventArgs e) { - if (!(e is ShopWeaponRecycleEventArgs args)) return; + if (!(e is ShopWeaponRecycleEventArgs args)) + { + return; + } + + if (sender is not DisplayItemInfoForm) + { + return; + } if (_useCase == null || Context == null) { + Log.Error("ShopFormController.WeaponRecycle() controller state is invalid."); return; } diff --git a/Assets/GameMain/Scripts/UI/MenuScene/Controller/SelectRoleFormController.cs b/Assets/GameMain/Scripts/UI/MenuScene/Controller/SelectRoleFormController.cs index c31e86f..5f7006a 100644 --- a/Assets/GameMain/Scripts/UI/MenuScene/Controller/SelectRoleFormController.cs +++ b/Assets/GameMain/Scripts/UI/MenuScene/Controller/SelectRoleFormController.cs @@ -1,6 +1,7 @@ using CustomEvent; using Definition.Enum; using GameFramework.Event; +using UnityEngine; using UnityGameFramework.Runtime; namespace UI @@ -34,6 +35,7 @@ namespace UI { if (rawData == null) { + Log.Error("SelectRoleFormController.BuildContext() rawData is null."); return null; } @@ -107,17 +109,35 @@ namespace UI public void UpdateShowRole(RolePropertyAreaContext rolePropertyAreaContext) { - if (Context != null) + if (Context == null) { - Context.RolePropertyAreaContext = rolePropertyAreaContext; + Log.Error("SelectRoleFormController.UpdateShowRole() Context is null."); + return; } + Context.RolePropertyAreaContext = rolePropertyAreaContext; + Form?.UpdateShowRole(rolePropertyAreaContext); } + private bool IsCurrentFormEventSender(object sender) + { + if (sender is SelectRoleForm selectRoleForm) + { + return selectRoleForm == Form; + } + + if (sender is Component component && Form != null) + { + return component.transform.IsChildOf(Form.transform); + } + + return false; + } + private void OnMenuSelectRoleReturn(object sender, GameEventArgs e) { - if (!(sender is SelectRoleForm) || !(e is MenuSelectRoleReturnEventArgs)) + if (sender != Form || !(e is MenuSelectRoleReturnEventArgs)) { return; } @@ -132,10 +152,22 @@ namespace UI return; } - SelectRoleFormRawData rawData = _useCase != null ? _useCase.SelectRole(args.RoleId) : null; + if (!IsCurrentFormEventSender(sender)) + { + return; + } + + if (_useCase == null) + { + Log.Error("SelectRoleFormController.OnMenuSelectRoleSelected() useCase is null."); + return; + } + + SelectRoleFormRawData rawData = _useCase.SelectRole(args.RoleId); SelectRoleFormContext context = BuildContext(rawData); if (context == null) { + Log.Error("SelectRoleFormController.OnMenuSelectRoleSelected() context build failed."); return; } @@ -150,7 +182,18 @@ namespace UI return; } - _useCase?.ConfirmSelectedRole(); + if (!IsCurrentFormEventSender(sender)) + { + return; + } + + if (_useCase == null) + { + Log.Error("SelectRoleFormController.OnMenuSelectRoleConfirm() useCase is null."); + return; + } + + _useCase.ConfirmSelectedRole(); } } } diff --git a/Assets/Launcher.unity b/Assets/Launcher.unity index 733d6f0..b9d15ea 100644 --- a/Assets/Launcher.unity +++ b/Assets/Launcher.unity @@ -719,7 +719,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 11499388, guid: adb3eb1c35fcff14f89fba7b05c9d71c, type: 3} propertyPath: m_FrameRate - value: 60 + value: 240 objectReference: {fileID: 0} - target: {fileID: 11499388, guid: adb3eb1c35fcff14f89fba7b05c9d71c, type: 3} propertyPath: m_EditorLanguage diff --git a/Assets/StreamingAssets/SceneSettings.dat b/Assets/StreamingAssets/SceneSettings.dat index ff11765..4ec79d0 100644 Binary files a/Assets/StreamingAssets/SceneSettings.dat and b/Assets/StreamingAssets/SceneSettings.dat differ diff --git a/Assets/StreamingAssets/UI/UISprites/SelectRoleFormRT.dat b/Assets/StreamingAssets/UI/UISprites/SelectRoleFormRT.dat index c0a6382..c61b285 100644 Binary files a/Assets/StreamingAssets/UI/UISprites/SelectRoleFormRT.dat and b/Assets/StreamingAssets/UI/UISprites/SelectRoleFormRT.dat differ diff --git a/Assets/StreamingAssets/URPAssets.dat b/Assets/StreamingAssets/URPAssets.dat index d3ee1df..109a3f5 100644 Binary files a/Assets/StreamingAssets/URPAssets.dat and b/Assets/StreamingAssets/URPAssets.dat differ