hch
8 天以前 af6e207c6d185ed66125e85e18c02c63bea597f9
Main/System/Main/HomeWin.cs
@@ -1,3 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -21,7 +22,7 @@
    [SerializeField] Image awardIcon;
    [SerializeField] Text awardCnt;
    [SerializeField] UIEffectPlayer taskEffect;
    [SerializeField] UIEffectPlayer lvUPEffect;
    //关卡
    [SerializeField] Button bossBtn;
@@ -49,9 +50,11 @@
    [SerializeField] UIEffectPlayer autoOpenEffect;
    [SerializeField] Button blessLVBtn;
    [SerializeField] Text blessLVText;
    [SerializeField] Button mailBtn;
    //其他功能入口
    [SerializeField] Button monthCardBtn;
    [SerializeField] Button FirstChargeBtn;
    /// <summary>
    /// 初始化组件
@@ -59,10 +62,7 @@
    protected override void InitComponent()
    {
        taskButton.AddListener(OnClickTaskButton);
        bossBtn.AddListener(() =>
        {
            UIManager.Instance.OpenWindow<MainBossEnterWin>();
        });
        bossBtn.AddListener(OnClickEnterBoss);
        changeHeroPosBtn.AddListener(() =>
        {
@@ -72,26 +72,7 @@
        autoBtn.AddListener(() =>
        {
            // //测试拾取所有物品
            // var items = PackManager.Instance.GetItems(PackType.DropItem);
            // List<int> dropindexs = new List<int>();
            // for (int i = 0; i < items.Count; i++)
            // {
            //     var item = items[i];
            //     if (dropindexs.Count > 5)
            //     {
            //         EquipModel.Instance.NotifyItemDrop(dropindexs, BattleManager.Instance.storyBattleField.battleRootNode.blueTeamNodeList[Random.Range(0, 5)].GetComponent<RectTransform>());
            //         dropindexs.Clear();
            //     }
            //     dropindexs.Add(item.gridIndex);
            // }
            // if (dropindexs.Count > 0)
            // {
            //     EquipModel.Instance.NotifyItemDrop(dropindexs, BattleManager.Instance.storyBattleField.battleRootNode.blueTeamNodeList[Random.Range(0, 5)].GetComponent<RectTransform>());
            //     dropindexs.Clear();
            // }
            if (!FuncOpen.Instance.IsFuncOpen(108, true))
            if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.AutoFight, true))
            {
                return;
            }
@@ -104,9 +85,23 @@
            InvestModel.Instance.BuyInvest(InvestModel.monthCardType);
        });
        FirstChargeBtn.AddListener(() =>
        {
            UIManager.Instance.OpenWindow<FirstChargeWin>();
        });
        blessLVBtn.AddListener(() =>
        {
            if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.BlessLV, true))
            {
                return;
            }
            UIManager.Instance.OpenWindow<BlessLVWin>();
        });
        mailBtn.AddListener(() =>
        {
            UIManager.Instance.OpenWindow<MailWin>();
        });
        officialUpBtn.AddListener(() =>
@@ -144,7 +139,13 @@
        AutoFightModel.Instance.OnFightEvent += ChangeMode;
        TeamManager.Instance.OnTeamChange += DisplayCard;
        UIManager.Instance.OnCloseWindow += OnCloseWindow;
        FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChange;
        FirstChargeManager.Instance.OnUpdateFirstChargeInfo += OnUpdateFirstChargeInfo;
        GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
        HeroUIManager.Instance.OnUnLockHeroCountEvent += OnUnLockHeroCountEvent;
        Display();
        DisplayFirstChargeBtn();
        // var battleWin = UIManager.Instance.OpenWindow<BattleWin>();
        // battleWin.SetBattleField(BattleManager.Instance.storyBattleField);
    }
