hch
5 天以前 8f006f426334f5ca733bfe4be2aa91007e232f55
Main/System/HeroUI/HeroUIManager.OnTeam.cs
@@ -6,7 +6,7 @@
public partial class HeroUIManager : GameSystemManager<HeroUIManager>
{
    #region 布阵界面
    public List<string> heroOnTeamSortList { get; private set; } = new List<string>();    //不同上阵的列表排序
@@ -171,7 +171,7 @@
        var team = TeamManager.Instance.GetTeam(teamType);
        if (team == null)
        {
        {
            return heroCountryCount;
        }
        TeamHero[] teamHeroes = isPreview ? team.tempHeroes : team.serverHeroes;
@@ -306,6 +306,155 @@
    #endregion
    #region 主界面上的武将上阵解锁显示 和 解锁规则
    public int[][] lockHeroCountLimit;
    public List<int> lockIndexList = new List<int>();
    public Action OnUnLockHeroCountEvent;
    public int lockState
    {
        get
        {
            return QuickSetting.Instance.GetQuickSettingValue<int>(QuickSettingType.HeroCountLock, 0);
        }
        set
        {
            QuickSetting.Instance.SetQuickSetting(QuickSettingType.HeroCountLock, value, 0);
            QuickSetting.Instance.SendPackage();
            RefreshServerLockIndex();
        }
    }
    //解锁上阵英雄的数量限制, 解锁条件在界面上是按顺序排序的,但是锁定的位置是动态变化的
    //比如 第4,5,6格子锁住了,但第6个的锁先完成了解锁条件,解锁后锁住的位置往后顺推
    //则 第4的位置显示为解锁状态,5和6是锁住状态,5的解锁条件按配置列表的顺序解锁(即为原4的解锁条件)
    // 模拟服务端 这里的index 对应的是配表的
    public bool IsUnLock(int configIndex)
    {
        //按lockState的位判断
        return (lockState & (1 << configIndex)) != 0;
    }
    public bool SetUnLock(int configIndex)
    {
        if (!CanUnLock(configIndex, true))
        {
            return false;
        }
        lockState |= 1 << configIndex;
        return true;
    }
    // 解锁类型
    // 1.主公等级达X级开启;
    // 2.通关主线X-X开启;同任务配法
    // 3.开服时间达到X天开启;
    public bool CanUnLock(int configIndex, bool notify = false)
    {
        int type = lockHeroCountLimit[configIndex][0];
        int value = lockHeroCountLimit[configIndex][1];
        if (type == 1)
        {
            if (PlayerDatas.Instance.baseData.LV < value)
            {
                if (notify)
                    SysNotifyMgr.Instance.ShowTip("HeroCountUnLock1", value);
                return false;
            }
        }
        else if (type == 2)
        {
            //如ExAttr1值为20103代表当前已经过了第2章第1关第3波; value为201
            if (PlayerDatas.Instance.baseData.ExAttr1 / 100 <= value)
            {
                if (notify)
                    SysNotifyMgr.Instance.ShowTip("HeroCountUnLock2", value / 100, value % 100);
                return false;
            }
        }
        else if (type == 3)
        {
            if (TimeUtility.OpenDay < value - 1)
            {
                if (notify)
                    SysNotifyMgr.Instance.ShowTip("HeroCountUnLock3", value);
                return false;
            }
        }
        return true;
    }
    public void ShowUnLockTip(int configIndex)
    {
        int type = lockHeroCountLimit[configIndex][0];
        int value = lockHeroCountLimit[configIndex][1];
        if (type == 1)
        {
            if (PlayerDatas.Instance.baseData.LV < value)
            {
                SysNotifyMgr.Instance.ShowTip("HeroCountUnLock1", value);
                return;
            }
        }
        else if (type == 2)
        {
            //如ExAttr1值为20103代表当前已经过了第2章第1关第3波; value为201
            if (PlayerDatas.Instance.baseData.ExAttr1 / 100 <= value)
            {
                SysNotifyMgr.Instance.ShowTip("HeroCountUnLock2", value / 100, value % 100);
                return;
            }
        }
        else if (type == 3)
        {
            if (TimeUtility.OpenDay < value - 1)
            {
                SysNotifyMgr.Instance.ShowTip("HeroCountUnLock3", value);
                return;
            }
        }
        //可以解锁,但未解锁
        if (!IsUnLock(configIndex))
        {
            SysNotifyMgr.Instance.ShowTip("HeroCountUnLock4");
        }
    }
    // 刷新未解锁武将上限的配置索引列表
    public void RefreshServerLockIndex()
    {
        lockIndexList.Clear();
        for (int i = 0; i < lockHeroCountLimit.Length; i++)
        {
            if (!IsUnLock(i))
            {
                lockIndexList.Add(i);
            }
        }
    }
    public bool UnLockHeroCnt(int lockIndex)
    {
        if (lockIndex < 0 || lockIndex >= lockIndexList.Count)
        {
            return false;
        }
        return SetUnLock(lockIndexList[lockIndex]);
    }
    void OnQuickSettingUpdate()
    {
        RefreshServerLockIndex();
    }
    #endregion
}