| | |
| | | using UnityEngine; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | /// <summary> |
| | |
| | | battleField.OnRoundChange += OnRoundChange; |
| | | OnRoundChange(battleField.round, battleField.turnMax); // 立即执行一次以显示初始回合 |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 跳过战斗 |
| | | /// </summary> |
| | |
| | | { |
| | | if (null == battleField) |
| | | return true; |
| | | // 检查是否为永久特权卡玩家 |
| | | |
| | | bool hasForeverPrivilege = InvestModel.Instance.IsInvested(InvestModel.foreverCardType); |
| | | |
| | | string battleFieldName = battleField.ToString(); |
| | | if (!hasForeverPrivilege && !FuncOpen.Instance.IsFuncOpen(BattleManager.Instance.passFuncId)) |
| | | { |
| | | if (battleFieldName != BattleConst.StoryBossBattleField) |
| | | { |
| | | //等级达到20级后解锁或开通终身特权解锁 |
| | | SysNotifyMgr.Instance.ShowTip("BattlePass2"); |
| | | } |
| | | else |
| | | { |
| | | FuncOpen.Instance.ProcessorFuncErrorTip(BattleManager.Instance.passFuncId); |
| | | } |
| | | |
| | | // 检查功能开启状态 |
| | | if (!IsPassOpen(hasForeverPrivilege, battleFieldName)) |
| | | return false; |
| | | } |
| | | |
| | | int passRound = BattleManager.Instance.defaultPassRound; |
| | | var name = battleField.ToString(); |
| | | |
| | | |
| | | if (hasForeverPrivilege) |
| | | // 获取配置的回合限制 |
| | | int configRoundLimit = GetRequiredPassRound(hasForeverPrivilege, battleFieldName); |
| | | int nowRound = battleField.round > 0 ? battleField.round : 1; |
| | | if (nowRound >= configRoundLimit + 1) |
| | | { |
| | | // 永久特权卡玩家逻辑 |
| | | if (BattleConst.FieldNameToIndex.ContainsKey(name)) |
| | | return true; |
| | | } |
| | | ShowSkipWaitTip(configRoundLimit, battleFieldName, hasForeverPrivilege); |
| | | return false; |
| | | } |
| | | |
| | | private bool IsPassOpen(bool hasForeverPrivilege, string battleFieldName) |
| | | { |
| | | // 拥有永久特权卡,无视功能开启限制 |
| | | if (hasForeverPrivilege) |
| | | return true; |
| | | |
| | | int passFuncId = BattleManager.Instance.passFuncId; |
| | | // 检查功能ID是否开启 |
| | | if (FuncOpen.Instance.IsFuncOpen(passFuncId)) |
| | | return true; |
| | | |
| | | if (!FuncOpenLVConfig.HasKey(passFuncId)) |
| | | return true; |
| | | int lv = FuncOpenLVConfig.Get(passFuncId).LimitLV; |
| | | SysNotifyMgr.Instance.ShowTip("BattlePass2", lv); |
| | | return false; |
| | | } |
| | | |
| | | private int GetRequiredPassRound(bool hasForeverPrivilege, string battleFieldName) |
| | | { |
| | | // 初始化默认值 |
| | | int resultRound = BattleManager.Instance.defaultPassRound; |
| | | |
| | | // 尝试获取普通配置(覆盖默认值) |
| | | if (BattleConst.FieldNameToIndex.TryGetValue(battleFieldName, out int index)) |
| | | { |
| | | if (BattleManager.Instance.passDict.TryGetValue(index, out int normalRound)) |
| | | { |
| | | int index = BattleConst.FieldNameToIndex[name]; |
| | | if (BattleManager.Instance.foreverPrivilegePassDict.ContainsKey(index)) |
| | | { |
| | | passRound = BattleManager.Instance.foreverPrivilegePassDict[index]; |
| | | } |
| | | else |
| | | { |
| | | // 未配置的战场类型,使用普通玩家规则 |
| | | if (BattleManager.Instance.passDict.ContainsKey(index)) |
| | | { |
| | | passRound = BattleManager.Instance.passDict[index]; |
| | | } |
| | | // 否则使用默认配置 |
| | | } |
| | | resultRound = normalRound; |
| | | } |
| | | // 如果战场类型不在 FieldNameToIndex 中,使用默认配置 |
| | | } |
| | | else |
| | | { |
| | | // 普通玩家逻辑 |
| | | if (BattleConst.FieldNameToIndex.ContainsKey(name)) |
| | | { |
| | | int index = BattleConst.FieldNameToIndex[name]; |
| | | if (BattleManager.Instance.passDict.ContainsKey(index)) |
| | | { |
| | | passRound = BattleManager.Instance.passDict[index]; |
| | | } |
| | | // 否则使用默认配置 |
| | | } |
| | | // 如果战场类型不在 FieldNameToIndex 中,使用默认配置 |
| | | // 如果连索引都找不到,直接返回默认值,无需后续判断 |
| | | return resultRound; |
| | | } |
| | | |
| | | if (passRound != 0) |
| | | // 如果没有特权,直接返回普通配置 |
| | | if (!hasForeverPrivilege) |
| | | return resultRound; |
| | | |
| | | // 判断特权是否生效 |
| | | bool isPrivilegeEffective = true; |
| | | |
| | | // 特殊规则:主线BOSS需要达到指定章节,特权才生效 |
| | | if (battleFieldName == BattleConst.StoryBossBattleField) |
| | | { |
| | | int nowRound = battleField.round; |
| | | int realPassRound = passRound + 1; // 配置是超过x回合可以跳,意味着x+1回合可以跳 |
| | | if (nowRound < realPassRound) |
| | | if (IsStoryBossChapterLimited()) |
| | | { |
| | | if (battleFieldName != BattleConst.StoryBossBattleField) |
| | | { |
| | | //%s0回合后可跳过,开通终身特权立即跳过 |
| | | SysNotifyMgr.Instance.ShowTip("BattlePass1", realPassRound - nowRound); |
| | | } |
| | | else |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("BattlePass", realPassRound - nowRound); |
| | | } |
| | | |
| | | return false; |
| | | isPrivilegeEffective = false; |
| | | } |
| | | } |
| | | return true; |
| | | |
| | | if (isPrivilegeEffective) |
| | | { |
| | | var vipDict = BattleManager.Instance.foreverPrivilegePassDict; |
| | | // 只有当特权表里显式配置了该战场,才进行覆盖 |
| | | if (vipDict.TryGetValue(index, out int vipRound)) |
| | | { |
| | | resultRound = vipRound; |
| | | } |
| | | } |
| | | |
| | | return resultRound; |
| | | } |
| | | |
| | | private void ShowSkipWaitTip(int configRoundLimit, string battleFieldName, bool hasForeverPrivilege) |
| | | { |
| | | int waitRound = Mathf.Max(configRoundLimit - battleField.round + 1, 0); |
| | | |
| | | // 主线BOSS战场特殊提示 |
| | | if (battleFieldName == BattleConst.StoryBossBattleField) |
| | | { |
| | | if (!hasForeverPrivilege || IsStoryBossChapterLimited()) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("BattlePass3", waitRound, BattleManager.Instance.passChapterID); |
| | | } |
| | | else |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("BattlePass", waitRound); |
| | | } |
| | | } |
| | | // 其他战场提示 |
| | | else |
| | | { |
| | | if (hasForeverPrivilege) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("BattlePass", waitRound); |
| | | } |
| | | else |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("BattlePass1", waitRound); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检查主线BOSS是否受到章节限制 |
| | | /// </summary> |
| | | private bool IsStoryBossChapterLimited() |
| | | { |
| | | long currentProgress = PlayerDatas.Instance.baseData.ExAttr2; |
| | | int nowChapterID = (int)(currentProgress / 10000); |
| | | |
| | | return nowChapterID <= BattleManager.Instance.passChapterID; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 改变速度 |