hch
2025-08-31 a03d6a0b9a2d94809e6a17f92de4e3163e26a2f2
125 【战斗】战斗系统 - 主线战斗的关卡显示
5个文件已修改
4个文件已添加
295 ■■■■■ 已修改文件
Main/Config/PartialConfigs/MainLevelConfig.cs 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Config/PartialConfigs/MainLevelConfig.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Core/GameEngine/Player/PlayerBaseData.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Core/GameEngine/Player/PlayerDatas.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Boss/MainBossEnterWin.cs 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Main/AutoFightModel.cs 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Main/HomeWin.cs 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Main/MainLevelWaveCell.cs 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Main/MainLevelWaveCell.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Config/PartialConfigs/MainLevelConfig.cs
New file
@@ -0,0 +1,50 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public partial class MainLevelConfig : ConfigBase<int, MainLevelConfig>
{
    static Dictionary<int, Dictionary<int, MainLevelConfig>> configDics = new Dictionary<int, Dictionary<int, MainLevelConfig>>();
    protected override void OnConfigParseCompleted()
    {
        Dictionary<int, MainLevelConfig> tempDic = null;
        if (!configDics.TryGetValue(ChapterID, out tempDic))
        {
            tempDic = new Dictionary<int, MainLevelConfig>();
            configDics.Add(ChapterID, tempDic);
        }
        tempDic[LevelNum] = this;
    }
    public static MainLevelConfig GetMainLevelConfig(int chapterID, int LevelNum)
    {
        Dictionary<int, MainLevelConfig> tempDic = null;
        if (!configDics.TryGetValue(chapterID, out tempDic))
        {
            return null;
        }
        MainLevelConfig config = null;
        tempDic.TryGetValue(LevelNum, out config);
        return config;
    }
    public static int GetwaveCount(MainLevelConfig config)
    {
        int[][] waveLineupLists = new int[][]
        {
            config.WaveLineupIDList1,
            config.WaveLineupIDList2,
            config.WaveLineupIDList3,
            config.WaveLineupIDList4,
            config.WaveLineupIDList5,
            config.WaveLineupIDList6
        };
        // 统计非空数组的数量
        return waveLineupLists.Count(list => list.Length > 0);
    }
}
Main/Config/PartialConfigs/MainLevelConfig.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0c654df83f955ce4ca0495942771519c
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/Core/GameEngine/Player/PlayerBaseData.cs
@@ -34,8 +34,8 @@
    public byte FBID;    //fb id
    public byte realmLevel;    //官职
    public byte VIPLv;    //VIP等级
    public uint ExAttr1;    // 策划配置关卡ID为201,即 过关2-1(0/1) ,使用 ExAttr1 值判断,如ExAttr1值为20103代表当前已经过了第2章第1关第3波,包含了波,需要击败该关卡boss后才算该关过关
    public uint teamAutoOperateFlag;    //扩展属性2,各项目专用
    public int ExAttr1;    // 策划配置关卡ID为201,即 过关2-1(0/1) ,使用 ExAttr1 值判断,如ExAttr1值为20103代表当前已经过了第2章第1关第3波,包含了波,需要击败该关卡boss后才算该关过关
    public int ExAttr2;    // 用于记录主线当前刷怪所在章节关卡记录,记录值 = 章节*10000+关卡编号*100+第x波  ; 0418刷新类型103
    public int dungeonLineId;    // 副本线路id
    public int dungeonMapId;    // 副本用作 DataMapId,单人副本存在1.假副本 2.服务端1对客户端多地图同分线 3.服务端1对客户端多地图不同分线
    public uint shield;    //护盾值
@@ -167,8 +167,8 @@
        CON = _serverInfo.CON;
        Setting = _serverInfo.Setting;
        FBID = _serverInfo.FBID;
        ExAttr1 = _serverInfo.ExAttr1;  //策划配置关卡ID为201,即 过关2-1(0/1) ,使用 ExAttr1 值判断,如ExAttr1值为20103代表当前已经过了第2章第1关第3波,包含了波,需要击败该关卡boss后才算该关过关
        teamAutoOperateFlag = _serverInfo.ExAttr2;
        ExAttr1 = (int)_serverInfo.ExAttr1;  //策划配置关卡ID为201,即 过关2-1(0/1) ,使用 ExAttr1 值判断,如ExAttr1值为20103代表当前已经过了第2章第1关第3波,包含了波,需要击败该关卡boss后才算该关过关
        ExAttr2 = (int)_serverInfo.ExAttr2;  //用于记录主线当前刷怪所在章节关卡记录,记录值 = 章节*10000+关卡编号*100+第x波  ; 0418刷新类型103
        dungeonLineId = (int)_serverInfo.ExAttr3 % 1000;
        dungeonMapId = (int)_serverInfo.ExAttr3 / 1000;
        shield = _serverInfo.ExAttr4;