@@ -160,11 +161,30 @@
        AutoFightModel.Instance.OnFightEvent -= ChangeMode;
        TeamManager.Instance.OnTeamChange -= DisplayCard;
        UIManager.Instance.OnCloseWindow -= OnCloseWindow;
        FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChange;
        FirstChargeManager.Instance.OnUpdateFirstChargeInfo -= OnUpdateFirstChargeInfo;
        GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
        HeroUIManager.Instance.OnUnLockHeroCountEvent -= OnUnLockHeroCountEvent;
        //  关闭的时候把战斗界面也给关了 虽然是在外面开的
        UIManager.Instance.CloseWindow<BattleWin>();
    }
    private void OnClickEnterBoss()
    {
        // BattleField battleField = BattleManager.Instance.GetBattleFieldByMapID(2); //BOSS战斗
        // if (null != battleField)
        // {
        //     StoryBossBattleWin fsBattleWin = UIManager.Instance.OpenWindow<StoryBossBattleWin>();
        //     fsBattleWin.SetBattleField(battleField);
        //     return;
        // }
        UIManager.Instance.OpenWindow<MainBossEnterWin>();
    }
    int lastLV = 0;
    void PlayerDataRefresh(PlayerDataType type)
    {
        switch (type)
@@ -174,6 +194,11 @@
                ShowExp();
                break;
            case PlayerDataType.LV:
                if (lastLV != PlayerDatas.Instance.baseData.LV)
                {
                    lastLV = PlayerDatas.Instance.baseData.LV;
                    lvUPEffect.Play();
                }
                playerLevelText.text = PlayerDatas.Instance.baseData.LV.ToString();
                break;
            case PlayerDataType.ExAttr1:
@@ -267,20 +292,20 @@
            getReward.DataEx = (uint)TaskManager.Instance.mainTask.TaskID;
            GameNetSystem.Instance.SendInfo(getReward);
        }
        else
        {
            //根据任务类型引导
        }
        TaskManager.Instance.ClickTask();
    }
    void DisplayCard(TeamType teamType)
    {
        if (teamType != TeamType.Story)
            return;
        var team = TeamManager.Instance.GetTeam(teamType);
        var heros = team.GetHerosOnTeam();
        //显示卡牌
        for (int i = 0; i < heroFightingCardCells.Length; i++)
        {
            heroFightingCardCells[i].Display(i);
            heroFightingCardCells[i].Display(i, heros);
        }
    }
@@ -322,7 +347,7 @@
        //【普通】关卡名字1-6
        levelName.text = Language.Get("mainui7", chapterConfig.Level, chapterConfig.ChapterName, chapterID, levelNum);
        bool canChallengeBoss = AutoFightModel.Instance.CanChallengeBoss();
        bool canChallengeBoss = MainLevelManager.Instance.CanChallengeBoss();
        //BOSS
        if (canChallengeBoss)
        {
@@ -371,11 +396,49 @@
    }
    void GotoRest()
    {
    {
        if (BattleManager.Instance.storyBattleField != null &&
            BattleManager.Instance.storyBattleField.GetBattleMode() != BattleMode.Stop)
        {
            BattleManager.Instance.storyBattleField.HaveRest();
        }
    }
    private void DisplayFirstChargeBtn()
    {
        bool isFirstChargeFuncOpen = FuncOpen.Instance.IsFuncOpen(FirstChargeManager.FuncID);
        if (FirstChargeManager.Instance.IsAllFirstChargeRewardsClaimed() &&
        FirstChargeManager.Instance.IsNextDayAfterAllClaimed())
        {
            FirstChargeBtn.SetActive(false);
        }
        else
        {
            FirstChargeBtn.SetActive(isFirstChargeFuncOpen);
        }
    }
    private void OnFuncStateChange(int funcId)
    {
        if (funcId == FirstChargeManager.FuncID)
        {
            DisplayFirstChargeBtn();
        }
    }
    private void OnUpdateFirstChargeInfo()
    {
        DisplayFirstChargeBtn();
    }
    private void OnSecondEvent()
    {
        DisplayFirstChargeBtn();
    }
    void OnUnLockHeroCountEvent()
    {
        DisplayCard(TeamType.Story);
    }
}