| | |
| | | {
|
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += OnBeforePlayerDataInitialize;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent += OnPlayerDataRefresh;
|
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
|
| | |
|
| | |
|
| | | m_MaxWorkerCount = GoldRushWorkerConfig.GetKeys().Count;
|
| | |
|
| | |
| | | {
|
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin -= OnBeforePlayerDataInitialize;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent -= OnPlayerDataRefresh;
|
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
|
| | | }
|
| | |
|
| | | void ParseConfig()
|
| | |
| | | }
|
| | |
|
| | |
|
| | | void OnPlayerLoginOk()
|
| | | {
|
| | | //自动淘金未解锁的设置不勾选
|
| | | for (int i = 0; i < autoRefreshItemIDs.Length; i++)
|
| | | {
|
| | | var itemID = autoRefreshItemIDs[i];
|
| | | if (IsLock(itemID, out int funcID) && GetAutoItemLV(i) != 0)
|
| | | {
|
| | | SetAutoItemLV(i, 0);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | void OnPlayerDataRefresh(PlayerDataType type)
|
| | | {
|
| | |
| | | {
|
| | | UpdateRedpoint();
|
| | | }
|
| | | else if (type == PlayerDataType.GoldRush)
|
| | | {
|
| | | SetAutoWorking(isOpenAuto, UIHelper.GetMoneyCnt(52) > 0);
|
| | | }
|
| | | // else if (type == PlayerDataType.GoldRush)
|
| | | // {
|
| | | // ResumeAutoWorking();
|
| | | // }
|
| | | }
|
| | |
|
| | |
|
| | |
| | | warehouseIDList = netPack.WarehouseIDList;
|
| | | lastRecoverTime = (int)netPack.LastRecoverTime;
|
| | | UpdateRedpoint();
|
| | |
|
| | | ResumeAutoWorking();
|
| | | OnGoldRushInfoEvent?.Invoke();
|
| | | }
|
| | |
|
| | |
| | | return (int)campInfoDict[campID].EndTime;
|
| | | }
|
| | | return 0;
|
| | | }
|
| | |
|
| | | //有可进行和进行中的
|
| | | public bool HasWorking()
|
| | | {
|
| | | return campInfoDict.Values.Any(x => x.GoldID != 0);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | {
|
| | | var value = QuickSetting.Instance.GetQuickSettingValue<int>(QuickSettingType.AutoGoldRush, index);
|
| | | if (value == 9)
|
| | | { |
| | | {
|
| | | return 0;
|
| | | }
|
| | | return value + 1;
|
| | |
| | | public void SetAutoItemLV(int index, int value)
|
| | | {
|
| | | if (value == 0)
|
| | | { |
| | | {
|
| | | value = 9;
|
| | | }
|
| | | else
|
| | |
| | | QuickSetting.Instance.SendPackage();
|
| | | }
|
| | |
|
| | | void OnSecondEvent()
|
| | | {
|
| | | if (!isAutoWorking || !isOpenAuto)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (UIHelper.GetMoneyCnt(52) <= 0 && !HasWorking())
|
| | | {
|
| | | PauseAutoWorking();
|
| | | SysNotifyMgr.Instance.ShowTip("GoldRush10");
|
| | | return;
|
| | | }
|
| | | if (GetFinishGoldRushCount() >= warehouseMaxCnt)
|
| | | {
|
| | | PauseAutoWorking();
|
| | | SysNotifyMgr.Instance.ShowTip("GoldRush9");
|
| | | return;
|
| | | }
|
| | | if (GetWarehouseCnt() >= warehouseMaxCnt)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | AutoWorking();
|
| | | }
|
| | |
|
| | | public void StartAutoWorking()
|
| | | {
|
| | | GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
|
| | | SetAutoWorking(true, true);
|
| | | }
|
| | |
|
| | | public void StopAutoWorking()
|
| | | {
|
| | | GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
|
| | |
|
| | | SetAutoWorking(false, false);
|
| | | }
|
| | |
|
| | | public void PauseAutoWorking()
|
| | | {
|
| | | GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
|
| | | SetAutoWorking(isOpenAuto, false);
|
| | | }
|
| | |
|
| | | public void ResumeAutoWorking()
|
| | | {
|
| | | if (UIHelper.GetMoneyCnt(52) <= 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (GetFinishGoldRushCount() >= warehouseMaxCnt)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (!UIManager.Instance.IsOpened<AffairBaseWin>())
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (isOpenAuto && !isAutoWorking)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("GoldRush11");
|
| | | StartAutoWorking();
|
| | | }
|
| | | }
|
| | |
|
| | | void AutoWorking()
|
| | | {
|
| | | bool isRefreshing = false;
|
| | | //先刷营地
|
| | | foreach (var campID in campInfoDict.Keys)
|
| | | {
|
| | | var campInfo = campInfoDict[campID];
|
| | | if (campInfo.GoldID != 0 && campInfo.EndTime != 0)
|
| | | {
|
| | | //正在采集中
|
| | | continue;
|
| | | }
|
| | | var lockState = GetCampLockState(campID);
|
| | | if (lockState != 0)
|
| | | {
|
| | | //未解锁
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (campInfo.GoldID == 0)
|
| | | {
|
| | | SendGoldRushOP(0, campID, 0);
|
| | | isRefreshing = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | //是否满足条件
|
| | | var config = GoldRushItemConfig.Get(campInfo.GoldID);
|
| | | var needLV = GetAutoItemLV(Array.IndexOf(autoRefreshItemIDs, config.ItemID));
|
| | |
|
| | | if (needLV == 0 || config.ItemLV < needLV)
|
| | | {
|
| | | if (!UIHelper.CheckMoneyCount(refreshMoneyType, GetRefreshMoney(campID), 0))
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | //存在货币不足也会同时请求刷新的情况
|
| | | SendGoldRushOP(1, campID, 0);
|
| | | isRefreshing = true;
|
| | | continue;
|
| | | }
|
| | |
|
| | | isRefreshing = true;
|
| | | //开始采集
|
| | | SendGoldRushOP(2, campID, 1);
|
| | | }
|
| | | }
|
| | |
|
| | | //填充监工
|
| | | if (isRefreshing) return;
|
| | |
|
| | | foreach (var campID in campInfoDict.Keys)
|
| | | {
|
| | | var campInfo = campInfoDict[campID];
|
| | | var config = GoldRushItemConfig.Get(campInfo.GoldID);
|
| | | if (campInfo.GoldID != 0 && campInfo.EndTime != 0)
|
| | | {
|
| | | //正在采集中 增加监工, 一次循环只增加一个监工
|
| | | if (campInfo.WorkerCnt < config.WorkerMax && GetEmptyWorkerCount() > 0)
|
| | | {
|
| | | SendGoldRushOP(2, campID, campInfo.WorkerCnt + 1);
|
| | | break;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | public int GetRefreshMoney(int campID)
|
| | | {
|
| | | var refreshCnt = GetCampRefreshCnt(campID);
|
| | | return refreshMoneyList[Math.Min(refreshCnt, refreshMoneyList.Length - 1)];
|
| | | }
|
| | | |
| | | public bool IsLock(int itemID, out int funcID)
|
| | | {
|
| | | funcID = 0;
|
| | | if (itemIDUnLockFuncIDDict.ContainsKey(itemID))
|
| | | {
|
| | | funcID = itemIDUnLockFuncIDDict[itemID];
|
| | | if (!FuncOpen.Instance.IsFuncOpen(funcID))
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | return false;
|
| | | }
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|