From 35e1332c385226a4f57c4294c19045a8aed9abe6 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 10 九月 2025 17:09:52 +0800
Subject: [PATCH] 125 【战斗】战斗系统 目标选择规则&bug修复
---
Main/System/Battle/SkillEffect/NormalSkillEffect.cs | 27 +++++---
Main/System/Battle/BattleUtility.cs | 108 ++++++++++++++++++++++++++----------
Main/System/Battle/Skill/SkillBase.cs | 29 ++++++++-
Main/System/Battle/Skill/SkillCastMode.cs | 2
4 files changed, 123 insertions(+), 43 deletions(-)
diff --git a/Main/System/Battle/BattleUtility.cs b/Main/System/Battle/BattleUtility.cs
index c37887b..23774fe 100644
--- a/Main/System/Battle/BattleUtility.cs
+++ b/Main/System/Battle/BattleUtility.cs
@@ -176,68 +176,116 @@
// 3 鍚庢帓
// 4 绾垫帓锛屾寜瀵逛綅瑙勫垯閫夋嫨绾垫帓
// 5 鑷繁锛岄粯璁ゅ彧閫夎嚜宸�
- // 6 缁ф壙涓绘妧鑳�/鏉ユ簮鎶�鑳界洰鏍�
- // 涓�鑸槸棰濆瑙﹀彂鐨勬妧鑳戒娇鐢紝濡傛鐜囬檮鍔犳煇buff
- // 棰濆瑙﹀彂鐨勬妧鑳藉鏋滅洰鏍囦笌涓绘妧鑳戒笉涓�鑷达紝鍒欓噸鏂拌瀹氱洰鏍囧嵆鍙�
- // 鎴栬鍔ㄨЕ鍙戠殑鎶�鑳斤紝鍙户鎵胯Е鍙戞潵婧愭妧鑳界殑鏀婚槻鍙屾柟鍏崇郴
switch (skillConfig.TagAim)
{
case 0:
- // 鍏ㄩ儴鑼冨洿
- //鍏ㄩ儴鑼冨洿+鏁屾垜+鐩爣鏁伴噺涓�6
- //灏辨槸鍙栨晫鎴戠珯浣嶄腑鐨�2鍙蜂綅
- returnIndex = 1;
- break;
- case 1:
- returnIndex = caster.teamHero.positionNum;
- // 瀵绘壘瀵逛綅鏄惁鏈変汉 娌℃湁鐨勮瘽閫夋嫨鏈�灏忕殑
- List<BattleObject> opposite = new List<BattleObject>(from bo in targetObjList where !bo.IsDead() && bo.teamHero.positionNum == returnIndex select bo);
- if (opposite.Count > 0)
+ // 0 鍏ㄩ儴鑼冨洿锛�
+ // 鑻agCount鐩爣涓暟涓�0鎴�6锛屾牴鎹甌agFriendly鏁屾垜閰嶇疆锛屼唬琛ㄤ綔鐢ㄤ簬鏁屾柟鍏ㄤ綋鎴栨垜鏂瑰叏浣擄紝姝ゆ椂涓荤洰鏍囦负鏁屾垜绔欎綅涓殑2鍙蜂綅缃�
+ // 鑻agCount鐩爣涓暟涓�1~5涓紝鏍规嵁TagFriendly鏁屾垜+TagAffect缁嗗垎鐩爣閰嶇疆锛屼唬琛ㄩ殢鏈轰綔鐢ㄤ簬鏁屾柟鎴栨垜鏂箈涓灏嗭紝绗竴涓负涓荤洰鏍�
+ if (skillConfig.TagCount == 0 || skillConfig.TagCount == 6)
{
- returnIndex = opposite[0].teamHero.positionNum;
+ returnIndex = 1;
}
else
{
- opposite = new List<BattleObject>(from bo in targetObjList where !bo.IsDead() select bo);
- opposite.Sort((a, b) => a.teamHero.positionNum.CompareTo(b.teamHero.positionNum));
- returnIndex = opposite.Count > 0 ? opposite[0].teamHero.positionNum : returnIndex;
+ uint objId = targetList[0].ObjID;
+ BattleObject target = caster.battleField.battleObjMgr.GetBattleObject((int)objId);
+ return target.teamHero.positionNum;
+ }
+ break;
+ case 1:
+ // 1 瀵逛綅锛�
+ // 榛樿鍙��1涓紝瀵逛綅瑙勫垯涓篈1浼樺厛鎵揃1锛孉2浼樺厛鎵揃2锛孉3浼樺厛鎵揃3锛屽浣嶇洰鏍囨浜℃椂锛屼紭鍏堝墠鎺掞紝姣斿B2宸茬粡姝讳骸锛岄偅涔圓2灏嗕紭鍏堟墦B1锛屽墠鎺�1銆�2銆�3鍙蜂綅缃叏閮ㄦ浜′箣鍚庢墠寮�濮嬮�夋嫨鍚庢帓4銆�5銆�6鍙蜂綅缃紝瀵逛綅鍙彲閫�1涓洰鏍囷紝鍗充富鐩爣
+ if (targetList.Count > 0)
+ {
+ BattleObject battleObject = caster.battleField.battleObjMgr.GetBattleObject((int)targetList[0].ObjID);
+ if (battleObject != null)
+ {
+ returnIndex = battleObject.teamHero.positionNum;
+ }
+ else
+ {
+ Debug.LogError("GetMainTargetPositionNum 鎵句笉鍒扮洰鏍� ObjId : " + targetList[0].ObjID);
+ returnIndex = 0;
+ }
+ }
+ else
+ {
+ Debug.LogError("targetList 鐩爣鍒楄〃涓虹┖");
+ returnIndex = 0;
}
break;
case 2:
- // 鐪嬬湅瀵归潰鍓嶆帓鏄惁閮芥椿鐫�
- List<BattleObject> front = new List<BattleObject>(from bo in targetObjList where !bo.IsDead() && bo.teamHero.positionNum < 3 select bo);
- if (front.Count > 0)
+ // 1銆�2銆�3鍙蜂綅涓哄墠鎺掞紝榛樿2鍙蜂綅缃负涓荤洰鏍囷紝褰�1銆�2銆�3鍙蜂綅缃鑹插叏閮ㄦ浜★紝鍓嶆帓灏嗘浛鎹㈡垚鍚庢帓锛�5鍙蜂綅缃彉鏇翠负涓荤洰鏍囷紝
+ // 鑻ラ厤缃甌agAffect缁嗗垎鐩爣锛屼笖浜烘暟灏忎簬3锛屽垯鎵�鏈夎閫夋嫨鐩爣鍧囦负涓荤洰鏍囷紙鏂芥硶浣嶇疆浼氱敤瀹㈡埛绔厤缃級
+ // 锛堝嵆鍓嶆帓榛樿2鍙蜂綅鎴�5鍙蜂綅瑙勫垯鏃犳晥锛屽疄闄呬綔鐢ㄥ灏戜汉灏辨槸澶氬皯涓富鐩爣锛� (YL : TagAffect>0 && TagAffect != 3灏辨槸鍏ㄤ綋閮芥槸涓荤洰鏍� 鍚庢帓涓�鏍� )
+ if (skillConfig.TagAffect != 0 && skillConfig.TagAffect != 3 && skillConfig.TagCount < 3)
{
- returnIndex = 1;
+ uint objId = targetList[0].ObjID;
+ BattleObject target = caster.battleField.battleObjMgr.GetBattleObject((int)objId);
+ returnIndex = target.teamHero.positionNum;
}
else
{
- returnIndex = 4;
+ // 鐪嬬湅瀵归潰鍓嶆帓鏄惁閮芥椿鐫�
+ List<BattleObject> front = new List<BattleObject>(from bo in targetObjList where !bo.IsDead() && bo.teamHero.positionNum < 3 select bo);
+ if (front.Count > 0)
+ {
+ returnIndex = 1;
+ }
+ else
+ {
+ returnIndex = 4;
+ }
}
break;
case 3:
- // 鐪嬬湅瀵归潰鍚庢帓鏄惁閮芥椿鐫�
- List<BattleObject> back = new List<BattleObject>(from bo in targetObjList where !bo.IsDead() && bo.teamHero.positionNum >= 3 select bo);
- if (back.Count > 0)
+ if (skillConfig.TagAffect != 0 && skillConfig.TagAffect != 3 && skillConfig.TagCount < 3)
{
- returnIndex = 4;
+ uint objId = targetList[0].ObjID;
+ BattleObject target = caster.battleField.battleObjMgr.GetBattleObject((int)objId);
+ returnIndex = target.teamHero.positionNum;
}
else
{
- returnIndex = 1;
+ // 鐪嬬湅瀵归潰鍚庢帓鏄惁閮芥椿鐫�
+ List<BattleObject> back = new List<BattleObject>(from bo in targetObjList where !bo.IsDead() && bo.teamHero.positionNum >= 3 select bo);
+ if (back.Count > 0)
+ {
+ returnIndex = 4;
+ }
+ else
+ {
+ returnIndex = 1;
+ }
}
break;
// 4 绾垫帓锛屾寜瀵逛綅瑙勫垯閫夋嫨绾垫帓
case 4:
- List<BattleObject> vertical = new List<BattleObject>(from bo in targetObjList where !bo.IsDead() && (bo.teamHero.positionNum - caster.teamHero.positionNum) % 3 == 0 select bo);
- // TODO YYL
+ returnIndex = int.MaxValue;
+ for (int i = 0; i < targetList.Count; i++)
+ {
+ var hurt = targetList[i];
+ BattleObject target = caster.battleField.battleObjMgr.GetBattleObject((int)hurt.ObjID);
+ if (target == null)
+ {
+ Debug.LogError("GetMainTargetPositionNum 鎵句笉鍒扮洰鏍� ObjId : " + hurt.ObjID);
+ continue;
+ }
+ else
+ {
+ returnIndex = Mathf.Min(returnIndex, target.teamHero.positionNum);
+ }
+ }
break;
// 5 鑷繁锛岄粯璁ゅ彧閫夎嚜宸�
case 5:
returnIndex = caster.teamHero.positionNum;
break;
default:
+ Debug.LogError("鏆傛椂涓嶆敮鎸佸叾浠栫殑鏂瑰紡閫夋嫨涓荤洰鏍� 鏈夐渶姹傝鑱旂郴绛栧垝 鎶�鑳絠d:" + skillConfig.SkillID + " TagAim " + skillConfig.TagAim);
+ returnIndex = 0;
break;
}
diff --git a/Main/System/Battle/Skill/SkillBase.cs b/Main/System/Battle/Skill/SkillBase.cs
index f68863f..474444e 100644
--- a/Main/System/Battle/Skill/SkillBase.cs
+++ b/Main/System/Battle/Skill/SkillBase.cs
@@ -116,9 +116,9 @@
case SkillCastMode.Allies:
CastToAllies();
break;
- // case SkillCastMode.DashCast:
- // DashToTarget(() => BackToOrigin(OnSkillFinished));
- // break;
+ case SkillCastMode.DashCast:
+ DashCast(OnAttackFinish);
+ break;
default:
Debug.LogError("鏆傛椂涓嶆敮鎸佸叾浠栫殑鏂瑰紡閲婃斁 鏈夐渶姹傝鑱旂郴绛栧垝 鎶�鑳絠d:" + skillConfig.SkillID + " cast position " + skillConfig.CastPosition);
OnSkillFinished();
@@ -127,6 +127,29 @@
}
+ // 鍐叉挒鏀诲嚮
+ protected void DashCast(Action _onComplete)
+ {
+ Debug.LogError("DashCast 杩樻病瀹炵幇");
+ // YYL TODO
+
+ // var entry = caster.motionBase.PlayAnimation(skillConfig.GetMotionName(), false);
+ // float animationTime = entry.AnimationTime;
+
+ // int mainTargetPosNum = BattleUtility.GetMainTargetPositionNum(caster, tagUseSkillAttack.HurtList.ToList(), skillConfig);
+
+ // BattleCamp battleCamp = skillConfig.TagFriendly != 0 ? caster.Camp : caster.GetEnemyCamp();
+
+ // RectTransform targetTrans = battleField.GetTeamNode(battleCamp, mainTargetPosNum);
+
+ // var tweener = BattleUtility.MoveToTarget(caster.heroRectTrans, targetTrans, new Vector2(skillConfig.CastDistance, 0), animationTime * 0.9f, () =>
+ // {
+ // caster.motionBase.PlayAnimation(MotionName.idle, true);
+ // _onComplete?.Invoke();
+ // });
+ // battleField.battleTweenMgr.OnPlayTween(tweener);
+ }
+
protected void MoveToTarget(RectTransform target, Vector2 offset, float duration, Action onComplete = null)
{
// 鍘熷湴閲婃斁
diff --git a/Main/System/Battle/Skill/SkillCastMode.cs b/Main/System/Battle/Skill/SkillCastMode.cs
index 413fed4..36fd14d 100644
--- a/Main/System/Battle/Skill/SkillCastMode.cs
+++ b/Main/System/Battle/Skill/SkillCastMode.cs
@@ -17,4 +17,6 @@
Target,
+ DashCast, //閲婃斁鎶�鑳藉啿鍒哄埌鐩爣浣嶇疆
+
}
\ No newline at end of file
diff --git a/Main/System/Battle/SkillEffect/NormalSkillEffect.cs b/Main/System/Battle/SkillEffect/NormalSkillEffect.cs
index a124a4a..b185387 100644
--- a/Main/System/Battle/SkillEffect/NormalSkillEffect.cs
+++ b/Main/System/Battle/SkillEffect/NormalSkillEffect.cs
@@ -20,6 +20,23 @@
public override void OnMiddleFrameEnd(int times, int hitIndex)
{
+
+ int mainTargetIndex = BattleUtility.GetMainTargetPositionNum(caster, tagUseSkillAttack.HurtList.ToList(), skillConfig);
+
+ BattleCamp battleCamp = skillConfig.TagFriendly == 1 ? caster.Camp : caster.GetEnemyCamp();
+
+ RectTransform targetTransform = caster.battleField.GetTeamNode(battleCamp, mainTargetIndex);
+
+ if (skillConfig.ExplosionEffectId > 0)
+ {
+ caster.battleField.battleEffectMgr.PlayEffect(0, skillConfig.ExplosionEffectId, targetTransform, battleCamp);
+ }
+
+ if (skillConfig.ExplosionEffect2 > 0)
+ {
+ caster.battleField.battleEffectMgr.PlayEffect(0, skillConfig.ExplosionEffect2, targetTransform, battleCamp);
+ }
+
for (int i = 0; i < tagUseSkillAttack.HurtList.Length; i++)
{
var hurt = tagUseSkillAttack.HurtList[i];
@@ -28,16 +45,6 @@
{
Debug.LogError("鐗规晥鐩爣涓虹┖ target == null ObjId : " + hurt.ObjID);
continue;
- }
-
- if (skillConfig.ExplosionEffectId > 0)
- {
- caster.battleField.battleEffectMgr.PlayEffect(target.ObjID, skillConfig.ExplosionEffectId, target.heroGo.transform, target.Camp);
- }
-
- if (skillConfig.ExplosionEffect2 > 0)
- {
- caster.battleField.battleEffectMgr.PlayEffect(target.ObjID, skillConfig.ExplosionEffect2, target.heroGo.transform, target.Camp);
}
if (skillConfig.ExplosionEffect3 > 0)
--
Gitblit v1.8.0