Main/Core/GameEngine/Player/PlayerDatas.cs
@@ -233,10 +233,10 @@
                extersion.luckValue = (int)value;
                break;
            case PlayerDataType.ExAttr1:
                baseData.ExAttr1 = value;
                baseData.ExAttr1 = (int)value;
                break;
            case PlayerDataType.ExAttr2:
                baseData.teamAutoOperateFlag = value;
                baseData.ExAttr2 = (int)value;
                break;
            case PlayerDataType.ExAttr3:
                baseData.dungeonLineId = (int)value % 1000;
Main/System/Boss/MainBossEnterWin.cs
@@ -16,18 +16,22 @@
    [SerializeField] Button CloseBtn;
    [SerializeField] Button rankBtn;
    [SerializeField] Button fightBtn;
    protected override void InitComponent()
    {
        CloseBtn.AddListener(CloseWindow);
        rankBtn.AddListener(()=>
        rankBtn.AddListener(() =>
        {
            RankModel.Instance.ResetQueryParam();
            RankModel.Instance.QueryRankByPage(0, watchID: (int)PlayerDatas.Instance.baseData.PlayerID);
            var win = UIManager.Instance.OpenWindow<PlayerRankWin>();
            win.rankType = 0;
        });
        fightBtn.AddListener(FightBoss);
    }
    protected override void OnPreOpen()
@@ -35,21 +39,25 @@
    }
    protected override void OnOpen()
    {
    }
    protected override void OnPreClose()
    {
    }
    protected override void OnClose()
    void Display()
    {
        base.OnClose();
        var canChallengeBoss = AutoFightModel.Instance.CanChallengeBoss();
        fightBtn.interactable = canChallengeBoss;
        fightBtn.SetColorful(null, canChallengeBoss);
    }
    void FightBoss()
    {
        if (AutoFightModel.Instance.CanChallengeBoss())
        {
            BattleManager.Instance.MainFightRequest(3);
        }
    }
}
Main/System/Main/AutoFightModel.cs
@@ -211,7 +211,7 @@
    public int fightingHeroSkinID;  //当前战斗的英雄皮肤ID
    public string heroGuid; //战斗中的武将
    public event Action<bool> OnFightEvent; //是否战斗通知
    public event Action<bool> OnFightEvent; //战斗模式变更通知 战斗释放技能通知
    /// <summary>
@@ -243,6 +243,27 @@
        OnFightEvent?.Invoke(true);
    }
    public bool CanChallengeBoss()
    {
        //最后一波通过,且当前波还是最后一波;倒退只倒退波不会倒退关卡
        if (PlayerDatas.Instance.baseData.ExAttr2 != PlayerDatas.Instance.baseData.ExAttr1)
        {
            return false;
        }
        var value = PlayerDatas.Instance.baseData.ExAttr2;
        var chapterID = value / 10000;
        var levelNum = value % 10000 / 100;
        var waveID = value % 100;
        var config = MainLevelConfig.GetMainLevelConfig(chapterID, levelNum);
        if (waveID < MainLevelConfig.GetwaveCount(config))
        {
            return false;
        }
        return true;
    }
    #endregion
Main/System/Main/HomeWin.cs
@@ -25,12 +25,22 @@
    //关卡
    [SerializeField] Button bossBtn;
    [SerializeField] MainLevelWaveCell[] mainLevelWaves;
    [SerializeField] ScrollRect mainLevelScrollRect;
    [SerializeField] Text levelName;
    [SerializeField] Button changeHeroPosBtn;
    [SerializeField] GameObject restMark;
    [SerializeField] Button restBtn;
    [SerializeField] GameObject fightMark;
    [SerializeField] ScaleTween bossTween;
    [SerializeField] GameObject bossActiveGo;
    [SerializeField] GameObject bitemeGo;
    [SerializeField] Text processText;
    //卡牌
    [SerializeField] HeroFightingCardCell[] heroFightingCardCells;
    [SerializeField] Button changeHeroPosBtn;
    //底部功能
    [SerializeField] Button autoBtn;
@@ -104,6 +114,8 @@
                return;
            UIManager.Instance.OpenWindow<OfficialUpWin>();
        });
        restBtn.AddListener(GotoRest);
    }
@@ -117,6 +129,8 @@
        ShowBlessLV();
        DisplayAutoFight();
        DisplayCard(TeamType.Story);
        DisplayLevel();
        DisplayRestState();
    }
@@ -126,6 +140,7 @@
        TaskManager.Instance.OnTaskUpdate += UpdateTask;
        BlessLVManager.Instance.OnBlessLVUpdateEvent += ShowBlessLV;
        AutoFightModel.Instance.ChangeAutoEvent += DisplayAutoFight;
        AutoFightModel.Instance.OnFightEvent += ChangeMode;
        TeamManager.Instance.OnTeamChange += DisplayCard;
        UIManager.Instance.OnCloseWindow += OnCloseWindow;
        Display();
