| | |
| | | public Dictionary<int, Redpoint> redPointDict = new Dictionary<int, Redpoint>(); |
| | | |
| | | public int waitAdID = 0; //回调后发放奖励用 |
| | | public int waitRemainAdsCount = 0; //断线并不知是否领取成功 用次数做二次验证 |
| | | int loadErrorCD = 10; //等待10秒后才能再请求 |
| | | public float lastLoadErrorTime = 0; |
| | | |
| | | public override void Init() |
| | | { |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += OnBeforePlayerDataInitializeEvent; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += UpdateRedpoint; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += PlayerLoginOkEvent; |
| | | DungeonManager.Instance.UpdateFBInfoListEvent += OnUpdateFBInfoChangeEvent; |
| | | FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent; |
| | | |
| | |
| | | public override void Release() |
| | | { |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin -= OnBeforePlayerDataInitializeEvent; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= UpdateRedpoint; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= PlayerLoginOkEvent; |
| | | DungeonManager.Instance.UpdateFBInfoListEvent -= OnUpdateFBInfoChangeEvent; |
| | | FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent; |
| | | } |
| | |
| | | public void OnBeforePlayerDataInitializeEvent() |
| | | { |
| | | waitAdID = 0; |
| | | waitRemainAdsCount = 0; |
| | | adsInfoDict.Clear(); |
| | | } |
| | | |
| | | public void PlayerLoginOkEvent() |
| | | { |
| | | UpdateRedpoint(); |
| | | } |
| | | |
| | | private void OnUpdateFBInfoChangeEvent(int mapID) |
| | |
| | | GameNetSystem.Instance.SendInfo(pack); |
| | | } |
| | | |
| | | //查看广告等待太久可能导致奖励被清空,需要恢复 |
| | | public void RestoreAdsAward() |
| | | { |
| | | if (waitAdID == 0) return; |
| | | int adsCnt = GetADCntByADID(waitAdID); |
| | | var aDAwardConfig = ADAwardConfig.Get(waitAdID); |
| | | if (waitRemainAdsCount != 0 && waitRemainAdsCount == aDAwardConfig.ADCntMax - adsCnt) |
| | | { |
| | | //恢复奖励领取 |
| | | GetAdsAward(waitAdID); |
| | | } |
| | | |
| | | waitAdID = 0; |
| | | waitRemainAdsCount = 0; |
| | | } |
| | | |
| | | |
| | | //区分不同渠道是否有广告SDK |
| | | public void PlayAds(int ADID) |
| | | { |
| | |
| | | SysNotifyMgr.Instance.ShowTip("AdLoadFail"); |
| | | return; |
| | | } |
| | | |
| | | //等待广告的ID和剩余次数 |
| | | waitAdID = ADID; |
| | | int adsCnt = GetADCntByADID(waitAdID); |
| | | var aDAwardConfig = ADAwardConfig.Get(waitAdID); |
| | | waitRemainAdsCount = aDAwardConfig.ADCntMax - adsCnt; |
| | | |
| | | |
| | | SDKUtils.Instance.PlayAds("b69a2b68bb3d22"); |
| | | return; |
| | | } |
| | |
| | | UpdateRedpoint(); |
| | | |
| | | } |
| | | |
| | | RestoreAdsAward(); |
| | | } |
| | | |
| | | void UpdateRedpoint() |