From 8bce7d89dcfcc750c19b8d27f45905fe17849c8c Mon Sep 17 00:00:00 2001 From: wuwenbo Date: Mon, 22 Jun 2026 20:03:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E6=89=B9=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TH1_Logic/Action/AttackAllyActionLogic.cs | 1 + .../Skill/AllSkill/SanaeDivineSkill.cs | 3 +- .../Skill/AllSkill/SuwakoHebiSkill.cs | 13 +++++++-- .../Scripts/TH1_Logic/Unit/UnitLogic.cs | 28 ++++++++++++++----- .../Scripts/TH1_Renderer/MapRenderer.cs | 6 ++-- .../View/Bottom/UIBottomRankingRowMono.cs | 11 ++++++-- 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/Unity/Assets/Scripts/TH1_Logic/Action/AttackAllyActionLogic.cs b/Unity/Assets/Scripts/TH1_Logic/Action/AttackAllyActionLogic.cs index cc2264b12..a272134fe 100644 --- a/Unity/Assets/Scripts/TH1_Logic/Action/AttackAllyActionLogic.cs +++ b/Unity/Assets/Scripts/TH1_Logic/Action/AttackAllyActionLogic.cs @@ -213,6 +213,7 @@ namespace Logic.Action //处理SuwakoHebi的合并 if (unit1.GetSkill(SkillType.SUWAKOHEBI, out var _)) { + if (!SuwakoHebiSkill.CanCombineToNextLevel(unit2)) return false; NotProjectile = true; //unit2.UnitFullType.UnitLevel++; var unitFullType = unit2.UnitFullType; diff --git a/Unity/Assets/Scripts/TH1_Logic/Skill/AllSkill/SanaeDivineSkill.cs b/Unity/Assets/Scripts/TH1_Logic/Skill/AllSkill/SanaeDivineSkill.cs index 3559fcff3..60b76451f 100644 --- a/Unity/Assets/Scripts/TH1_Logic/Skill/AllSkill/SanaeDivineSkill.cs +++ b/Unity/Assets/Scripts/TH1_Logic/Skill/AllSkill/SanaeDivineSkill.cs @@ -266,6 +266,8 @@ namespace Logic.Skill private void OmikujiAnim(MapData mapData,GridData origin,GridData target, SanaeDivineType divine) { if (mapData == null || origin == null || target == null) return; + var mainMap = Main.MapData; + if (mapData != mainMap || mainMap?.GridMap == null || mainMap.PlayerMap?.SelfPlayerData?.Sight == null) return; if (origin.InMainSight() || target.InMainSight()) { if (Table.Instance == null) return; @@ -609,4 +611,3 @@ namespace Logic.Skill } } } - diff --git a/Unity/Assets/Scripts/TH1_Logic/Skill/AllSkill/SuwakoHebiSkill.cs b/Unity/Assets/Scripts/TH1_Logic/Skill/AllSkill/SuwakoHebiSkill.cs index e8e7ac765..b83aa95aa 100644 --- a/Unity/Assets/Scripts/TH1_Logic/Skill/AllSkill/SuwakoHebiSkill.cs +++ b/Unity/Assets/Scripts/TH1_Logic/Skill/AllSkill/SuwakoHebiSkill.cs @@ -33,10 +33,10 @@ namespace Logic.Skill public override bool IsCanAttackTargetAlly(MapData map,UnitData self, UnitData target) { - //不能已经满级 - if (self.UnitLevel == 5) return false; + if (map == null || self == null || target == null) return false; //必须是同类 if (target.UnitFullType != self.UnitFullType) return false; + if (!CanCombineToNextLevel(target)) return false; //必须是同一阵营 if (target.Player(map) != self.Player(map)) return false; //必须是距离1 @@ -59,6 +59,14 @@ namespace Logic.Skill return false; } + public static bool CanCombineToNextLevel(UnitData target) + { + if (target == null || Table.Instance?.UnitTypeDataAssets == null) return false; + var targetFullType = target.UnitFullType; + targetFullType.UnitLevel++; + return Table.Instance.UnitTypeDataAssets.GetUnitTypeInfo(targetFullType, out _); + } + public override bool IsCanAttackAlly() { return true; @@ -163,4 +171,3 @@ namespace Logic.Skill } } } - diff --git a/Unity/Assets/Scripts/TH1_Logic/Unit/UnitLogic.cs b/Unity/Assets/Scripts/TH1_Logic/Unit/UnitLogic.cs index 12f38aa71..8e8ae6a3e 100644 --- a/Unity/Assets/Scripts/TH1_Logic/Unit/UnitLogic.cs +++ b/Unity/Assets/Scripts/TH1_Logic/Unit/UnitLogic.cs @@ -1975,11 +1975,20 @@ namespace Logic //生命周期: 1 . 卸载所有原来的skill //TODO 要迭代这块,主要是在skill那边要加标记,确认一个skill是否可以继承,是否transfrom的时候要删掉之类的,要不要触发情况等等 - Table.Instance.UnitTypeDataAssets.GetUnitTypeInfo(unitData.UnitType, unitData.GiantType, unitData.UnitLevel, out var originInfo); - Table.Instance.UnitTypeDataAssets.GetUnitTypeInfo(targetType, giantType, unitLevel, out var targetInfo); - if (originInfo == null || targetInfo == null) return; + var originFullTypeBeforeTransform = unitData.UnitFullType; + var targetFullTypeBeforeTransform = new UnitFullType(targetType, giantType, unitLevel); + if (!Table.Instance.UnitTypeDataAssets.GetUnitTypeInfo(originFullTypeBeforeTransform, out var originInfo)) + { + LogSystem.LogError($"UnitTypeTransform failed: origin unit type not found. unitId:{unitData.Id} origin:{FormatUnitFullType(originFullTypeBeforeTransform)} target:{FormatUnitFullType(targetFullTypeBeforeTransform)}"); + return; + } + if (!Table.Instance.UnitTypeDataAssets.GetUnitTypeInfo(targetFullTypeBeforeTransform, out var targetInfo)) + { + LogSystem.LogError($"UnitTypeTransform failed: target unit type not found. unitId:{unitData.Id} origin:{FormatUnitFullType(originFullTypeBeforeTransform)} target:{FormatUnitFullType(targetFullTypeBeforeTransform)}"); + return; + } var previousFullTypeForBoatOnLandLog = unitData.UnitFullType; - var requestedFullTypeForBoatOnLandLog = new UnitFullType(targetType, giantType, unitLevel); + var requestedFullTypeForBoatOnLandLog = targetFullTypeBeforeTransform; unitData.SkillCache ??= new List(); unitData.Skills ??= new List(); @@ -2008,7 +2017,7 @@ namespace Logic } catch (Exception e) { - LogSystem.LogError($"UnitTypeTransform ReservedOnTransform failed. skill:{skill.GetType().Name} ex:{e.Message}"); + LogSystem.LogError($"UnitTypeTransform ReservedOnTransform failed. unitId:{unitData.Id} origin:{FormatUnitFullType(originFullTypeBeforeTransform)} target:{FormatUnitFullType(targetFullTypeBeforeTransform)} skill:{skill.GetType().Name} skillType:{skill.GetSkillType()} ex:{e}"); reserved = false; } @@ -2065,8 +2074,8 @@ namespace Logic } } - var originFullType = new UnitFullType(unitData.UnitType, unitData.GiantType, unitData.UnitLevel); - var targetFullType = new UnitFullType(targetType, giantType, unitLevel); + var originFullType = originFullTypeBeforeTransform; + var targetFullType = targetFullTypeBeforeTransform; if (mapData.GetPlayerDataByUnitId(unitData.Id, out var playerData)) { @@ -2089,6 +2098,11 @@ namespace Logic previousFullTypeForBoatOnLandLog, requestedFullTypeForBoatOnLandLog); } + private static string FormatUnitFullType(UnitFullType fullType) + { + return $"{fullType.UnitType}/{fullType.GiantType}/{fullType.UnitLevel}"; + } + public void PassiveMoveAway(MapData mapData,UnitData unitData) { if (!mapData.GetGridDataByUnitId(unitData.Id, out var gridData)) diff --git a/Unity/Assets/Scripts/TH1_Renderer/MapRenderer.cs b/Unity/Assets/Scripts/TH1_Renderer/MapRenderer.cs index 78b7ccf85..e26c82847 100644 --- a/Unity/Assets/Scripts/TH1_Renderer/MapRenderer.cs +++ b/Unity/Assets/Scripts/TH1_Renderer/MapRenderer.cs @@ -701,7 +701,8 @@ namespace TH1Renderer { targetGridData.Renderer(Main.MapData)?.PlayVFXInSight(new GridVFXParams(GridVFXType.CounterDieHint),GridVFXPlayType.Play); } - ROUnitMap[unitDataB.Id].SetAttackHighlight(true); + if (ROUnitMap.TryGetValue(unitDataB.Id, out var targetUnitRenderer)) + targetUnitRenderer.SetAttackHighlight(true); } //如果是友军目标,且unit的AP>0 if (sig == MoveAttackType.Ally && unitData.GetActionPoint(ActionPointType.Attack) > 0) @@ -710,7 +711,8 @@ namespace TH1Renderer if (!targetGridData.MainSelfPlayerVisibleUnit(out var unitDataB)) continue; - ROUnitMap[unitDataB.Id].SetAllyHighlight(true); + if (ROUnitMap.TryGetValue(unitDataB.Id, out var targetUnitRenderer)) + targetUnitRenderer.SetAllyHighlight(true); } //如果是攻击ground目标,且unit的AP>0 if (sig == MoveAttackType.AttackGround && diff --git a/Unity/Assets/Scripts/TH1_UI/View/Bottom/UIBottomRankingRowMono.cs b/Unity/Assets/Scripts/TH1_UI/View/Bottom/UIBottomRankingRowMono.cs index 0daeefce0..cb0b4b6d3 100644 --- a/Unity/Assets/Scripts/TH1_UI/View/Bottom/UIBottomRankingRowMono.cs +++ b/Unity/Assets/Scripts/TH1_UI/View/Bottom/UIBottomRankingRowMono.cs @@ -93,7 +93,7 @@ namespace TH1_UI.View.Info Union.SetActive(false); } //未相遇的对手 - else if (!selfPlayer.MeetPlayers.Contains(player.Id)) + else if (!HasMetPlayer(selfPlayer, player)) { RefreshForceName(); Avatar.sprite = Table.Instance.PlayerDataAssets.CommonPlayerAvatar; @@ -157,7 +157,7 @@ namespace TH1_UI.View.Info ForceName.text = Logic.PlayerLogic.GetDisplayForceName(Main.MapData, _player); ForceName.color = Color.gray; } - else if (selfPlayer != null && !selfPlayer.MeetPlayers.Contains(_player.Id)) + else if (!HasMetPlayer(selfPlayer, _player)) { ForceName.text = "???"; ForceName.color = NormalRankTextColor; @@ -197,6 +197,13 @@ namespace TH1_UI.View.Info return confirm != null && confirm.IsNeedAI(); } + private static bool HasMetPlayer(PlayerData selfPlayer, PlayerData player) + { + if (selfPlayer == null || player == null) return false; + if (selfPlayer.Id == player.Id) return true; + return selfPlayer.MeetPlayers?.Contains(player.Id) == true; + } + private void SetForceNameActive(bool active) { if (ForceName != null) ForceName.gameObject.SetActive(active);