yingchigamesdk-cocos-v3 25.8.6 → 25.8.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -66,6 +66,16 @@ var StorageUtils = class {
66
66
  if (value == "false") return false;
67
67
  return false;
68
68
  }
69
+ static setIntData(key, value) {
70
+ sys.localStorage.setItem(key, value.toString());
71
+ }
72
+ static getIntgData(key) {
73
+ let value = sys.localStorage.getItem(key);
74
+ if (value) {
75
+ return parseInt(value);
76
+ }
77
+ return 0;
78
+ }
69
79
  };
70
80
 
71
81
  // assets/script/ycsdk/minigame/md5.ts
@@ -1542,28 +1552,37 @@ var OppoGame = class {
1542
1552
  this.count = 0;
1543
1553
  console.log("current channel is oppo");
1544
1554
  }
1545
- init(callback) {
1555
+ init(callback, adconfig) {
1546
1556
  if (sdkconfig.subornUserTest) {
1547
1557
  sdkconfig.subornUser = true;
1548
- this.config();
1558
+ this.config(adconfig);
1549
1559
  callback && callback();
1550
1560
  return;
1551
1561
  }
1552
- const info = this.qg.getEnterOptionsSync();
1562
+ let info = this.qg.getEnterOptionsSync();
1553
1563
  console.log("oppo init: ", info);
1554
1564
  if (info) {
1555
- const type = info.type;
1556
- const query = info.query;
1557
- const referrerInfo = info.referrerInfo;
1565
+ let type = info.type;
1566
+ let query = info.query;
1567
+ let referrerInfo = info.referrerInfo;
1558
1568
  if (query && query.key1 && query.key2) {
1559
1569
  sdkconfig.subornUser = true;
1560
- this.config();
1570
+ this.config(adconfig);
1561
1571
  }
1562
1572
  }
1563
1573
  callback && callback();
1564
1574
  }
1565
- config() {
1566
- this.loadVideoAdNoCallBack();
1575
+ config(adconfig) {
1576
+ if (!adconfig.switch) {
1577
+ return;
1578
+ }
1579
+ if (adconfig.delay > 0) {
1580
+ setTimeout(() => {
1581
+ this.loadVideoAdNoCallBack(adconfig.count);
1582
+ }, adconfig.delay * 1e3);
1583
+ return;
1584
+ }
1585
+ this.loadVideoAdNoCallBack(adconfig.count);
1567
1586
  }
1568
1587
  login(callBack) {
1569
1588
  }
@@ -1671,7 +1690,8 @@ var OppoGame = class {
1671
1690
  console.log("\u539F\u751F\u6A21\u677F\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
1672
1691
  return;
1673
1692
  }
1674
- if (this.qg.getSystemInfoSync().platformVersionCode < 1094) {
1693
+ let { windowHeight, windowWidth, platformVersionCode, screenWidth, screenHeight } = this.qg.getSystemInfoSync();
1694
+ if (platformVersionCode < 1094) {
1675
1695
  console.log("\u5FEB\u5E94\u7528\u5E73\u53F0\u7248\u672C\u53F7\u4F4E\u4E8E1094,\u6682\u4E0D\u652F\u6301\u539F\u751F\u6A21\u677F\u5E7F\u544A\u76F8\u5173API");
1676
1696
  return;
1677
1697
  }
@@ -1682,10 +1702,9 @@ var OppoGame = class {
1682
1702
  this.nativeAd = this.qg.createCustomAd({
1683
1703
  adUnitId: sdkconfig.ycNativeId,
1684
1704
  style: {
1685
- //开发者自行设置
1686
- top: this.qg.getSystemInfoSync().windowHeight * 0.3,
1687
- left: 0,
1688
- width: this.qg.getSystemInfoSync().screenWidth
1705
+ top: windowHeight * 0.4,
1706
+ left: (windowWidth - windowWidth * 0.6) / 2,
1707
+ width: windowWidth * 0.6
1689
1708
  }
1690
1709
  });
1691
1710
  this.nativeAd.onLoad(() => {
@@ -1737,7 +1756,7 @@ var OppoGame = class {
1737
1756
  videoCallBack && videoCallBack(false);
1738
1757
  return;
1739
1758
  }
1740
- const videoAd = this.qg.createRewardedVideoAd({
1759
+ let videoAd = this.qg.createRewardedVideoAd({
1741
1760
  adUnitId: sdkconfig.ycVideoId
1742
1761
  });
1743
1762
  videoAd.onLoad(() => {
@@ -1774,12 +1793,12 @@ var OppoGame = class {
1774
1793
  });
1775
1794
  videoAd.load();
1776
1795
  }
1777
- loadVideoAdNoCallBack() {
1796
+ loadVideoAdNoCallBack(adcount = 3) {
1778
1797
  if (!sdkconfig.ycVideoId) {
1779
1798
  console.log("\u89C6\u9891\u5E7F\u544A\u53C2\u6570\u6CA1\u6709\u914D\u7F6E");
1780
1799
  return;
1781
1800
  }
1782
- const videoAd = this.qg.createRewardedVideoAd({
1801
+ let videoAd = this.qg.createRewardedVideoAd({
1783
1802
  adUnitId: sdkconfig.ycVideoId
1784
1803
  });
1785
1804
  videoAd.onLoad(() => {
@@ -1792,11 +1811,10 @@ var OppoGame = class {
1792
1811
  });
1793
1812
  videoAd.onClose((res) => {
1794
1813
  this.count++;
1795
- console.log("oppo video count: ", this.count);
1796
- if (this.count >= 3) {
1814
+ if (this.count >= adcount) {
1797
1815
  return;
1798
1816
  }
1799
- this.loadVideoAdNoCallBack();
1817
+ this.loadVideoAdNoCallBack(adcount);
1800
1818
  });
1801
1819
  videoAd.load();
1802
1820
  YCSDK.ins.onLoad("Video" /* Video */);
@@ -2436,10 +2454,12 @@ var MiniGame = class {
2436
2454
  jsonToKeyValue(json) {
2437
2455
  return Object.entries(json).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
2438
2456
  }
2439
- init(callBack) {
2457
+ init(callBack, adconfig) {
2458
+ if (!adconfig) adconfig = { switch: false, count: 0, delay: 0 };
2440
2459
  if (!YCSDK.ins.isRun(sys6.Platform.OPPO_MINI_GAME)) {
2441
2460
  this.setAdStateListener();
2442
- this.channel.init(callBack);
2461
+ adconfig.switch = false;
2462
+ this.channel.init(callBack, adconfig);
2443
2463
  return;
2444
2464
  }
2445
2465
  const url = "https://iaa.rhino-times.com/api/game/query-match-config";
@@ -2449,15 +2469,19 @@ var MiniGame = class {
2449
2469
  HttpRequest.get().requestPostjson(url, data, (success, result) => {
2450
2470
  if (!success || !result) {
2451
2471
  this.setAdStateListener();
2452
- this.channel.init(callBack);
2472
+ adconfig.switch = false;
2473
+ this.channel.init(callBack, adconfig);
2453
2474
  return;
2454
2475
  }
2455
2476
  const res = result.oexts;
2456
2477
  sdkconfig.open = result.open;
2457
2478
  sdkconfig.ratio = res.ratio;
2458
2479
  sdkconfig.subornUserTest = res.subornUserTest;
2480
+ if (res.subornVideoConfig) {
2481
+ adconfig = res.subornVideoConfig;
2482
+ }
2459
2483
  this.setAdStateListener();
2460
- this.channel.init(callBack);
2484
+ this.channel.init(callBack, adconfig);
2461
2485
  });
2462
2486
  }
2463
2487
  setAdStateListener() {
@@ -2493,13 +2517,13 @@ var MiniGame = class {
2493
2517
  callBack.onAgree && callBack.onAgree();
2494
2518
  StorageUtils.setStringData(this.privacyKey, "agree");
2495
2519
  yinsiUI.active = false;
2496
- });
2520
+ }, this);
2497
2521
  const disagree = yinsiUI.getChildByName("panel").getChildByName("disagree");
2498
2522
  disagree.on(Node4.EventType.TOUCH_END, () => {
2499
- yinsiUI.getChildByName("panel").getChildByName("tip").active = true;
2500
2523
  callBack.onDisAgree && callBack.onDisAgree();
2501
- });
2502
- node.addChild(yinsiUI);
2524
+ yinsiUI.getChildByName("panel").getChildByName("tip").active = true;
2525
+ }, this);
2526
+ YCSDK.ins.getGameNode().addChild(yinsiUI);
2503
2527
  });
2504
2528
  }
2505
2529
  login(callBack) {
@@ -2624,7 +2648,7 @@ var YCSDK = class _YCSDK {
2624
2648
  isRun(platform) {
2625
2649
  return sys7.platform == platform;
2626
2650
  }
2627
- init(config, callBack) {
2651
+ init(config, callBack, adconfig) {
2628
2652
  console.log("ycsdk init");
2629
2653
  if (!config) {
2630
2654
  console.log("ycsdk init fail, config is null");
@@ -2639,7 +2663,7 @@ var YCSDK = class _YCSDK {
2639
2663
  sdkconfig.videoId = config.videoId;
2640
2664
  sdkconfig.nativeBannerId = config.nativeBannerId;
2641
2665
  sdkconfig.extension = config.extension;
2642
- this.platform.init(callBack);
2666
+ this.platform.init(callBack, adconfig);
2643
2667
  }
2644
2668
  agreePrivacy() {
2645
2669
  if (this.isRun(sys7.Platform.ANDROID)) {
@@ -2685,6 +2709,10 @@ var YCSDK = class _YCSDK {
2685
2709
  this.platform.customFunc(methodName, params, callBack);
2686
2710
  }
2687
2711
  setAdStateListener(state) {
2712
+ if (!state) {
2713
+ console.log("state is null, can not add to list");
2714
+ return;
2715
+ }
2688
2716
  if (this.states.includes(state)) {
2689
2717
  console.log("setAdStateListener interface is called");
2690
2718
  return;
@@ -2707,7 +2735,7 @@ var YCSDK = class _YCSDK {
2707
2735
  return;
2708
2736
  }
2709
2737
  this.states.forEach((state) => {
2710
- state.onLoad(type);
2738
+ state.onLoad && state.onLoad(type);
2711
2739
  });
2712
2740
  }
2713
2741
  onError(type, callback) {
@@ -2715,7 +2743,7 @@ var YCSDK = class _YCSDK {
2715
2743
  return;
2716
2744
  }
2717
2745
  this.states.forEach((state) => {
2718
- state.onError(type, callback);
2746
+ state.onError && state.onError(type, callback);
2719
2747
  });
2720
2748
  }
2721
2749
  onShow(type) {
@@ -2723,7 +2751,7 @@ var YCSDK = class _YCSDK {
2723
2751
  return;
2724
2752
  }
2725
2753
  this.states.forEach((state) => {
2726
- state.onShow(type);
2754
+ state.onShow && state.onShow(type);
2727
2755
  });
2728
2756
  }
2729
2757
  onClick(type) {
@@ -2731,7 +2759,7 @@ var YCSDK = class _YCSDK {
2731
2759
  return;
2732
2760
  }
2733
2761
  this.states.forEach((state) => {
2734
- state.onClick(type);
2762
+ state.onClick && state.onClick(type);
2735
2763
  });
2736
2764
  }
2737
2765
  onClose(type) {
@@ -2739,7 +2767,7 @@ var YCSDK = class _YCSDK {
2739
2767
  return;
2740
2768
  }
2741
2769
  this.states.forEach((state) => {
2742
- state.onClose(type);
2770
+ state.onClose && state.onClose(type);
2743
2771
  });
2744
2772
  }
2745
2773
  onReward() {
@@ -2747,7 +2775,7 @@ var YCSDK = class _YCSDK {
2747
2775
  return;
2748
2776
  }
2749
2777
  this.states.forEach((state) => {
2750
- state.onReward();
2778
+ state.onReward && state.onReward();
2751
2779
  });
2752
2780
  }
2753
2781
  };