Browse Source

[FC:]增加开屏广告、其他优化调整

fengcong 5 years ago
parent
commit
2083eb580c

+ 3 - 0
assets/resources/game/prefab/uiPanel/GameOverUI.prefab

@@ -1887,6 +1887,9 @@
       "__id__": 1
     },
     "_enabled": true,
+    "node_bg": {
+      "__id__": 2
+    },
     "_id": ""
   },
   {

+ 9 - 2
assets/script/before/GamePlay.ts

@@ -420,7 +420,7 @@ export default class GamePlay extends cc.Component {
         this.curXIndex++;
         if (this.curXIndex >= GameConst.col_num) {
             this.unschedule(this.addCellItemFuc);
-            this.getStartRedPacketCellItem();
+            // this.getStartRedPacketCellItem();
         }
     }
 
@@ -1162,10 +1162,17 @@ export default class GamePlay extends cc.Component {
     public interval_ShowInter: number = null;
     //间隔显示
     intervalShowInter() {
+        let time = gData.gameData.configs.ServerConfig.interOpenGapTime;
+        if (!time) {
+            time = 15000;
+        }
+        else {
+            time *= 1000;
+        }
         this.cancelShowInter();
         this.interval_ShowGuide = setInterval(() => {
             mk.ad.showInterAd(0);
-        }, 15000);
+        }, time);
     }
 
     cancelShowInter() {

+ 4 - 0
assets/script/before/view/GameOverUI.ts

@@ -5,12 +5,16 @@ const { ccclass, property } = cc._decorator;
 
 @ccclass
 export default class GameOverUI extends cc.Component {
+   
+    @property(cc.Node)
+    node_bg:cc.Node = null;
 
     // LIFE-CYCLE CALLBACKS:
 
     // onLoad () {}
 
     start() {
+        this.node_bg.setContentSize(cc.winSize.width, cc.winSize.height);
         mk.ad.showNative(4);
     }
 

+ 2 - 0
assets/script/game/module/login/Login.ts

@@ -58,6 +58,8 @@ export default class Login extends cc.Component {
                 }
                 else {
                     mk.ui.openPanel("game/prefab/game");
+                    console.log("===[Jsbsystem 显示开屏广告================================")
+                    JsbSystem.showSplash();
                 }
 
                 gData.gameData.dataFinish = false;

+ 6 - 3
assets/script/mk/system/AdSystem.ts

@@ -96,7 +96,7 @@ export default class AdSystem {
 
     /** 显示原生广告 */
     public showNative(type = 4) {
-        
+
         if (!this.ifShowAd) {
             return;
         }
@@ -198,8 +198,11 @@ export default class AdSystem {
         if (!gData.gameData.adShowConfig) {
             return;
         }
-
-        if (Math.random() <= gData.gameData.adShowConfig.insert_probability) {
+        let chance = gData.gameData.configs.ServerConfig.interOpenChance;
+        if (!chance) {
+            chance = 0.4;
+        }
+        if (Math.random() <= chance) {
             this.showInterAd(0);
         }
         else {

+ 11 - 0
assets/script/mk/system/JsbSystem.ts

@@ -139,6 +139,17 @@ export default class JsbSystem {
         }
         return str;
     }
+    
+    /** 显示开屏 */
+    static showSplash() {
+        // mk.data.sendDataEvent('slashAd', '开屏')
+        if (cc.sys.os == cc.sys.OS_ANDROID) {
+            this.callStaticMethod(this._JSB_ANDROID_PATH, "showSplash", "()V");
+        }
+        else if (cc.sys.os == cc.sys.OS_IOS) {
+            jsb.reflection.callStaticMethod("GameConfig", "showSplash:", "");
+        }
+    }
 
     /**
      * 复制到剪切板

BIN
build/jsb-link/frameworks/runtime-src/proj.android-studio/.idea/caches/build_file_checksums.ser


+ 6 - 0
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml

@@ -95,6 +95,12 @@
         </provider>
         <!-- source file: china/network_sdk/baidu/AndroidManifest.xml -->
 
+        <!-- 开屏广告 -->
+        <activity
+            android:name="org.cocos2dx.javascript.thirdSdk.ad.SplashAdShowActivity"
+            android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"
+            android:configChanges="keyboardHidden|orientation|keyboard|smallestScreenSize|screenSize|screenLayout"/>
+
         <!-- 安装apk -->
         <provider
             android:name="androidx.core.content.FileProvider"

+ 1 - 1
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/gradle.properties

@@ -12,7 +12,7 @@ MY_APP_NAME=\u5929\u5929\u7231\u6d88\u6d88
 PACKAGE_NAME=com.aries.qsllx.mz
 VERSION_NAME=1.0.1
 VERSION_CODE=2
-TOPON="a60cac090a6eb0,66b742dd0e502b64d783d9c66a9d30c4,b60cac0e43c0e1,b60cac0e4892fa,b60cac0e4d08e8,b60cac0e5754fc,b60cac0e524313"; //巨量渠道topon的 AppId,AppSecreate,激励视频,插屏,信息流,全屏开屏
+TOPON="a60cac090a6eb0,66b742dd0e502b64d783d9c66a9d30c4,b60cac0e43c0e1,b60cac0e4892fa,b60cac0e4d08e8,b60cac0e5754fc,b60cac0e524313"; //巨量渠道topon的 AppId,AppSecreate,激励视频,插屏,信息流,全屏开屏,banner
 APP_CONFIG_CODE="1.0.0"
 
 

BIN
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/release/EasyEliminate-release.apk


+ 8 - 0
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/thirdSdk/ThirdSdkMgr.java

@@ -3,9 +3,11 @@ package org.cocos2dx.javascript.thirdSdk;
 import android.content.ClipData;
 import android.content.ClipboardManager;
 import android.content.Context;
+import android.content.Intent;
 import android.util.Log;
 
 import org.cocos2dx.javascript.AppActivity;
+import org.cocos2dx.javascript.thirdSdk.ad.SplashAdShowActivity;
 import org.cocos2dx.javascript.thirdSdk.thinkingdata.TDSDKMgr;
 import org.cocos2dx.javascript.util.DeviceUtil;
 import org.cocos2dx.lib.Cocos2dxJavascriptJavaBridge;
@@ -147,4 +149,10 @@ public class ThirdSdkMgr {
         boolean isExist = ThirdSdkMgr.appActivity.checkStartApp(pkg, start);
         return isExist;
     }
+
+    //显示开屏广告 ----------------------------------------------------------------------------------
+    public static void showSplash(){
+        Log.d("===[ThirdSdkMgr ","显示开屏广告");
+        ThirdSdkMgr.appActivity.startActivity(new Intent( ThirdSdkMgr.appActivity, SplashAdShowActivity.class));
+    }
 }

+ 187 - 0
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/thirdSdk/ad/SplashAdShowActivity.java

@@ -0,0 +1,187 @@
+package org.cocos2dx.javascript.thirdSdk.ad;
+
+import android.content.pm.ActivityInfo;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.os.CountDownTimer;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import androidx.fragment.app.FragmentActivity;
+
+import com.anythink.core.api.ATAdConst;
+import com.anythink.core.api.ATAdInfo;
+import com.anythink.core.api.ATMediationRequestInfo;
+import com.anythink.core.api.AdError;
+import com.anythink.splashad.api.ATSplashAd;
+import com.anythink.splashad.api.ATSplashAdListener;
+import com.aries.qsllx.mz.BuildConfig;
+import com.aries.qsllx.mz.R;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class SplashAdShowActivity extends FragmentActivity implements ATSplashAdListener {
+
+    ATSplashAd splashAd;
+    private String unitId = "";
+    private FrameLayout container;
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        unitId = BuildConfig.TOPON.split(",")[5];
+        setContentView(R.layout.splash_ad_show);
+
+//        String[] arr = BuildConfig.JL_TOPON.split(",");
+//        unitId = arr[arr.length - 1];
+//        String unitId = getIntent().getStringExtra("b5f8d40ea99cea");
+
+        container = findViewById(R.id.splash_ad_container);
+        ViewGroup.LayoutParams layoutParams = container.getLayoutParams();
+
+        Configuration cf = getResources().getConfiguration();
+        int ori = cf.orientation;
+
+        /**You should set size to the layout param.**/
+        if (ori == Configuration.ORIENTATION_LANDSCAPE) {
+            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
+            layoutParams.width = (int)(getResources().getDisplayMetrics().widthPixels * 0.9);
+            layoutParams.height = getResources().getDisplayMetrics().heightPixels;
+        } else if (ori == Configuration.ORIENTATION_PORTRAIT) {
+            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
+            layoutParams.width = getResources().getDisplayMetrics().widthPixels;
+            layoutParams.height = (int) (getResources().getDisplayMetrics().heightPixels * 0.85);
+        } else {
+            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
+            layoutParams.width = getResources().getDisplayMetrics().widthPixels;
+            layoutParams.height = (int) (getResources().getDisplayMetrics().heightPixels * 0.85);
+        }
+
+        //v5.6.2新增,针对首次安装获取TopOn策略导致开屏广告加载超时,可传递各广告平台参数,直接发起请求
+        //请参考:https://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_splash_access?id=splash_timeout
+        ATMediationRequestInfo atMediationRequestInfo = null;
+
+        //Mintegral
+        //atMediationRequestInfo = new MintegralATRequestInfo(appid, appkey, placement_id, unitid);
+        //atMediationRequestInfo.setAdSourceId(mintegralTopOnAdsourceId);
+
+        //腾讯广告(Tencent Ads)
+        //atMediationRequestInfo = new GDTATRequestInfo(app_id, unit_id);
+        //atMediationRequestInfo.setAdSourceId(gdtTopOnAdsourceId);
+
+        //穿山甲(Pangle)
+        //atMediationRequestInfo = new TTATRequestInfo(app_id, slot_id, personalized_template);
+        //atMediationRequestInfo.setAdSourceId(pangleTopOnAdsourceId);
+
+        //Sigmob
+        //atMediationRequestInfo = new SigmobiATRequestInfo(app_id, app_key, placement_id);
+        //atMediationRequestInfo.setAdSourceId(sigmobTopOnAdsourceId);
+
+        //百度
+        //atMediationRequestInfo = new BaiduATRequestInfo(app_id, ad_place_id);
+        //atMediationRequestInfo.setAdSourceId(baiduTopOnAdsourceId);
+
+        //快手
+        //atMediationRequestInfo  = new KSATRequestInfo(app_id, position_id);
+        //atMediationRequestInfo.setAdSourceId(kuaishouTopOnAdsourceId);
+
+        //Admob
+        //atMediationRequestInfo = new AdmobATRequestInfo(app_id, unit_id, orientation);
+        //atMediationRequestInfo.setAdSourceId(admobTopOnAdsourceId);
+
+        //atMediationRequestInfo传入后,只针对首次请求开屏的情况生效,请详细阅读上方说明
+        splashAd = new ATSplashAd(this, unitId, atMediationRequestInfo, this, 5000);
+        //splashAd = new ATSplashAd(this, TopOnPlacementId, this);
+
+        Map<String,Object> localMap = new HashMap<>();
+        localMap.put(ATAdConst.KEY.AD_WIDTH, layoutParams.width);
+        localMap.put(ATAdConst.KEY.AD_HEIGHT, layoutParams.height);
+        splashAd.setLocalExtra(localMap);
+
+        if (splashAd.isAdReady()) {
+            Log.i("===[TAG", "SplashAd is ready to show.");
+            splashAd.show(this, container);
+        } else {
+            Log.i("===[TAG", "SplashAd isn't ready to show, start to request.");
+            splashAd.loadAd();
+        }
+    }
+
+    @Override
+    public void onAdLoaded() {
+        splashAd.show(this, container);
+    }
+
+    @Override
+    public void onNoAdError(AdError adError) {
+        //注意:禁止在此回调中执行广告的加载方法进行重试,否则会引起很多无用请求且可能会导致应用卡顿
+        //AdError,请参考 https://docs.toponad.com/#/zh-cn/android/android_doc/android_test?id=aderror
+        Log.e("TAG", "onNoAdError:" + adError.getFullErrorInfo());
+        jumpToMainActivity();
+    }
+
+    @Override
+    public void onAdShow(ATAdInfo atAdInfo) {
+        //ATAdInfo可区分广告平台以及获取广告平台的广告位ID等
+        //请参考 https://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_callback_access?id=callback_info
+    }
+
+    @Override
+    public void onAdClick(ATAdInfo atAdInfo) {
+
+    }
+
+    @Override
+//  public void onAdDismiss(ATAdInfo atAdInfo, IATSplashEyeAd splashEyeAd) {//v5.7.47开始,请使用此回调
+    public void onAdDismiss(ATAdInfo atAdInfo) {//低于v5.7.47,请使用此回调
+        jumpToMainActivity();
+    }
+
+    boolean hasHandleJump = false;
+    boolean canJump;//是否可以跳转主页面,当开屏Activity处于后台时禁止跳转主页面
+
+    public void jumpToMainActivity() {
+
+        if (!canJump) {
+            canJump = true;
+            return;
+        }
+
+        if (!hasHandleJump) {
+            hasHandleJump = true;
+            finish();
+            Toast.makeText(this, "start your MainActivity.", Toast.LENGTH_SHORT).show();
+        }
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        if (canJump) {
+            jumpToMainActivity();
+        }
+
+        canJump = true;
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+
+        canJump = false;
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        if (splashAd != null) {
+            splashAd.onDestory();
+        }
+    }
+}

+ 3 - 1
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/util/DeviceUtil.java

@@ -13,6 +13,8 @@ import android.telephony.TelephonyManager;
 import android.util.Log;
 import android.widget.Toast;
 
+import com.aries.qsllx.mz.R;
+
 import org.cocos2dx.javascript.thirdSdk.oaid.OaidHelper;
 
 import java.io.IOException;
@@ -109,7 +111,7 @@ public class DeviceUtil {
 //            String  strMac1= getNewMac();
 //            Log.e("=====",strMac1);
             return strMac;
-            R
+
         }
         return "02:00:00:00:00:00";
     }

+ 52 - 0
build/jsb-link/frameworks/runtime-src/proj.android-studio/res/layout/splash_ad_show.xml

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="#ffffff">
+
+
+    <FrameLayout
+        android:id="@+id/splash_ad_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"></FrameLayout>
+
+    <TextView
+        android:id="@+id/splash_ad_skip"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentRight="true"
+        android:layout_margin="10dp"
+        android:paddingLeft="20dp"
+        android:paddingTop="5dp"
+        android:paddingRight="20dp"
+        android:paddingBottom="5dp"
+        android:textColor="#ffffff"
+        android:textSize="16dp"
+        android:visibility="gone"></TextView>
+
+    <LinearLayout
+        android:id="@+id/logo_area"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/splash_ad_container"
+        android:layout_alignParentBottom="true"
+        android:layout_centerHorizontal="true"
+        android:gravity="center">
+
+        <ImageView
+            android:id="@+id/app_logo"
+            android:layout_width="70dp"
+            android:layout_height="70dp"
+            android:scaleType="fitCenter"
+            android:src="@drawable/splash_icon" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerVertical="true"
+            android:layout_marginLeft="10dp"
+            android:text="@string/app_name"
+            android:textColor="#000000"
+            android:textSize="18dp" />
+    </LinearLayout>
+</RelativeLayout>

+ 25 - 11
build/jsb-link/js backups (useful for debugging)/main.index.js

@@ -1976,7 +1976,11 @@ t.prototype.showInterAd = function(t) {
 this.ifShowAd && this.adSdk.showInter(t);
 };
 t.prototype.checkShowInterByChance = function() {
-this.ifShowAd && gData.gameData.adShowConfig && (Math.random() <= gData.gameData.adShowConfig.insert_probability ? this.showInterAd(0) : gData.moreGame.popMoreGamePopNode());
+if (this.ifShowAd && gData.gameData.adShowConfig) {
+var t = gData.gameData.configs.ServerConfig.interOpenChance;
+t || (t = .4);
+Math.random() <= t ? this.showInterAd(0) : gData.moreGame.popMoreGamePopNode();
+}
 };
 return t;
 }();
@@ -7974,12 +7978,15 @@ return a > 3 && r && Object.defineProperty(e, n, r), r;
 Object.defineProperty(n, "__esModule", {
 value: !0
 });
-var r = t("../GamePlay"), c = cc._decorator, s = c.ccclass, l = (c.property, function(t) {
+var r = t("../GamePlay"), c = cc._decorator, s = c.ccclass, l = c.property, u = function(t) {
 i(e, t);
 function e() {
-return null !== t && t.apply(this, arguments) || this;
+var e = null !== t && t.apply(this, arguments) || this;
+e.node_bg = null;
+return e;
 }
 e.prototype.start = function() {
+this.node_bg.setContentSize(cc.winSize.width, cc.winSize.height);
 mk.ad.showNative(4);
 };
 e.prototype.onClickClose = function() {
@@ -7998,9 +8005,10 @@ r.default.Inst.node.active = !1;
 mk.ad.destroyNativeAd();
 mk.ui.closePanel(this.node.name);
 };
+a([ l(cc.Node) ], e.prototype, "node_bg", void 0);
 return a([ s ], e);
-}(cc.Component));
-n.default = l;
+}(cc.Component);
+n.default = u;
 cc._RF.pop();
 }, {
 "../GamePlay": "GamePlay"
@@ -8276,10 +8284,7 @@ e.prototype.addCellItem = function() {
 mk.console.log("addCellItem!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
 this.addColCellItem();
 this.curXIndex++;
-if (this.curXIndex >= l.default.col_num) {
-this.unschedule(this.addCellItemFuc);
-this.getStartRedPacketCellItem();
-}
+this.curXIndex >= l.default.col_num && this.unschedule(this.addCellItemFuc);
 };
 e.prototype.addColCellItem = function() {
 this.cellItemDic[this.curXIndex] = [];
@@ -8650,10 +8655,12 @@ this.couldCleanVecArr = [];
 }
 };
 e.prototype.intervalShowInter = function() {
+var t = gData.gameData.configs.ServerConfig.interOpenGapTime;
+t ? t *= 1e3 : t = 15e3;
 this.cancelShowInter();
 this.interval_ShowGuide = setInterval(function() {
 mk.ad.showInterAd(0);
-}, 15e3);
+}, t);
 };
 e.prototype.cancelShowInter = function() {
 this.interval_ShowGuide && clearInterval(this.interval_ShowGuide);
@@ -10829,6 +10836,9 @@ var t = "";
 cc.sys.os == cc.sys.OS_ANDROID ? t = this.callStaticMethod(this._JSB_ANDROID_PATH, "getAdvertisingChannel", "()Ljava/lang/String;") : cc.sys.os == cc.sys.OS_IOS && (t = this.callStaticMethod("CsjAdReward", "AdvertisingChannel", ""));
 return t;
 };
