| | |
| | | |
| | | public class FirstChargeManager : GameSystemManager<FirstChargeManager> |
| | | { |
| | | public const int FuncID = 21; |
| | | public int taskID; |
| | | public int nextTaskID; |
| | | public int mainItemId { get { return GetMainItemId(); } } |
| | | public int heroItemID; |
| | | public int maxGiftCount |
| | |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitializeEvent; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk; |
| | | RechargeManager.Instance.rechargeCountEvent += OnRechargeCountEvent; |
| | | FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent; |
| | | TaskManager.Instance.OnTaskUpdate += OnTaskUpdate; |
| | | InitClickTabDict(); |
| | | InitRedPoint(); |
| | | } |
| | |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitializeEvent; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk; |
| | | RechargeManager.Instance.rechargeCountEvent -= OnRechargeCountEvent; |
| | | FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent; |
| | | TaskManager.Instance.OnTaskUpdate -= OnTaskUpdate; |
| | | } |
| | | |
| | | private void OnFuncStateChangeEvent(int obj) |
| | | |
| | | public event Action OnFirstChargeTaskUpdateEvent; |
| | | int beforeMainID; |
| | | private void OnTaskUpdate() |
| | | { |
| | | if (FuncID == obj) |
| | | int currentTaskID = TaskManager.Instance.mainTask.TaskID; |
| | | |
| | | if (beforeMainID == taskID && currentTaskID == nextTaskID) |
| | | { |
| | | string key = $"FirstCharge_FirstTime_{FuncID}_{PlayerDatas.Instance.baseData.PlayerID}"; |
| | | string key = $"FirstCharge_FirstTime_{taskID}_{PlayerDatas.Instance.baseData.PlayerID}"; |
| | | if (!LocalSave.HasKey(key)) |
| | | { |
| | | // 第一次开启功能 |
| | | // 第一次完成任务 |
| | | LocalSave.SetBool(key, true); |
| | | PopupWindowsProcessor.Instance.Add("FirstChargeWin"); |
| | | OnFirstChargeTaskUpdateEvent?.Invoke(); |
| | | } |
| | | } |
| | | beforeMainID = currentTaskID; |
| | | } |
| | | |
| | | public void InitClickTabDict() |
| | |
| | | public void OnBeforePlayerDataInitializeEvent() |
| | | { |
| | | firstChargeInfoDict.Clear(); |
| | | |
| | | FuncConfigConfig config = FuncConfigConfig.Get("FirstCharge"); |
| | | taskID = int.Parse(config.Numerical1); |
| | | nextTaskID = int.Parse(config.Numerical2); |
| | | } |
| | | |
| | | public void OnPlayerLoginOk() |
| | | { |
| | | if (FuncOpen.Instance.IsFuncOpen(FuncID) && TryGetUnBuyFirstId(out int firstId)) |
| | | if (IsFuncOpen() && TryGetUnBuyFirstId(out int firstId)) |
| | | { |
| | | PopupWindowsProcessor.Instance.Add("FirstChargeWin"); |
| | | } |
| | |
| | | return; |
| | | if (battleName == "TianziBillboradBattleField") |
| | | return; |
| | | if (!FuncOpen.Instance.IsFuncOpen(FuncID)) |
| | | if (!IsFuncOpen()) |
| | | return; |
| | | if (!TryGetUnBuyFirstId(out int firstId)) |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | public string loaclKey = "FirstCharge_Fail_"; |
| | | |
| | | public bool GetLocalFail() |
| | | { |
| | | return LocalSave.GetBool(StringUtility.Contact(loaclKey + PlayerDatas.Instance.PlayerId)); |
| | | } |
| | | |
| | | public void SetLocalFail() |
| | | { |
| | | LocalSave.SetBool(StringUtility.Contact(loaclKey + PlayerDatas.Instance.PlayerId), true); |
| | | } |
| | | |
| | | public bool IsFuncOpen() |
| | | { |
| | | if (IsBuyOne()) |
| | | return true; |
| | | if (TaskConfig.HasKey(taskID) && |
| | | TaskManager.Instance.mainTask != null && |
| | | TaskConfig.HasKey(TaskManager.Instance.mainTask.TaskID) && |
| | | TaskManager.Instance.GetNeedFinishTaskCount(taskID) <= 0) |
| | | return true; |
| | | bool isLocalFail = GetLocalFail(); |
| | | return isLocalFail; |
| | | } |
| | | |
| | | // 有一档被购买就返回true |
| | | public bool IsBuyOne() |
| | | { |
| | | var firstChargeList = FirstChargeConfig.GetKeys(); |
| | | if (firstChargeList != null) |
| | | { |
| | | firstChargeList.Sort(); |
| | | foreach (int item in firstChargeList) |
| | | { |
| | | if (TryGetFirstChargeDataByFirstId(item, out FirstChargeData data)) |
| | | { |
| | | if (data.IsUnlock() && data.IsBuy()) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public bool TryGetUnBuyFirstId(out int firstId) |
| | | { |
| | | firstId = 0; |