修改广告

This commit is contained in:
huanghaipeng 2025-10-17 19:06:57 +08:00
parent 392ecf7030
commit d178f497db
5 changed files with 112 additions and 111 deletions

View File

@ -17581,7 +17581,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "ab9b1a6d-9c1b-4d87-ba50-43dbe414eb7f"
"__uuid__": "b51c6577-3f31-4777-bf4a-6bfad58f0612"
},
"_type": 0,
"_sizeMode": 1,

View File

@ -1983,68 +1983,38 @@ export default class MapConroler extends cc.Component {
ad_placement_name: "2000", //内部广告位名称
current_page: "GameScene" //所在页面
}
// let coin = 500;
if (type == "time") {
if (cc.fx.GameTool.canObtainByShare("reviveTime")) {
cc.fx.GameTool.shareToWX(this.runRewive(data))
if (typeof wx !== 'undefined' && wx !== null) {
if (type == "time") {
if (cc.fx.GameTool.canObtainByShare("reviveTime")) {
cc.fx.GameTool.shareToWX(this.runRewive(data))
} else {
cc.fx.GameTool.onShowVideo(this.runRewive(data), overData)
}
}
else if (type == "boom") {
if (cc.fx.GameTool.canObtainByShare("removeBomb")) {
cc.fx.GameTool.shareToWX(this.runRewive(data))
} else {
cc.fx.GameTool.onShowVideo(this.runRewive(data), overData)
}
}
else if (type == "lock") {
if (cc.fx.GameTool.canObtainByShare("openDoor")) {
cc.fx.GameTool.shareToWX(this.runRewive(data))
} else {
cc.fx.GameTool.onShowVideo(this.runRewive(data), overData)
}
}
else if (type == "revolving") {
if (cc.fx.GameTool.canObtainByShare("removeJam")) {
cc.fx.GameTool.shareToWX(this.runRewive(data))
} else {
cc.fx.GameTool.onShowVideo(this.runRewive(data), overData)
}
} else {
cc.fx.GameTool.onShowVideo(this.runRewive(data), overData)
// this.runRewive(data);
}
}
else if (type == "boom") {
if (cc.fx.GameTool.canObtainByShare("removeBomb")) {
cc.fx.GameTool.shareToWX(this.runRewive(data))
} else {
cc.fx.GameTool.onShowVideo(this.runRewive(data), overData)
}
}
else if (type == "lock") {
if (cc.fx.GameTool.canObtainByShare("openDoor")) {
cc.fx.GameTool.shareToWX(this.runRewive(data))
} else {
cc.fx.GameTool.onShowVideo(this.runRewive(data), overData)
}
}
else if (type == "revolving") {
if (cc.fx.GameTool.canObtainByShare("removeJam")) {
cc.fx.GameTool.shareToWX(this.runRewive(data))
} else {
cc.fx.GameTool.onShowVideo(this.runRewive(data), overData)
}
} else {
// this.runRewive(data);
}
// if (type == "time") {
// if (cc.fx.GameConfig.GM_INFO.review == 1) coin = 1000;
// else if (cc.fx.GameConfig.GM_INFO.review == 2) coin = 1500;
// }
// else if (type == "boom") {
// if (cc.fx.GameConfig.GM_INFO.reviewBoom == 1) coin = 1000;
// else if (cc.fx.GameConfig.GM_INFO.reviewBoom == 2) coin = 1500;
// }
// else if (type == "lock") {
// if (cc.fx.GameConfig.GM_INFO.reviewDoor == 1) coin = 1000;
// else if (cc.fx.GameConfig.GM_INFO.reviewDoor == 2) coin = 1500;
// }
// else if (type == "revolving") {
// if (cc.fx.GameConfig.GM_INFO.reviewDoor == 1) coin = 1000;
// else if (cc.fx.GameConfig.GM_INFO.reviewDoor == 2) coin = 1500;
// }
// data.coin = -coin;
// // console.log("自身金币:",cc.fx.GameConfig.GM_INFO.coin,"消耗金币:",coin);
// if (cc.fx.GameConfig.GM_INFO.coin < Math.abs(coin)) {
// MiniGameSdk.API.showToast("金币不足,无法加时间");
// setTimeout(() => {
// // this.openShop();
// console.log("调用金币, 需删除");
// this.reviewState = false;
// }, 500);
// return;
// }
// else {
// this.runRewive(data);
// }
}
//执行复活函数
@ -2056,6 +2026,7 @@ export default class MapConroler extends cc.Component {
id: "2000",
num: 1
}
cc.fx.GameTool.shushu_Track("resource_get", dataTemp);
// const dataTemp2 = {
// change_reason: "游戏内复活消耗金币",
@ -2074,22 +2045,33 @@ export default class MapConroler extends cc.Component {
//// this.updateCoin();
// NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
if (data.type == "time") {
if (cc.fx.GameConfig.GM_INFO.review < 2)
if (cc.fx.GameConfig.GM_INFO.review < 2) {
cc.fx.GameConfig.GM_INFO.review += 1;
cc.fx.GameTool.addShareCount("reviveTime")
}
}
else if (data.type == "boom") {
if (cc.fx.GameConfig.GM_INFO.reviewBoom < 2)
if (cc.fx.GameConfig.GM_INFO.reviewBoom < 2) {
cc.fx.GameConfig.GM_INFO.reviewBoom += 1;
cc.fx.GameTool.addShareCount("removeBomb")
}
}
else if (data.type == "lock") {
this.changeState(true);
if (cc.fx.GameConfig.GM_INFO.reviewDoor < 2)
if (cc.fx.GameConfig.GM_INFO.reviewDoor < 2) {
cc.fx.GameConfig.GM_INFO.reviewDoor += 1;
cc.fx.GameTool.addShareCount("openDoor")
}
}
else if (data.type == "revolving") {
this.changeRevolvingWall();
if (cc.fx.GameConfig.GM_INFO.reviewDoor < 2)
if (cc.fx.GameConfig.GM_INFO.reviewDoor < 2) {
cc.fx.GameConfig.GM_INFO.reviewDoor += 1;
cc.fx.GameTool.addShareCount("removeJam")
}
}
if (this.node.parent.getChildByName("Ice").active) {

View File

@ -281,6 +281,7 @@ export namespace MiniGameSdk {
* @returns
*/
show(onResult: (res: EAdVideoResult, count: number) => void, target?: any, maxVideoCount: number = 3, video_data: any = null): void {
console.log("调用广告显示");
let callback = (state: EAdVideoResult, count: number) => {
// 确保广告实例被清理
if (this._adVideo) {

View File

@ -98,6 +98,8 @@ export default class NewClass extends cc.Component {
cc.fx.GameTool.setUserHealth(0, (data) => {
cc.fx.GameTool.getHealth(null);
})
cc.fx.GameTool.addShareCount("health")
}
if (cc.fx.GameTool.canObtainByShare("health")) {

View File

@ -700,7 +700,9 @@ var GameTool = {
compensate: false
}
cc.fx.GameTool.shushu_Track("resource_get", data);
if (propid == 2001) cc.fx.GameTool.addShareCount("freeze")
else if (propid == 2002) cc.fx.GameTool.addShareCount("hammer")
else if (propid == 2003) cc.fx.GameTool.addShareCount("magicWand")
callback();
}
let video_data = {
@ -1472,62 +1474,70 @@ var GameTool = {
},
onShowVideo(callback: Function, videoData: any) {
let requestData = {
ad_type: "激励视频", //广告类型
ad_placement_name: videoData.ad_placement_name, //内部广告位名称 //2000复活 道具 2001 2002 2003
ad_placement_id: "adunit-32a23bc2b2f4ee0a", //内部广告位ID
current_page: videoData.current_page, //所在页面
}
cc.fx.GameTool.shushu_Track("ad_request", requestData);
cc.fx.GameConfig.GM_INFO.videoTime = Math.floor(Date.now() / 1000);
MiniGameSdk.AdvertManager.instance.showVideo('adunit-32a23bc2b2f4ee0a', videoData, (res: MiniGameSdk.EAdVideoResult, count: number) => {
console.log('用户看的视频广告个数是:', count);
// 根据用户观看广告的结果执行不同的逻辑s
console.log('用户观看视频广告结果:', res);
let duration = Math.floor(Date.now() / 1000) - cc.fx.GameConfig.GM_INFO.videoTime;
if (duration <= 0) duration = 0;
let data = {
if (typeof wx !== 'undefined' && wx !== null) {
let requestData = {
ad_type: "激励视频", //广告类型
ad_placement_name: videoData.ad_placement_name, //内部广告位名称 //2000复活 道具 2001 2002 2003
ad_placement_id: "adunit-32a23bc2b2f4ee0a", //内部广告位ID
current_page: videoData.current_page, //所在页面
ad_duration: duration, //广告展示时长
ad_play_duration: 30, //广告播放时长
is_complete_play: false //是否完整播放
current_page: videoData.current_page, //所在页面
}
switch (res) {
case MiniGameSdk.EAdVideoResult.ACCEPT:
data.is_complete_play = true;
// MiniGameSdk.API.showToast('用户看完广告,可以奖励');
cc.fx.GameTool.shushu_Track("ad_close", data);
callback();
break;
case MiniGameSdk.EAdVideoResult.REJECT:
data.is_complete_play = false;
MiniGameSdk.API.showToast('广告中断,未获得奖励');
cc.fx.GameTool.shushu_Track("ad_close", data);
break;
case MiniGameSdk.EAdVideoResult.ERROR:
MiniGameSdk.API.showToast('广告加载失败,请稍后再试');
cc.fx.GameTool.shushu_Track("ad_close", data);
break;
default:
// 其他情况,不作处理
break;
}
});
cc.fx.GameTool.shushu_Track("ad_request", requestData);
cc.fx.GameConfig.GM_INFO.videoTime = Math.floor(Date.now() / 1000);
MiniGameSdk.AdvertManager.instance.showVideo('adunit-32a23bc2b2f4ee0a', videoData, (res: MiniGameSdk.EAdVideoResult, count: number) => {
console.log('用户看的视频广告个数是:', count);
// 根据用户观看广告的结果执行不同的逻辑s
console.log('用户观看视频广告结果:', res);
let duration = Math.floor(Date.now() / 1000) - cc.fx.GameConfig.GM_INFO.videoTime;
if (duration <= 0) duration = 0;
let data = {
ad_type: "激励视频", //广告类型
ad_placement_name: videoData.ad_placement_name, //内部广告位名称 //2000复活 道具 2001 2002 2003
ad_placement_id: "adunit-32a23bc2b2f4ee0a", //内部广告位ID
current_page: videoData.current_page, //所在页面
ad_duration: duration, //广告展示时长
ad_play_duration: 30, //广告播放时长
is_complete_play: false //是否完整播放
}
switch (res) {
case MiniGameSdk.EAdVideoResult.ACCEPT:
data.is_complete_play = true;
MiniGameSdk.API.showToast('用户看完广告,可以奖励');
cc.fx.GameTool.shushu_Track("ad_close", data);
callback();
break;
case MiniGameSdk.EAdVideoResult.REJECT:
data.is_complete_play = false;
MiniGameSdk.API.showToast('广告中断,未获得奖励');
cc.fx.GameTool.shushu_Track("ad_close", data);
break;
case MiniGameSdk.EAdVideoResult.ERROR:
MiniGameSdk.API.showToast('广告加载失败,请稍后再试');
cc.fx.GameTool.shushu_Track("ad_close", data);
break;
default:
// 其他情况,不作处理
break;
}
});
}
},
//检查是否可以使用分享方式获取道具
canObtainByShare(propType: string): boolean {
const today = new Date().toDateString();
const lastShareDate = cc.fx.StorageMessage.getStorage(`dailyShareCounts${propType}`) || 0;
const lastResetDate = cc.fx.StorageMessage.getStorage(`shareCountResetDate_${propType}`) || "";
// 如果是新的一天,重置分享次数
if (today !== lastShareDate) {
if (today !== lastResetDate) {
cc.fx.GameConfig.GM_INFO.dailyShareCounts[propType] = 0;
cc.fx.StorageMessage.setStorage(`dailyShareCounts${propType}`, today);
cc.fx.StorageMessage.setStorage(`shareCountResetDate_${propType}`, today);
} else {
// 从本地存储获取当前的分享次数
const storedShareCount = cc.fx.StorageMessage.getStorage(`dailyShareCounts${propType}`);
if (storedShareCount !== null && storedShareCount !== undefined) {
cc.fx.GameConfig.GM_INFO.dailyShareCounts[propType] = storedShareCount;
}
}
const shareLimit = (cc.fx.GameConfig.DAILY_SHARE_LIMITS && cc.fx.GameConfig.DAILY_SHARE_LIMITS[propType]) || 0;
@ -1538,12 +1548,18 @@ var GameTool = {
// 增加分享次数
addShareCount(propType: string): void {
const today = new Date().toDateString();
const lastShareDate = cc.fx.StorageMessage.getStorage(`dailyShareCounts${propType}`) || 0;
const lastResetDate = cc.fx.StorageMessage.getStorage(`shareCountResetDate_${propType}`) || "";
// 如果是新的一天,重置分享次数
if (today !== lastShareDate) {
if (today !== lastResetDate) {
cc.fx.GameConfig.GM_INFO.dailyShareCounts[propType] = 0;
cc.fx.StorageMessage.setStorage(`dailyShareCounts${propType}`, today);
cc.fx.StorageMessage.setStorage(`shareCountResetDate_${propType}`, today);
} else {
// 从本地存储获取当前的分享次数
const storedShareCount = cc.fx.StorageMessage.getStorage(`dailyShareCounts${propType}`);
if (storedShareCount !== null && storedShareCount !== undefined) {
cc.fx.GameConfig.GM_INFO.dailyShareCounts[propType] = storedShareCount;
}
}
cc.fx.GameConfig.GM_INFO.dailyShareCounts[propType]++;