yyl
2025-08-05 2917e8a4eae31c1a1bc4419a9b6f23be7e4fda3e
Main/System/Battle/BattleObject/BattleObjMgr.cs
@@ -21,30 +21,65 @@
        battleField = _battleField;
        CreateTeam(battleField.battleRootNode.redTeamNodeList, redCampDict, _redTeam, BattleCamp.Red);
        CreateTeam(battleField.battleRootNode.blueTeamNodeList, blueCampDict, _blueTeam, BattleCamp.Blue);
    }
    }
    protected void CreateTeam(List<GameObject> posNodeList, Dictionary<int, BattleObject> campDict, TeamBase teamBase, BattleCamp _Camp)
    {
        DestroyTeam(campDict);
        for (int i = 0; i < teamBase.teamHeros.Length; i++)
        if (teamBase == null)
        {
            TeamHero teamHero = teamBase.teamHeros[i];
            return;
        }
        for (int i = 0; i < teamBase.serverHeroes.Length; i++)
        {
            TeamHero teamHero = teamBase.serverHeroes[i];
            if (teamHero != null)
            {
                BattleObject battleObj = BattleObjectFactory.CreateBattleObject(battleField, posNodeList, teamHero, _Camp);
                allBattleObjDict.Add(battleObj.BattleObjectId, battleObj);
                campDict.Add(teamHero.heroIndex, battleObj);
                if (battleObj.ObjID == 0)
                    continue;
                allBattleObjDict.Add(battleObj.ObjID, battleObj);
                campDict.Add(teamHero.positionNum, battleObj);
            }
        }
    }
    
    public BattleObject GetBattleObject(int battleObjId)
    public BattleObject GetBattleObject(int objId)
    {
        if (allBattleObjDict.TryGetValue(battleObjId, out BattleObject battleObj))
        if (allBattleObjDict.TryGetValue(objId, out BattleObject battleObj))
        {
            return battleObj;
        }
        return null;
    }
    public List<BattleObject> GetBattleObjList(BattleCamp _Camp)
    {
        if (_Camp == BattleCamp.Red)
        {
            return redCampList;
        }
        else
        {
            return blueCampList;
        }
    }
    public List<BattleObject> GetBattleObjList(H0604_tagUseSkillAttack tagUseSkillAttack)
    {
        List<BattleObject> retList = new List<BattleObject>();
        foreach (var hurt in tagUseSkillAttack.HurtList)
        {
            BattleObject obj = GetBattleObject((int)hurt.ObjID);
            if (null != obj)
            {
                retList.Add(obj);
            }
        }
        return retList;
    }
    protected void DestroyTeam(Dictionary<int, BattleObject> campDict)
@@ -54,12 +89,32 @@
            BattleObject battleObj = item.Value;
            if (battleObj != null)
            {
                allBattleObjDict.Remove(battleObj.BattleObjectId);
                allBattleObjDict.Remove(battleObj.ObjID);
                BattleObjectFactory.DestroyBattleObject(item.Key, battleObj);
            }
        }
        campDict.Clear();
    }
    //  空闲状态
    public void HaveRest(BattleCamp _Camp)
    {
        //  休息状态
        if (_Camp == BattleCamp.Red)
        {
            foreach (var item in redCampDict.Values)
            {
                item.HaveRest();
            }
        }
        else
        {
            foreach (var item in blueCampDict.Values)
            {
                item.HaveRest();
            }
        }
    }
    public void Release()
@@ -127,7 +182,7 @@
        return blueCampList;
    }
#if UNITY_EDITOR
#if UNITY_EDITOR_STOP_USING
    public void ReviveAll()
    {
        foreach (var kv in allBattleObjDict)
@@ -168,7 +223,7 @@
                //暂时没有召唤物
                // 放在第7格的BOSS后排的。。位置放在正中间
                // a)前排,1、2、3号为前排,前排全部阵亡后,4、5、6号即是前排也是后排 7其实也是后排
                List<BattleObject> frontList = new List<BattleObject>(from BO in returnList where BO.teamHero.heroIndex < 3 && !BO.IsDead() select BO);
                List<BattleObject> frontList = new List<BattleObject>(from BO in returnList where BO.teamHero.positionNum < 3 && !BO.IsDead() select BO);
                if (frontList.Count == 0)
                {
                    frontList.AddRange(returnList);
@@ -176,7 +231,7 @@
                returnList = frontList;                
                break;
            case SkillTargetRangeType.Back:
                List<BattleObject> backList = new List<BattleObject>(from BO in returnList where BO.teamHero.heroIndex >= 3 && !BO.IsDead() select BO);
                List<BattleObject> backList = new List<BattleObject>(from BO in returnList where BO.teamHero.positionNum >= 3 && !BO.IsDead() select BO);
                if (backList.Count == 0)
                {
                    backList.AddRange(returnList);
@@ -198,18 +253,8 @@
            case SkillTargetRangeType.HighestAttack:
                returnList = new List<BattleObject>(from BO in returnList where !BO.IsDead() select BO);
                BattleObject mostHighestAttckObj = null;
                for (int i = 0; i < returnList.Count; i++)
                {
                    if (mostHighestAttckObj == null)
                    {
                        mostHighestAttckObj = returnList[i];
                        continue;
                    }
                    if (returnList[i].teamHero.attack > mostHighestAttckObj.teamHero.attack)
                    {
                        mostHighestAttckObj = returnList[i];
                    }
                }
                //  客户端不包含数据 这里取第一个
                mostHighestAttckObj = returnList[0];
                returnList.Clear();
                if (mostHighestAttckObj != null)
                    returnList.Add(mostHighestAttckObj);