+t.showSplash = function() {
+cc.sys.os == cc.sys.OS_ANDROID ? this.callStaticMethod(this._JSB_ANDROID_PATH, "showSplash", "()V") : cc.sys.os == cc.sys.OS_IOS && jsb.reflection.callStaticMethod("GameConfig", "showSplash:", "");
+};
 t.setClipboard = function(t) {
 if (cc.sys.os == cc.sys.OS_ANDROID) this.callStaticMethod(this._JSB_ANDROID_PATH, "setClipboard", "(Ljava/lang/String;)V", t); else if (cc.sys.os == cc.sys.OS_IOS) ; else if (cc.sys.isBrowser) {
 var e = t, n = document.createElement("textarea");
@@ -11672,7 +11682,11 @@ if (gData.appData.getDeviceInfoCompelete) {
 this.login();
 gData.appData.getDeviceInfoCompelete = !1;
 } else if (gData.gameData.dataFinish) {
-gData.gameData.isNewPlayer() ? mk.ui.openPanel("module/login/agreementTip") : mk.ui.openPanel("game/prefab/game");
+if (gData.gameData.isNewPlayer()) mk.ui.openPanel("module/login/agreementTip"); else {
+mk.ui.openPanel("game/prefab/game");
+console.log("===[Jsbsystem 显示开屏广告================================");
+l.default.showSplash();
+}
 gData.gameData.dataFinish = !1;
 }
 } else gData.loginData.loadLocalRes();

+ 2 - 2
packages-hot-update/cfg.json

@@ -7,7 +7,7 @@
         "http://",
         "https://xcx-box.oss-cn-hangzhou.aliyuncs.com/hotgame/EasyEliminateTest/baseRemote/"
     ],
-    "buildTime": 1625058927456,
-    "genTime": 1625058927456,
+    "buildTime": 1625197749282,
+    "genTime": 1625197749282,
     "genVersion": null
 }