yyl
2025-08-25 cec8b67d82c2c2c1662d55c818c4a46bcc0487db
Main/System/Battle/BattleField/BattleField.cs
@@ -146,7 +146,7 @@
        if (operationAgent == null)
        {
            Debug.LogError("you should SetBattleMode before Run");
            BattleDebug.LogError("you should SetBattleMode before Run");
            return;
        }
@@ -178,7 +178,7 @@
                break;
        }
        Debug.LogError("battleMode is " + battleMode.ToString());
        BattleDebug.LogError("battleMode is " + battleMode.ToString());
    }
    public virtual void AutoSetBattleMode()
@@ -283,8 +283,11 @@
    public virtual void OnObjsDead(List<HB422_tagMCTurnFightObjDead> deadPackList)
    {
        DeathRecordAction recordAction = new DeathRecordAction(this, deadPackList);
        recordPlayer.PlayRecord(recordAction);
        if (deadPackList.Count > 0)
        {
            DeathRecordAction recordAction = new DeathRecordAction(this, deadPackList);
            recordPlayer.PlayRecord(recordAction);
        }
    }
    public virtual void Destroy()
@@ -328,7 +331,7 @@
    {
        if (index < 0 || index >= battleRootNode.redTeamNodeList.Count)
        {
            Debug.LogError($"GetTeamNode: Index {index} is out of range for {battleCamp} camp.");
            BattleDebug.LogError($"GetTeamNode: Index {index} is out of range for {battleCamp} camp.");
            return null;
        }
@@ -402,18 +405,95 @@
        }
        else
        {
            Debug.LogError($"BattleObject with ID {vNetData.ObjID} not found for reborn.");
            BattleDebug.LogError($"BattleObject with ID {vNetData.ObjID} not found for reborn.");
        }
    }
    protected virtual void OnSettlement(JsonData turnFightStateData)
    {
    }
    public virtual void OnBattleEnd(JsonData turnFightStateData)
    {
        BattleEndAction battleEndAction = new BattleEndAction(this, turnFightStateData, () =>
        {
            BattleDebug.LogError(turnFightStateData.ToJson());
            // 这里可以添加战斗结束的具体逻辑
            OnSettlement(turnFightStateData);
            int winFaction = (int)turnFightStateData["winFaction"];
            //获胜阵营:   一般为1或者2,当玩家发起的战斗时,如果获胜阵营不等于1代表玩家失败了
            if (winFaction == 1)
            {
                Debug.LogError("战斗胜利");
                //  战斗胜利
                //  如果是自动战斗转自动战斗?
            }
            else
            {
                //  战斗失败
                Debug.LogError("战斗失败");
                HaveRest();
            }
            IsBattleFinish = true;
        });
        recordPlayer.PlayRecord(battleEndAction);
        // 处理战斗结束逻辑
        IsBattleFinish = true;
        // IsBattleFinish = true;
        // 结算逻辑
        // {"winFaction":获胜阵营, "statInfo":统计信息, “itemInfo“:[奖励物品信息列表]}
            // {
            // "itemInfo": [],
            // "winFaction": 1,//获胜阵营:   一般为1或者2,当玩家发起的战斗时,如果获胜阵营不等于1代表玩家失败了
            // "statInfo": {
            //     "1": {
            //     "1": {
            //         "5": {
            //         "NPCID": 0,
            //         "DefHurt": 633,
            //         "CureHP": 0,
            //         "AtkHurt": 169247,
            //         "ObjID": 1,
            //         "HeroID": 510006
            //         }
            //     }
            //     },
            //     "2": {
            //     "1": {
            //         "2": {
            //         "NPCID": 10101001,
            //         "DefHurt": 169246,
            //         "CureHP": 143096,
            //         "AtkHurt": 999952,
            //         "ObjID": 2,
            //         "HeroID": 0
            //         },
            //         "4": {
            //         "NPCID": 10101001,
            //         "DefHurt": 0,
            //         "CureHP": 0,
            //         "AtkHurt": 0,
            //         "ObjID": 3,
            //         "HeroID": 0
            //         },
            //         "6": {
            //         "NPCID": 10101001,
            //         "DefHurt": 1,
            //         "CureHP": 0,
            //         "AtkHurt": 0,
            //         "ObjID": 4,
            //         "HeroID": 0
            //         }
            //     }
            //     }
            // }
            // }
    }
    public virtual void HaveRest()