From 6696f835cfba7fd451d7a78342bb56cdc6e2e940 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 10 九月 2025 14:23:45 +0800
Subject: [PATCH] 125 【战斗】战斗系统 子弹部分代码

---
 Main/System/Battle/BattleUtility.cs |  149 +++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 123 insertions(+), 26 deletions(-)

diff --git a/Main/System/Battle/BattleUtility.cs b/Main/System/Battle/BattleUtility.cs
index 4a2c228..c37887b 100644
--- a/Main/System/Battle/BattleUtility.cs
+++ b/Main/System/Battle/BattleUtility.cs
@@ -4,7 +4,7 @@
 using UnityEngine.UI;
 using DG.Tweening;
 using DG.Tweening.Core;
-
+using System.Linq;
 
 public static class BattleUtility
 {
@@ -23,7 +23,7 @@
         var battleField = BattleManager.Instance.storyBattleField;
         if (battleField == null)
         {
-            BattleDebug.LogError("BattleManager.storyBattleField 鏈垵濮嬪寲锛�");
+            Debug.LogError("BattleManager.storyBattleField 鏈垵濮嬪寲锛�");
             return;
         }
 
@@ -119,11 +119,40 @@
 
     public static string DisplayDamageNum(long num, int attackType)
     {
+        // 鏈嶅姟鍣ㄤ綅鏁板埌瀹㈡埛绔被鍨婭D鐨勬槧灏�
+        Dictionary<int, int> serverToClientTypeMap = new Dictionary<int, int>
+        {
+            { 1, 2 },    // 鏅�氫激琛�
+            { 2, 4 },    // 鎭㈠鍥炶
+            { 3, 8 },    // 鍙嶅脊浼よ
+            { 4, 16 },   // 鎸佺画浼よ
+            { 5, 32 },   // 鏍兼尅
+            { 7, 64 },   // 鏆村嚮浼ゅ
+            { 9, 128 },  // 闂伩
+            // 鍏跺畠绫诲瀷濡傞渶琛ュ厖鍙户缁坊鍔�
+        };
+
+        int damageTypeValue = 0;
+        for (int i = 0; i < 32; i++)
+        {
+            int flag = 1 << i;
+            if ((attackType & flag) != 0)
+            {
+                // 鍙鐞嗘湁鏄犲皠鐨勭被鍨�
+                if (serverToClientTypeMap.TryGetValue(i + 1, out int clientTypeId))
+                {
+                    damageTypeValue += clientTypeId;
+                }
+            }
+        }
+        DamageType damageType = (DamageType)damageTypeValue;
+
+        var config = DamageNumConfig.Get(damageTypeValue);
         var basePowerStr = UIHelper.ReplaceLargeArtNum(num);
         var result = string.Empty;
         for (int i = 0; i < basePowerStr.Length; i++)
         {
-            var numChar = (char)GetDamageNumKey((DamageType)attackType, basePowerStr[i]);
+            var numChar = (char)GetDamageNumKey(config, basePowerStr[i]);
             if (numChar > 0)
             {
                 result += numChar;
@@ -132,33 +161,101 @@
         return result;
     }
 
-    public static int GetDamageNumKey(DamageType damageType, int _num)
+    public static int GetMainTargetPositionNum(BattleObject caster, List<HB427_tagSCUseSkill.tagSCUseSkillHurt> targetList, SkillConfig skillConfig)
     {
-        var config = DamageNumConfig.Get(damageType.ToString());
-        //.鐨凙SCII鐮佹槸46
-        if (_num == 46)
+        int returnIndex = 0;
+        //  鏍规嵁鏁屾柟琛�閲忛樀钀� 瀛樻椿浜烘暟鏉ラ�夋嫨
+        BattleCamp battleCamp = skillConfig.TagFriendly != 0 ? caster.Camp : caster.GetEnemyCamp();
+        List<BattleObject> targetObjList = caster.battleField.battleObjMgr.GetBattleObjList(battleCamp);
+
+
+        // 鐬勫噯鐨勭洰鏍囪寖鍥达紝濡傛灉鐩爣涓暟涓�0鍒欎负鑼冨洿鍐呭叏閮�
+        // 0    鍏ㄩ儴鑼冨洿
+        // 1    瀵逛綅锛岄粯璁ゅ彧閫�1涓�
+        // 2    鍓嶆帓
+        // 3    鍚庢帓
+        // 4    绾垫帓锛屾寜瀵逛綅瑙勫垯閫夋嫨绾垫帓
+        // 5    鑷繁锛岄粯璁ゅ彧閫夎嚜宸�
+        // 6    缁ф壙涓绘妧鑳�/鏉ユ簮鎶�鑳界洰鏍�
+        //      涓�鑸槸棰濆瑙﹀彂鐨勬妧鑳戒娇鐢紝濡傛鐜囬檮鍔犳煇buff
+        //      棰濆瑙﹀彂鐨勬妧鑳藉鏋滅洰鏍囦笌涓绘妧鑳戒笉涓�鑷达紝鍒欓噸鏂拌瀹氱洰鏍囧嵆鍙�
+        //      鎴栬鍔ㄨЕ鍙戠殑鎶�鑳斤紝鍙户鎵胯Е鍙戞潵婧愭妧鑳界殑鏀婚槻鍙屾柟鍏崇郴
+
+        switch (skillConfig.TagAim)
         {
-            return config.nums[10];
+            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)
+                {
+                    returnIndex = opposite[0].teamHero.positionNum;
+                }
+                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;
+                }
+                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)
+                {
+                    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)
+                {
+                    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
+                break;
+            // 5    鑷繁锛岄粯璁ゅ彧閫夎嚜宸�
+            case 5:
+                returnIndex = caster.teamHero.positionNum;
+                break;
+            default:
+                break;
         }
-        //k鐨凙SCII鐮佹槸107
-        else if (_num == 107)
+
+        return returnIndex;
+    }
+
+    public static int GetDamageNumKey(DamageNumConfig config, int _num)
+    {
+        if (_num == 46)      return config.nums[10]; // '.'
+        else if (_num == 107) return config.nums[11]; // 'k'
+        else if (_num == 109) return config.nums[12]; // 'm'
+        else if (_num == 98)  return config.nums[13]; // 'b'
+        else if (_num == 116) return config.nums[14]; // 't'
+        int targetNum = _num - 48;
+        if (targetNum >= config.nums.Length || targetNum < 0)
         {
-            return config.nums[11];
-        }
-        //m鐨凙SCII鐮佹槸109
-        else if (_num == 109)
-        {
-            return config.nums[12];
-        }
-        //b鐨凙SCII鐮佹槸98
-        else if (_num == 98)
-        {
-            return config.nums[13];
-        }
-        //t鐨凙SCII鐮佹槸116
-        else if (_num == 116)
-        {
-            return config.nums[14];
+            Debug.LogError("damage config " + config.TypeID + " _num is " +  _num + " out of range");
+            return _num;
         }
         return config.nums[_num - 48];
     }

--
Gitblit v1.8.0