| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- /** 点击信息流奖励数据类 */
- import NativeADAwardNode from "../ui/NativeAdAwardNode"
- import LogUtil from "../utils/LogUtil"
- import AdM from "./AdM"
- import GameM from "./GameM"
- import UiM from "./UiM"
- export default class NativeAdAwardData {
- ///单例
- private static instance: NativeAdAwardData = null
- public static get Instance() {
- if (this.instance == null) {
- this.instance = new NativeAdAwardData()
- }
- return this.instance
- }
- /** 打开点击信息流生效 */
- openNativeState = false
- /** 已点击信息流 */
- hasClickNative = false
- nativeAwardChanceArr = null;
- nativeShowLevel = 1
- nativeAwardTimes = 10
- /** 是否可显示领取奖励
- * @type 界面类型 1 工厂过热冷却 2 热气球奖励 3 车位上领取金币
- */
- canGetAward(type) {
- let value = GameM.globalStorage.getStorage('nativeAdAwardGet' + type)
- if (value == 1) {
- return true
- }
- else {
- return false
- }
- }
- /** 设置是否可显示领取奖励
- * @type 界面类型 1 工厂过热冷却 2 热气球奖励 3 车位上领取金币
- */
- setGetAward(type) {
- if (GameM.commonData.maxCarLevel < this.nativeShowLevel) {
- GameM.globalStorage.setStorage('nativeAdAwardGet' + type, 0)
- return
- }
- let value = GameM.globalStorage.getStorage('lastNativeAdAwardGet' + type)
- let chance = Number(this.nativeAwardChanceArr[type - 1])
- LogUtil.logV('NativeAdAward ', 'type ' + type)
- LogUtil.logV('NativeAdAward ', 'chance ' + chance)
- let can = false
- switch (type) {
- case 1:
- //上次出现过,此次必定不出现
- if (value != null && value != 0) {
- GameM.globalStorage.setStorage('lastNativeAdAwardGet' + type, 0)
- return
- }
- if (Math.random() <= chance) {
- can = true
- }
- break
- case 2:
- //上次出现过,此次必定不出现
- if (value != null && value != 0) {
- GameM.globalStorage.setStorage('lastNativeAdAwardGet' + type, 0)
- return
- }
- if (Math.random() <= chance) {
- can = true
- }
- break
- case 3:
- if (Math.random() <= chance) {
- can = true
- }
- break
- }
- LogUtil.logV('NativeAdAward ', 'can ' + can)
- if (can) {
- GameM.globalStorage.setStorage('nativeAdAwardGet' + type, 1)
- GameM.globalStorage.setStorage('lastNativeAdAwardGet' + type, 1)
- // AdM.onSendEvent('NativeAdAwardCreate' + type, `信息流变现触发${type}`, 'NativeAdAwardCreate')
- }
- else {
- GameM.globalStorage.setStorage('nativeAdAwardGet' + type, 0)
- }
- }
- /**
- * 重置是否可显示领取奖励
- * @param type 1 工厂过热冷却 2 热气球奖励 3 车位上领取金币
- */
- resetGetAward(type) {
- GameM.globalStorage.setStorage('nativeAdAwardGet' + type, 0)
- }
- setHasClickNative() {
- this.hasClickNative = true
- if (UiM.Instance.nativeAdAwardNode) {
- UiM.Instance.nativeAdAwardNode.getComponent(NativeADAwardNode).setCanGet()
- }
- }
- }
|