| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using LitJson; |
| | | |
| | | using UnityEngine; |
| | |
| | | { |
| | | get |
| | | { |
| | | int value = QuickSetting.Instance.GetQuickSettingValue<int>(QuickSettingType.AutoFight_Cost, 0); |
| | | return Math.Min(Math.Max(value, 1), maxCost); |
| | | string value = QuickSetting.Instance.GetQuickSetting(QuickSettingType.AutoFight_Cost, 0); |
| | | // value 是16进制转数字 |
| | | int result = Convert.ToInt32(string.IsNullOrEmpty(value) ? "1" : value, 16); // 16进制转int |
| | | return Math.Min(Math.Max(result, 1), maxCost); |
| | | } |
| | | set |
| | | { |
| | | QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_Cost, value); |
| | | //数字value 转16进制 |
| | | string hexValue = Convert.ToString(value, 16); |
| | | QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_Cost, hexValue, 0); |
| | | } |
| | | } |
| | | |
| | | //自动模式, 真正点击战锤消耗开启,和休息(或无材料)停止 |
| | | public bool isPause = false; //如打BOSS的情况,暂停自动战斗 后续可以补充每X秒检测下是否有异常 |
| | | |
| | | public bool restartMainStoryBattle = false; |
| | | public event Action AutoAttackEvent; |
| | | bool m_IsAutoAttack = false; |
| | | public bool isAutoAttack |
| | | { |
| | |
| | | return; |
| | | m_IsAutoAttack = value; |
| | | Debug.Log("isAutoAttack:" + m_IsAutoAttack); |
| | | AutoAttackEvent?.Invoke(); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public bool isAutoChangeBetterEquip |
| | | { |
| | | get |
| | | { |
| | | return QuickSetting.Instance.GetQuickSettingBool(QuickSettingType.AutoFight_AutoChangeBetterEquip, 0); |
| | | } |
| | | set |
| | | { |
| | | QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_AutoChangeBetterEquip, value); |
| | | } |
| | | } |
| | | public int startServerTime; // 开始时的服务器时间戳 |
| | | bool m_HasAutoExchanged = false; |
| | | public bool hasAutoExchanged // 是否已自动交换过 |
| | | { |
| | | get |
| | | { |
| | | return m_HasAutoExchanged; |
| | | } |
| | | set |
| | | { |
| | | if (m_HasAutoExchanged == value) |
| | | return; |
| | | m_HasAutoExchanged = value; |
| | | if (!value) |
| | | { |
| | | startServerTime = TimeUtility.AllSeconds; |
| | | } |
| | | } |
| | | } |
| | | |
| | | bool m_IsAutoExchangeDecomposeOld = false; |
| | | public bool isAutoExchangeDecomposeOld //是否替换后自动分解原装备 |
| | | { |
| | | get |
| | | { |
| | | return m_IsAutoExchangeDecomposeOld; |
| | | } |
| | | set |
| | | { |
| | | if (m_IsAutoExchangeDecomposeOld == value) |
| | | return; |
| | | m_IsAutoExchangeDecomposeOld = value; |
| | | if (value) |
| | | { |
| | | hasAutoExchanged = false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //自动挑战首领 |
| | | public bool isAutoChallengeBoss |
| | | { |
| | | get |
| | | { |
| | | return QuickSetting.Instance.GetQuickSettingBool(QuickSettingType.AutoFight_ChallengeBoss, 0); |
| | | } |
| | | set |
| | | { |
| | | QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_ChallengeBoss, value); |
| | | } |
| | | } |
| | | |
| | | //当前战败了x次;-1代表停止继续挑战 |
| | | private int m_NowChallengeCount = 0; |
| | | public float lastChallengeTime = 0; |
| | | public int nowChallengeCount |
| | | { |
| | | get { return m_NowChallengeCount; } |
| | | set |
| | | { |
| | | m_NowChallengeCount = value; |
| | | lastChallengeTime = Time.time; |
| | | // Debug.Log($"当前在主线Boss战败了{m_NowChallengeCount}次,上次战败时间是{lastChallengeTime}"); |
| | | if (m_NowChallengeCount >= tryChallengeCount) |
| | | { |
| | | m_NowChallengeCount = -1; //代表停止继续挑战BOSS, 但不是停止战斗 |
| | | isAutoChallengeBoss = false; //取消勾选自动挑战boss |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //自动挑战首领,战败x次停止 |
| | | public int tryChallengeCount |
| | | { |
| | | get |
| | | { |
| | | int value = QuickSetting.Instance.GetQuickSettingValue<int>(QuickSettingType.AutoFight_TryChallengeCount, 0); |
| | | return Math.Min(Math.Max(value, 1), maxTryChallengeCount); |
| | | } |
| | | set |
| | | { |
| | | QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_TryChallengeCount, value); |
| | | } |
| | | } |
| | | |
| | | //自动完成任务 |
| | | public bool isAutoFinishTask |
| | | { |
| | | get |
| | | { |
| | | return QuickSetting.Instance.GetQuickSettingBool(QuickSettingType.AutoFight_AutoFinishTask, 0); |
| | | } |
| | | set |
| | | { |
| | | QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_AutoFinishTask, value); |
| | | } |
| | | } |
| | | public event Action ChangeAutoEvent; |
| | | |
| | | |
| | | |
| | | |
| | | public int maxSpeed = 3; //最高速度 索引 |
| | | public int maxCost; //最高消耗 |
| | | public int[] autoCostWithBlessLV; //自动战斗消耗倍数关联祝福等级 |
| | | public int speed2UnlockMissionID; |
| | | |
| | | public int openAutoChallengeBossCond;//数值1:自动挑战首领解锁的关卡(需过关) |
| | | public int maxTryChallengeCount;//最大战败次数(下拉列表的最大值)解锁月卡有效 |
| | | public int maxTryChallengeCD; //打主线boss战败后,间隔x秒后重试 |
| | | public int openAutoFinishCond;//自动完成任务需祝福树X级 |
| | | public int autoCloseWinCD; |
| | | public int autoChangeBetterEquipWaitTimeS;//装备对比界面打开x秒后,为玩家替换高战力装备 |
| | | |
| | | public override void Init() |
| | | { |
| | | ParseConfig(); |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += BeforePlayerInit; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += OnBeforePlayerDataInitializeEventOnRelogin; |
| | | BattleManager.Instance.onBattleFieldCreate += OnCreateBattleField; |
| | | EventBroadcast.Instance.AddListener<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, OnSkillCast); |
| | | BlessLVManager.Instance.OnBlessLVUpdateEvent += UpdateRedpint; |
| | | TaskManager.Instance.OnTaskUpdate += OnTaskUpdate; |
| | | InvestModel.Instance.onInvestUpdate += OnInvestUpdate; |
| | | GlobalTimeEvent.Instance.secondEvent += OnSecondEvent; |
| | | |
| | | } |
| | | |
| | |
| | | { |
| | | BattleManager.Instance.onBattleFieldCreate -= OnCreateBattleField; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= BeforePlayerInit; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin -= OnBeforePlayerDataInitializeEventOnRelogin; |
| | | EventBroadcast.Instance.RemoveListener<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, OnSkillCast); |
| | | BlessLVManager.Instance.OnBlessLVUpdateEvent -= UpdateRedpint; |
| | | TaskManager.Instance.OnTaskUpdate -= OnTaskUpdate; |
| | | InvestModel.Instance.onInvestUpdate -= OnInvestUpdate; |
| | | GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent; |
| | | |
| | | } |
| | | |
| | |
| | | autoCostWithBlessLV = JsonMapper.ToObject<int[]>(config.Numerical1); |
| | | speed2UnlockMissionID = int.Parse(config.Numerical2); |
| | | maxCost = autoCostWithBlessLV.Length; |
| | | autoCloseWinCD = int.Parse(config.Numerical3); |
| | | autoChangeBetterEquipWaitTimeS = int.Parse(config.Numerical5); |
| | | config = FuncConfigConfig.Get("AutoGuaji1"); |
| | | openAutoChallengeBossCond = int.Parse(config.Numerical1); |
| | | maxTryChallengeCount = int.Parse(config.Numerical2); |
| | | maxTryChallengeCD = int.Parse(config.Numerical3); |
| | | openAutoFinishCond = int.Parse(config.Numerical4); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | fightingHeroSkinID = 0; |
| | | heroGuid = ""; |
| | | startServerTime = 0; |
| | | hasAutoExchanged = false; |
| | | } |
| | | |
| | | private void OnBeforePlayerDataInitializeEventOnRelogin() |
| | | { |
| | | nowChallengeCount = 0; |
| | | isAutoExchangeDecomposeOld = true; |
| | | } |
| | | |
| | | Dictionary<string, int> winWaitCloseDict = new Dictionary<string, int>(); |
| | | void OnSecondEvent() |
| | | { |
| | | ProccessCloseWin(); |
| | | } |
| | | void ProccessCloseWin() |
| | | { |
| | | if (!isAutoAttack) |
| | | return; |
| | | if (isAutoChallengeBoss) |
| | | { |
| | | if (UIManager.Instance.IsOpened<BattleVictoryWin>()) |
| | | { |
| | | if (!winWaitCloseDict.ContainsKey("BattleVictoryWin")) |
| | | { |
| | | winWaitCloseDict["BattleVictoryWin"] = 0; |
| | | } |
| | | |
| | | if (winWaitCloseDict["BattleVictoryWin"] == 0) |
| | | { |
| | | winWaitCloseDict["BattleVictoryWin"] = (int)Time.time; |
| | | } |
| | | else if (Time.time - winWaitCloseDict["BattleVictoryWin"] > AutoFightModel.Instance.autoCloseWinCD) |
| | | { |
| | | UIManager.Instance.CloseWindow<BattleVictoryWin>(); |
| | | winWaitCloseDict["BattleVictoryWin"] = 0; |
| | | } |
| | | } |
| | | |
| | | if (UIManager.Instance.IsOpened<BattleFailWin>()) |
| | | { |
| | | if (!winWaitCloseDict.ContainsKey("BattleFailWin")) |
| | | { |
| | | winWaitCloseDict["BattleFailWin"] = 0; |
| | | } |
| | | |
| | | if (winWaitCloseDict["BattleFailWin"] == 0) |
| | | { |
| | | winWaitCloseDict["BattleFailWin"] = (int)Time.time; |
| | | } |
| | | else if (Time.time - winWaitCloseDict["BattleFailWin"] > autoCloseWinCD) |
| | | { |
| | | UIManager.Instance.CloseWindow<BattleFailWin>(); |
| | | winWaitCloseDict["BattleFailWin"] = 0; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (isAutoFinishTask) |
| | | { |
| | | if (TaskManager.Instance.GetMainTaskState() == 2 && UIManager.Instance.IsOpened<HomeWin>() |
| | | && !UIManager.Instance.ExistAnyFullScreenOrMaskWin("") && !NewBieCenter.Instance.inGuiding) |
| | | { |
| | | //领取任务奖励 |
| | | CA504_tagCMPlayerGetReward getReward = new CA504_tagCMPlayerGetReward(); |
| | | getReward.RewardType = 66; |
| | | getReward.DataEx = (uint)TaskManager.Instance.mainTask.TaskID; |
| | | GameNetSystem.Instance.SendInfo(getReward); |
| | | return; |
| | | } |
| | | |
| | | if (UIManager.Instance.IsOpened<CommonGetItemWin>() && ItemLogicUtility.Instance.getItemEventName == "Task") |
| | | { |
| | | if (!winWaitCloseDict.ContainsKey("CommonGetItemWin")) |
| | | { |
| | | winWaitCloseDict["CommonGetItemWin"] = 0; |
| | | } |
| | | |
| | | if (winWaitCloseDict["CommonGetItemWin"] == 0) |
| | | { |
| | | winWaitCloseDict["CommonGetItemWin"] = (int)Time.time; |
| | | } |
| | | else if (Time.time - winWaitCloseDict["CommonGetItemWin"] > autoCloseWinCD) |
| | | { |
| | | UIManager.Instance.CloseWindow<CommonGetItemWin>(); |
| | | winWaitCloseDict["CommonGetItemWin"] = 0; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public void SaveAutoFightSetting() |
| | | { |
| | |
| | | return true; |
| | | |
| | | long showFightPower = FightPowerManager.Instance.GetFightPowerChange(item); |
| | | |
| | | if (showFightPower < 0) |
| | | |
| | | if (showFightPower <= 0) |
| | | { |
| | | EquipModel.Instance.SendEquipOP(new ushort[] { (ushort)item.gridIndex }, 1); |
| | | return true; |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | #region 主线战斗(自动和手动) |
| | | |
| | |
| | | |
| | | fightingHeroSkinID = teamHero.SkinID; |
| | | //战斗时没有GUID ,通过heroid查找 |
| | | var hero = TeamManager.Instance.GetTeam(TeamType.Story).GetHeroByHeroID(teamHero.heroId); |
| | | var hero = TeamManager.Instance.GetTeam(BattlePreSetType.Story).GetHeroByHeroID(teamHero.heroId); |
| | | if (hero != null) |
| | | { |
| | | heroGuid = hero.guid; |