@@ -141,6 +156,7 @@
        TaskManager.Instance.OnTaskUpdate -= UpdateTask;
        BlessLVManager.Instance.OnBlessLVUpdateEvent -= ShowBlessLV;
        AutoFightModel.Instance.ChangeAutoEvent -= DisplayAutoFight;
        AutoFightModel.Instance.OnFightEvent -= ChangeMode;
        TeamManager.Instance.OnTeamChange -= DisplayCard;
        UIManager.Instance.OnCloseWindow -= OnCloseWindow;
@@ -158,6 +174,9 @@
                break;
            case PlayerDataType.LV:
                playerLevelText.text = PlayerDatas.Instance.baseData.LV.ToString();
                break;
            case PlayerDataType.ExAttr2:
                DisplayLevel();
                break;
        }
@@ -187,6 +206,8 @@
            autoCloseImg.SetActive(true);
            autoOpenEffect.Stop();
        }
    }
    /// <summary>
@@ -269,4 +290,88 @@
            DisplayCard(TeamType.Story);
        }
    }
    private void DisplayLevel()
    {
        var value = PlayerDatas.Instance.baseData.ExAttr2;
        var chapterID = value / 10000;
        var levelNum = value % 10000 / 100;
        var waveID = value % 100;
        var config = MainLevelConfig.GetMainLevelConfig(chapterID, levelNum);
        var totalWave = MainLevelConfig.GetwaveCount(config);
        for (int i = 0; i < mainLevelWaves.Length; i++)
        {
            if (i < totalWave)
            {
                mainLevelWaves[i].SetActive(true);
                mainLevelWaves[i].Display(i);
            }
            else
            {
                mainLevelWaves[i].SetActive(false);
            }
        }
        mainLevelScrollRect.normalizedPosition = new Vector2(waveID > 2 ? 0.95f : 0, 0);
        var chapterConfig = MainChapterConfig.Get(chapterID);
        //【普通】关卡名字1-6
        levelName.text = Language.Get("mainui7", chapterConfig.Level, chapterConfig.ChapterName, chapterID, levelNum);
        bool canChallengeBoss = AutoFightModel.Instance.CanChallengeBoss();
        //BOSS
        if (canChallengeBoss)
        {
            bossActiveGo.SetActive(true);
            processText.SetActive(false);
            bossTween.Play();
            bitemeGo.SetActive(true);
        }
        else
        {
            bossActiveGo.SetActive(false);
            processText.SetActive(true);
            processText.text = (waveID - 1) * 100 / totalWave + "%";
            bossTween.Stop();
            bitemeGo.SetActive(false);
        }
    }
    void DisplayRestState()
    {
        if (BattleManager.Instance.storyBattleField != null &&
            BattleManager.Instance.storyBattleField.GetBattleMode() == BattleMode.Stop)
        {
            //休息中
            restMark.SetActive(true);
            fightMark.SetActive(false);
        }
        else
        {
            //战斗中
            restMark.SetActive(false);
            fightMark.SetActive(true);
        }
    }
    void ChangeMode(bool isFight)
    {
        if (isFight)
            return;
        DisplayRestState();
        DisplayLevel();
    }
    void GotoRest()
    {
        if (BattleManager.Instance.storyBattleField != null &&
            BattleManager.Instance.storyBattleField.GetBattleMode() != BattleMode.Stop)
        {
            BattleManager.Instance.storyBattleField.HaveRest();
        }
    }
}
Main/System/Main/MainLevelWaveCell.cs
New file
@@ -0,0 +1,55 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
//主线关卡的 波次显示
public class MainLevelWaveCell : MonoBehaviour
{
    [SerializeField] GameObject passLevelBG;    //已通关和正在通关的
    [SerializeField] Image passMark;    //已通关的标记
    [SerializeField] GameObject nowLevelMark;    //当前关卡
    [SerializeField] Image levelMark;   //关卡的标记 类似精英关,随机关的标识;休息时和未通关显示
    //index从0开始
    public void Display(int index)
    {
        var theWave = index + 1;
        //ExAttr2   用于记录主线当前刷怪所在章节关卡记录,记录值 = 章节*10000+关卡编号*100+第x波  ; 0418刷新类型103
        var value = PlayerDatas.Instance.baseData.ExAttr2;
        var waveID = value % 100;
        passLevelBG.SetActive(theWave <= waveID);
        levelMark.SetActive(theWave >= waveID);
        passMark.SetActive(theWave < waveID);
        if (theWave == waveID)
        {
            if (BattleManager.Instance.storyBattleField != null &&
                BattleManager.Instance.storyBattleField.GetBattleMode() == BattleMode.Stop)
            {
                levelMark.SetActive(true);
                nowLevelMark.SetActive(false);
            }
            else
            {
                nowLevelMark.SetActive(true);
                levelMark.SetActive(false);
            }
        }
        else
        {
            nowLevelMark.SetActive(false);
        }
        levelMark.SetSprite("MainBossMark" + (index % 2));
        levelMark.SetNativeSize();
    }
}
Main/System/Main/MainLevelWaveCell.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1f64b59c72b52da41bc3065533b7eef6
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant: