hch
2025-09-10 a80d9e64b60403c71ff7ff32c9e94e6833f50ace
Main/System/Main/HomeWin.cs
@@ -12,6 +12,7 @@
    //经验区
    [SerializeField] Text playerLevelText;
    [SerializeField] SmoothSlider expSlider;
    [SerializeField] Button officialUpBtn;
    //任务区
    [SerializeField] Button taskButton; //引导或者领取任务奖励
@@ -24,8 +25,33 @@
    //关卡
    [SerializeField] Button bossBtn;
    [SerializeField] MainLevelWaveCell[] mainLevelWaves;
    [SerializeField] ScrollRect mainLevelScrollRect;
    [SerializeField] Text levelName;
    [SerializeField] GameObject restMark;
    [SerializeField] Button restBtn;
    [SerializeField] GameObject fightMark;
    [SerializeField] ScaleTween bossTween;
    [SerializeField] GameObject bossmask;   //完成进度遮挡管道 纯显示
    [SerializeField] GameObject bossActiveGo;
    [SerializeField] GameObject bitemeGo;
    [SerializeField] Text processText;
    //卡牌
    [SerializeField] HeroFightingCardCell[] heroFightingCardCells;
    [SerializeField] Button changeHeroPosBtn;
    //底部功能
    [SerializeField] Button autoBtn;
    [SerializeField] Image autoCloseImg;
    [SerializeField] UIEffectPlayer autoOpenEffect;
    [SerializeField] Button blessLVBtn;
    [SerializeField] Text blessLVText;
    //其他功能入口
    [SerializeField] Button monthCardBtn;
    /// <summary>
    /// 初始化组件
@@ -37,41 +63,86 @@
        {
            UIManager.Instance.OpenWindow<MainBossEnterWin>();
        });
        changeHeroPosBtn.AddListener(() =>
        {
            HeroUIManager.Instance.selectTeamType = TeamType.Story;
            UIManager.Instance.OpenWindow<HeroPosWin>();
        });
        autoBtn.AddListener(() =>
        {
            if (!FuncOpen.Instance.IsFuncOpen(108, true))
            {
                return;
            }
            UIManager.Instance.OpenWindow<AutoFightWin>();
        });
        monthCardBtn.AddListener(() =>
        {
            InvestModel.Instance.BuyInvest(InvestModel.monthCardType);
        });
        blessLVBtn.AddListener(() =>
        {
            UIManager.Instance.OpenWindow<BlessLVWin>();
        });
        officialUpBtn.AddListener(() =>
        {
            if (RealmConfig.GetKeys().Count <= PlayerDatas.Instance.baseData.realmLevel)
                return;
            UIManager.Instance.OpenWindow<OfficialUpWin>();
        });
        restBtn.AddListener(GotoRest);
    }
    public override void Refresh()
    public void Display()
    {
        UpdatePlayerInfo();
        UpdateTask();
        RefreshRecharge();
        ShowBlessLV();
        DisplayAutoFight();
        DisplayCard(TeamType.Story);
        DisplayLevel();
        DisplayRestState();
    }
    protected override void OnPreOpen()
    {
        PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefresh;
        TaskManager.Instance.OnTaskUpdate += UpdateTask;
        Refresh();
        UIManager.Instance.OpenWindow<BattleWin>();
        BlessLVManager.Instance.OnBlessLVUpdateEvent += ShowBlessLV;
        AutoFightModel.Instance.ChangeAutoEvent += DisplayAutoFight;
        AutoFightModel.Instance.OnFightEvent += ChangeMode;
        TeamManager.Instance.OnTeamChange += DisplayCard;
        UIManager.Instance.OnCloseWindow += OnCloseWindow;
        Display();
        // var battleWin = UIManager.Instance.OpenWindow<BattleWin>();
        // battleWin.SetBattleField(BattleManager.Instance.storyBattleField);
    }
    protected override void OnOpen()
    {
        base.OnOpen();
    }
    protected override void OnPreClose()
    {
        PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefresh;
        TaskManager.Instance.OnTaskUpdate -= UpdateTask;
        BlessLVManager.Instance.OnBlessLVUpdateEvent -= ShowBlessLV;
        AutoFightModel.Instance.ChangeAutoEvent -= DisplayAutoFight;
        AutoFightModel.Instance.OnFightEvent -= ChangeMode;
        TeamManager.Instance.OnTeamChange -= DisplayCard;
        UIManager.Instance.OnCloseWindow -= OnCloseWindow;
        //  关闭的时候把战斗界面也给关了 虽然是在外面开的
        UIManager.Instance.CloseWindow<BattleWin>();
    }
@@ -86,6 +157,37 @@
            case PlayerDataType.LV:
                playerLevelText.text = PlayerDatas.Instance.baseData.LV.ToString();
                break;
            case PlayerDataType.ExAttr1:
            case PlayerDataType.ExAttr2:
                DisplayLevel();
                break;
        }
    }
    void RefreshRecharge()
    {
        monthCardBtn.SetActive(!InvestModel.Instance.IsInvested(InvestModel.monthCardType));
    }
    void ShowBlessLV()
    {
        blessLVText.text = BlessLVManager.Instance.m_TreeLV.ToString();
    }
    void DisplayAutoFight()
    {
        if (AutoFightModel.Instance.isAutoAttackSet)
        {
            autoCloseImg.SetActive(false);
            autoOpenEffect.Play();
        }
        else
        {
            autoCloseImg.SetActive(true);
            autoOpenEffect.Stop();
        }
@@ -110,7 +212,7 @@
    void UpdateTask()
    {
    {
        var task = TaskManager.Instance.mainTask;
        if (task.TaskID == 0)
        {
@@ -122,9 +224,16 @@
            var taskConfig = TaskConfig.Get(task.TaskID);
            taskText.text = taskConfig.TaskDescribe;
            taskNumText.text = string.Format("({0}/{1})", task.CurValue, taskConfig.NeedValue);
            taskNumText.color = task.CurValue >= taskConfig.NeedValue ? UIHelper.GetUIColor(TextColType.NavyYellow) :  UIHelper.GetUIColor(TextColType.Red);
            taskEffect.SetActive(TaskManager.Instance.GetMainTaskState() == 2);
            awardIcon.SetSprite(ItemConfig.Get(taskConfig.AwardItemList[0][0]).IconKey);
            taskNumText.color = task.CurValue >= taskConfig.NeedValue ? UIHelper.GetUIColor(TextColType.NavyYellow) : UIHelper.GetUIColor(TextColType.Red);
            if (TaskManager.Instance.GetMainTaskState() == 2)
            {
                taskEffect.Play();
            }
            else
            {
                taskEffect.Stop();
            }
            awardIcon.SetOrgSprite(ItemConfig.Get(taskConfig.AwardItemList[0][0]).IconKey);
            awardCnt.text = taskConfig.AwardItemList[0][1].ToString();
        }
    }
@@ -144,4 +253,110 @@
            //根据任务类型引导
        }
    }
    void DisplayCard(TeamType teamType)
    {
        if (teamType != TeamType.Story)
            return;
        //显示卡牌
        for (int i = 0; i < heroFightingCardCells.Length; i++)
        {
            heroFightingCardCells[i].Display(i);
        }
    }
    private void OnCloseWindow(UIBase closeUI)
    {
        //其他武将功能产生数据变化,需要刷新武将列表
        if (closeUI is HeroTrainWin)
        {
            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 > 3 ? 1 : 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);
            bossmask.SetActive(true);
        }
        else
        {
            bossActiveGo.SetActive(false);
            processText.SetActive(true);
            processText.text = (waveID - 1) * 100 / totalWave + "%";
            bossTween.Stop();
            bitemeGo.SetActive(false);
            bossmask.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();
        }
    }
}