Commit 5d80f2eb authored by Nguyễn Quang Sáng's avatar Nguyễn Quang Sáng

31/8/2023 commit

parent 15197a2b
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
"__id__": 37 "__id__": 37
}, },
{ {
"__id__": 43 "__id__": 42
} }
], ],
"_active": true, "_active": true,
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
} }
], ],
"_prefab": { "_prefab": {
"__id__": 42 "__id__": 47
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -194,7 +194,7 @@ ...@@ -194,7 +194,7 @@
"__id__": 37 "__id__": 37
}, },
{ {
"__id__": 37 "__id__": 42
} }
], ],
"_id": "" "_id": ""
...@@ -1573,17 +1573,6 @@ ...@@ -1573,17 +1573,6 @@
"fileId": "6dw+X1s/BNrJ7KUEmh6HWf", "fileId": "6dw+X1s/BNrJ7KUEmh6HWf",
"sync": false "sync": false
}, },
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "5dIbugedtGkbbo5t9KBiGM",
"sync": false
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Brick copy", "_name": "Brick copy",
...@@ -1595,17 +1584,17 @@ ...@@ -1595,17 +1584,17 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 44 "__id__": 43
}, },
{ {
"__id__": 45 "__id__": 44
}, },
{ {
"__id__": 46 "__id__": 45
} }
], ],
"_prefab": { "_prefab": {
"__id__": 47 "__id__": 46
}, },
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -1659,7 +1648,7 @@ ...@@ -1659,7 +1648,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 43 "__id__": 42
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -1691,7 +1680,7 @@ ...@@ -1691,7 +1680,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 43 "__id__": 42
}, },
"_enabled": true, "_enabled": true,
"_type": 0, "_type": 0,
...@@ -1716,7 +1705,7 @@ ...@@ -1716,7 +1705,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 43 "__id__": 42
}, },
"_enabled": true, "_enabled": true,
"tag": 0, "tag": 0,
...@@ -1740,7 +1729,7 @@ ...@@ -1740,7 +1729,7 @@
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
"__id__": 43 "__id__": 42
}, },
"asset": { "asset": {
"__uuid__": "3ef9ce8f-791c-430c-b1f8-ec3703b0ae18" "__uuid__": "3ef9ce8f-791c-430c-b1f8-ec3703b0ae18"
...@@ -1748,6 +1737,17 @@ ...@@ -1748,6 +1737,17 @@
"fileId": "123R1K5a1AdpWM7of9ETpf", "fileId": "123R1K5a1AdpWM7of9ETpf",
"sync": false "sync": false
}, },
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "5dIbugedtGkbbo5t9KBiGM",
"sync": false
},
{ {
"__type__": "cc.Widget", "__type__": "cc.Widget",
"_name": "", "_name": "",
......
...@@ -521,8 +521,8 @@ ...@@ -521,8 +521,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-80.258, -96.224,
28.22, 27.973,
0, 0,
0, 0,
0, 0,
...@@ -698,8 +698,8 @@ ...@@ -698,8 +698,8 @@
}, },
{ {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 29.3, "x": 32,
"y": 44.9 "y": 47.6
}, },
{ {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -708,8 +708,8 @@ ...@@ -708,8 +708,8 @@
}, },
{ {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": -27.2, "x": -29.4,
"y": 42.6 "y": 45.7
}, },
{ {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -732,7 +732,7 @@ ...@@ -732,7 +732,7 @@
"asset": { "asset": {
"__uuid__": "c3f6df06-c0ad-4e83-999f-c26983a694bc" "__uuid__": "c3f6df06-c0ad-4e83-999f-c26983a694bc"
}, },
"fileId": "87uLwgP5BPuYxg9RaYmras", "fileId": "621Sp7TO1L94et3Vz7Xbp5",
"sync": false "sync": false
}, },
{ {
...@@ -957,7 +957,7 @@ ...@@ -957,7 +957,7 @@
"__uuid__": "7c6aebf9-b0b0-4ee0-9a19-c3b7e1828a7f" "__uuid__": "7c6aebf9-b0b0-4ee0-9a19-c3b7e1828a7f"
}, },
"dog": { "dog": {
"__id__": 11 "__id__": 4
}, },
"_id": "" "_id": ""
}, },
...@@ -1194,7 +1194,7 @@ ...@@ -1194,7 +1194,7 @@
"__uuid__": "7c6aebf9-b0b0-4ee0-9a19-c3b7e1828a7f" "__uuid__": "7c6aebf9-b0b0-4ee0-9a19-c3b7e1828a7f"
}, },
"dog": { "dog": {
"__id__": 4 "__id__": 11
}, },
"_id": "" "_id": ""
}, },
...@@ -1966,7 +1966,7 @@ ...@@ -1966,7 +1966,7 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-78.574, -95.388,
-74.388, -74.388,
0, 0,
0, 0,
......
{
"ver": "2.3.7",
"uuid": "9773919c-689f-4327-bf0a-a2cad99806fe",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 190,
"height": 115,
"platformSettings": {},
"subMetas": {
"adsense": {
"ver": "1.0.6",
"uuid": "57b3fb4b-15db-4c36-92d9-32b4867b485f",
"importer": "sprite-frame",
"rawTextureUuid": "9773919c-689f-4327-bf0a-a2cad99806fe",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 190,
"height": 115,
"rawWidth": 190,
"rawHeight": 115,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.7",
"uuid": "c5ea459a-d4f8-44e4-9211-a95e4f22f7cc",
"importer": "texture",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 334,
"height": 133,
"platformSettings": {},
"subMetas": {
"button_double_collect": {
"ver": "1.0.6",
"uuid": "8529c74e-df6d-4d3f-83fd-2885260563af",
"importer": "sprite-frame",
"rawTextureUuid": "c5ea459a-d4f8-44e4-9211-a95e4f22f7cc",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 334,
"height": 133,
"rawWidth": 334,
"rawHeight": 133,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
This diff is collapsed.
...@@ -91,9 +91,6 @@ ...@@ -91,9 +91,6 @@
}, },
{ {
"__id__": 289 "__id__": 289
},
{
"__id__": 290
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -12805,24 +12802,5 @@ ...@@ -12805,24 +12802,5 @@
"_originalWidth": 0, "_originalWidth": 0,
"_originalHeight": 0, "_originalHeight": 0,
"_id": "23mlOldwlMM4VjKG7xyPZD" "_id": "23mlOldwlMM4VjKG7xyPZD"
},
{
"__type__": "221b6Awh/1PLZ7IzVb1f3El",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"soundOffSprite": {
"__uuid__": "d2abbacf-3959-4e3a-9fb7-5c1527a74dda"
},
"soundOnSprite": {
"__uuid__": "65a2b7d8-d4e8-4571-aedb-766db7693820"
},
"soundIntro": null,
"soundClick": null,
"animNode": null,
"_id": "1ck0GVZStOcohONtASUQ0f"
} }
] ]
\ No newline at end of file
This diff is collapsed.
...@@ -5,10 +5,9 @@ import PracticeLine from "../Objects/PracticeLine"; ...@@ -5,10 +5,9 @@ import PracticeLine from "../Objects/PracticeLine";
import Utils from "../Tools/Utils"; import Utils from "../Tools/Utils";
import { GlobalVariables } from "../Data/GlobalVariables"; import { GlobalVariables } from "../Data/GlobalVariables";
import StageController from "./StageController"; import StageController from "./StageController";
import SkinController from "./SkinsController";
import Hive from "../Objects/Hive";
import SoundController from "./SoundController"; import SoundController from "./SoundController";
import StartScene from "./StartScene"; import { showInterstitialAd } from "../../adsense-h5g-api/h5_games_ads";
import { InterstitialType } from "../../adsense-h5g-api/interstitial_type";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -27,6 +26,8 @@ export default class GamePlay extends cc.Component { ...@@ -27,6 +26,8 @@ export default class GamePlay extends cc.Component {
@property(cc.Node) coinLabel: cc.Node = null; @property(cc.Node) coinLabel: cc.Node = null;
@property(cc.Node) coinEarned: cc.Node = null; @property(cc.Node) coinEarned: cc.Node = null;
@property(cc.Node) levelComp: cc.Node = null; @property(cc.Node) levelComp: cc.Node = null;
@property(cc.Node) adsBgr: cc.Node = null;
@property(cc.Node) notiLabel: cc.Node = null;
@property(cc.Node) rewardSprite: cc.Node = null; @property(cc.Node) rewardSprite: cc.Node = null;
@property(cc.Node) shadow: cc.Node = null; @property(cc.Node) shadow: cc.Node = null;
@property(cc.AudioClip) soundClick: cc.AudioClip = null; @property(cc.AudioClip) soundClick: cc.AudioClip = null;
...@@ -75,6 +76,9 @@ export default class GamePlay extends cc.Component { ...@@ -75,6 +76,9 @@ export default class GamePlay extends cc.Component {
cc.director.getPhysicsManager().enabled = true; cc.director.getPhysicsManager().enabled = true;
cc.director.getCollisionManager().enabled = true; cc.director.getCollisionManager().enabled = true;
window.addEventListener("beforeunload", this.handleGameReload);
window.addEventListener("unload", this.handleGameReload);
// cc.director.getPhysicsManager().debugDrawFlags = 1; // cc.director.getPhysicsManager().debugDrawFlags = 1;
this.highestLevel = LocalStorage.getHighestLevel(); this.highestLevel = LocalStorage.getHighestLevel();
this.currentLevel = LocalStorage.getCurrentLevel(); this.currentLevel = LocalStorage.getCurrentLevel();
...@@ -99,6 +103,57 @@ export default class GamePlay extends cc.Component { ...@@ -99,6 +103,57 @@ export default class GamePlay extends cc.Component {
this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchUp, this); this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchUp, this);
} }
handleGameReload() {
LocalStorage.setGameStarted(false);
}
onPlayerClickAds() {
showInterstitialAd(InterstitialType.START, "doubleCoin");
}
onDestroy() {
window.removeEventListener("beforeunload", this.handleGameReload);
window.removeEventListener("unload", this.handleGameReload);
}
onShowNotiAds(status: string) {
if (status == "ok") {
this.notiLabel.getComponent(cc.Label).string =
"Successfully doubled coins!";
LocalStorage.setAllCoin(LocalStorage.getAllCoin() + this.randomCoin * 2);
this.adsBgr.active = true;
this.notiLabel.active = true;
this.scheduleOnce(() => {
this.adsBgr.active = false;
this.notiLabel.active = false;
}, 2);
this.currentCoin = LocalStorage.getAllCoin();
this.coinLabel.getComponent(cc.Label).string = `x${this.currentCoin}`;
}
if (status == "cancel") {
this.showFailedNotiAds("Double coin failed");
}
if (status == "notReady") {
this.showFailedNotiAds("Advertisement is preparing");
}
if (status == "frequencyCapped") {
this.showFailedNotiAds("Ads frequency limit!");
}
}
showFailedNotiAds(status: string) {
this.notiLabel.getComponent(cc.Label).string = status;
this.adsBgr.active = true;
this.notiLabel.active = true;
this.scheduleOnce(() => {
this.adsBgr.active = false;
this.notiLabel.active = false;
}, 2);
}
updateAllStarLabel() { updateAllStarLabel() {
let sum = 0; let sum = 0;
for (const item of LocalStorage.getAllStars()) { for (const item of LocalStorage.getAllStars()) {
...@@ -212,7 +267,8 @@ export default class GamePlay extends cc.Component { ...@@ -212,7 +267,8 @@ export default class GamePlay extends cc.Component {
if ( if (
cc.Vec2.distance(touchPos, this.lastTouchPos) >= this.lineMinSegLength && cc.Vec2.distance(touchPos, this.lastTouchPos) >= this.lineMinSegLength &&
cc.Vec2.distance(touchPos, this.lastDrawnPos) <= this.lineMinSegLength * 5 cc.Vec2.distance(touchPos, this.lastDrawnPos) <=
this.lineMinSegLength * 10
) { ) {
if (!this.drew) { if (!this.drew) {
let touchNormal = touchPos.sub(this.lastTouchPos).normalize(); let touchNormal = touchPos.sub(this.lastTouchPos).normalize();
...@@ -220,19 +276,19 @@ export default class GamePlay extends cc.Component { ...@@ -220,19 +276,19 @@ export default class GamePlay extends cc.Component {
let rightEdgeNormal = Utils.RotateVec2Clockwise(touchNormal); let rightEdgeNormal = Utils.RotateVec2Clockwise(touchNormal);
let leftEdgeLast = this.lastTouchPos.add( let leftEdgeLast = this.lastTouchPos.add(
cc.v2(leftEdgeNormal).multiplyScalar(this.lineWidth / 2) cc.v2(leftEdgeNormal).multiplyScalar(this.lineWidth / 1.5)
); );
let rightEdgeLast = this.lastTouchPos.add( let rightEdgeLast = this.lastTouchPos.add(
cc.v2(rightEdgeNormal).multiplyScalar(this.lineWidth / 2) cc.v2(rightEdgeNormal).multiplyScalar(this.lineWidth / 1.5)
); );
let leftEdgeCurrent = touchPos.add( let leftEdgeCurrent = touchPos.add(
cc.v2(leftEdgeNormal).multiplyScalar(this.lineWidth / 2) cc.v2(leftEdgeNormal).multiplyScalar(this.lineWidth / 1.5)
); );
let rightEdgeCurrent = touchPos.add( let rightEdgeCurrent = touchPos.add(
cc.v2(rightEdgeNormal).multiplyScalar(this.lineWidth / 2) cc.v2(rightEdgeNormal).multiplyScalar(this.lineWidth / 1.5)
); );
let newPolyCol = this.draw.addComponent(cc.PhysicsPolygonCollider); let newPolyCol = this.draw.addComponent(cc.PhysicsPolygonCollider);
......
import { GlobalVariables } from "../Data/GlobalVariables"; import { showInterstitialAd } from "../../adsense-h5g-api/h5_games_ads";
import { InterstitialType } from "../../adsense-h5g-api/interstitial_type";
import LocalStorage from "../Data/LocalStorage"; import LocalStorage from "../Data/LocalStorage";
import StartScene from "./StartScene";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -10,23 +10,70 @@ export default class SkinController extends cc.Component { ...@@ -10,23 +10,70 @@ export default class SkinController extends cc.Component {
@property(cc.Node) playerSkins: cc.Node = null; @property(cc.Node) playerSkins: cc.Node = null;
@property(cc.Node) enemySkins: cc.Node = null; @property(cc.Node) enemySkins: cc.Node = null;
@property(cc.AudioClip) soundClick: cc.AudioClip = null; @property(cc.AudioClip) soundClick: cc.AudioClip = null;
@property(cc.Node) adsBgr: cc.Node = null;
@property(cc.Node) notiLabel: cc.Node = null;
static instance: SkinController;
allCoin: number; allCoin: number;
allSkins: Array<{ skin: string; available: boolean }>; allSkins: Array<{ skin: string; available: boolean }>;
protected onLoad(): void { protected onLoad(): void {
SkinController.instance = this;
this.allCoin = LocalStorage.getAllCoin(); this.allCoin = LocalStorage.getAllCoin();
this.allSkins = LocalStorage.getAllSkins(); this.allSkins = LocalStorage.getAllSkins();
this.updateStatus(); this.updateStatus();
this.loadCurrentSkin(); this.loadCurrentSkin();
} }
onPlayerClickAds() {
showInterstitialAd(InterstitialType.START, "earn15Coin");
}
onClickButtonBack() { onClickButtonBack() {
cc.director.loadScene("start"); cc.director.loadScene("start");
cc.audioEngine.playEffect(this.soundClick, false); cc.audioEngine.playEffect(this.soundClick, false);
cc.audioEngine.stopAllEffects(); cc.audioEngine.stopAllEffects();
} }
onShowNotiAds(status: string) {
if (status == "ok") {
this.notiLabel.getComponent(cc.Label).string =
"Received coins successfully!";
LocalStorage.setAllCoin(LocalStorage.getAllCoin() + 15);
this.adsBgr.active = true;
this.notiLabel.active = true;
this.scheduleOnce(() => {
this.adsBgr.active = false;
this.notiLabel.active = false;
}, 2);
this.allCoin = LocalStorage.getAllCoin();
this.coinLabel.getComponent(cc.Label).string = `x${this.allCoin}`;
}
if (status == "cancel") {
this.showFailedNotiAds("Receiving coins failed!");
}
if (status == "notReady") {
this.showFailedNotiAds("Advertisement is preparing..!");
}
if (status == "frequencyCapped") {
this.showFailedNotiAds("Ads frequency limit!");
}
}
showFailedNotiAds(status: string) {
this.notiLabel.getComponent(cc.Label).string = status;
this.adsBgr.active = true;
this.notiLabel.active = true;
this.scheduleOnce(() => {
this.adsBgr.active = false;
this.notiLabel.active = false;
}, 2);
}
loadCurrentSkin() { loadCurrentSkin() {
const skinPlayer = LocalStorage.getCurrentSkinPlayer(); const skinPlayer = LocalStorage.getCurrentSkinPlayer();
const enemyPlayer = LocalStorage.getCurrentSkinEnemy(); const enemyPlayer = LocalStorage.getCurrentSkinEnemy();
......
...@@ -30,6 +30,8 @@ export default class StartScene extends cc.Component { ...@@ -30,6 +30,8 @@ export default class StartScene extends cc.Component {
this.updateButtonSprite(); this.updateButtonSprite();
window.addEventListener("beforeunload", this.handleGameReload); window.addEventListener("beforeunload", this.handleGameReload);
window.addEventListener("unload", this.handleGameReload);
this.isStarted = LocalStorage.getGameStarted(); this.isStarted = LocalStorage.getGameStarted();
if (this.isStarted) this.node.getChildByName("Intro").active = false; if (this.isStarted) this.node.getChildByName("Intro").active = false;
...@@ -53,6 +55,7 @@ export default class StartScene extends cc.Component { ...@@ -53,6 +55,7 @@ export default class StartScene extends cc.Component {
onDestroy() { onDestroy() {
window.removeEventListener("beforeunload", this.handleGameReload); window.removeEventListener("beforeunload", this.handleGameReload);
window.removeEventListener("unload", this.handleGameReload);
} }
onClickOpenGame() { onClickOpenGame() {
......
import GamePlay from "../Controllers/GamePlay"; import GamePlay from "../Controllers/GamePlay";
import SoundController from "../Controllers/SoundController"; import SoundController from "../Controllers/SoundController";
import { GlobalVariables } from "../Data/GlobalVariables";
import LocalStorage from "../Data/LocalStorage"; import LocalStorage from "../Data/LocalStorage";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
......
{
"ver": "1.1.3",
"uuid": "4e14393c-a6c4-4bfe-946c-abe1c5d19a8d",
"importer": "folder",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
/**
* Ad Events for Interstitial Callback
*/
export enum PrerollAdEvent {
AD_BREAK_DONE = 'H5GA_EVENT_PREROLL_AD_BREAK_DONE',
}
/**
* Ad Events for Interstitial Callback
*/
export enum InterstitialAdEvent {
BEFORE_AD = 'H5GA_EVENT_INTERSTITIAL_BEFORE_AD',
AFTER_AD = 'H5GA_EVENT_INTERSTITIAL_AFTER_AD',
AD_BREAK_DONE = 'H5GA_EVENT_INTERSTITIAL_AD_BREAK_DONE',
}
/**
* Ad Events for Rewarded Video Callback
*/
export enum RewardedVideoAdEvent {
BEFORE_AD = 'H5GA_EVENT_REWARDED_VIDEO_BEFORE_AD',
AFTER_AD = 'H5GA_EVENT_REWARDED_VIDEO_AFTER_AD',
AD_BREAK_DONE = 'H5GA_EVENT_REWARDED_VIDEO_AD_BREAK_DONE',
BEFORE_REWARD = 'H5GA_EVENT_REWARDED_VIDEO_BEFORE_REWARD',
AD_DISMISSED = 'H5GA_EVENT_REWARDED_VIDEO_AD_DISMISSED',
AD_VIEWED = 'H5GA_EVENT_REWARDED_VIDEO_AD_VIEWED',
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "6cdefff5-eef4-4d14-bf7f-3797ba31418b",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
const { game } = cc;
import { InterstitialCallback } from "./interstitial_callback";
import { RewardedCallback } from "./rewarded_callback";
import { PrerollCallback } from "./preroll_callback";
import {
InterstitialAdEvent,
PrerollAdEvent,
RewardedVideoAdEvent,
} from "./ad_event";
import { InterstitialType } from "./interstitial_type";
import SkinController from "../Scripts/Controllers/SkinsController";
import GamePlay from "../Scripts/Controllers/GamePlay";
// This is needed since there're no definition for AdSense object here.
// tslint:disable-next-line:no-any
const ADS_BY_GOOGLE = (window as any).adsbygoogle;
type AdBreakCallback =
| InterstitialCallback
| RewardedCallback
| PrerollCallback;
const adBreak = (o: AdBreakCallback) => {
ADS_BY_GOOGLE.push(o);
};
//let showRewardedAdFn : (() => void) | null;
/**
* API to show Preroll Ad when available.
* If there are no ad available this function will request an ad.
*/
// export function showPrerollAd(){
// try {
// const game_instance = game;
// adBreak({
// type: 'preroll',
// adBreakDone: (placementInfo: any) => {
// game_instance.emit(PrerollAdEvent.AD_BREAK_DONE);
// },
// });
// console.log(ADS_BY_GOOGLE)
// } catch(e) {
// console.log(e)
// }
// }
/**
* API to show Interstitial Ad when available.
* If there are no ad available this function will request an ad.
*/
export function showInterstitialAd(type: InterstitialType, name: string) {
try {
console.log("try to show InterstitialAd");
const gameInstance = game;
adBreak({
type,
name,
beforeAd: () => {
console.log("beforeAd");
gameInstance.emit(InterstitialAdEvent.BEFORE_AD);
cc.audioEngine.pauseMusic();
cc.audioEngine.pauseAllEffects();
},
afterAd: () => {
console.log("afterAd");
gameInstance.emit(InterstitialAdEvent.AFTER_AD);
},
adBreakDone: (placementInfo: any) => {
console.log(placementInfo);
gameInstance.emit(InterstitialAdEvent.AD_BREAK_DONE);
console.log("adBreakDone");
cc.audioEngine.resumeMusic();
cc.audioEngine.resumeAllEffects();
if (
placementInfo.breakName == "earn15Coin" &&
placementInfo.breakStatus == "viewed"
) {
SkinController.instance.onShowNotiAds("ok");
}
if (
(placementInfo.breakName == "earn15Coin" &&
placementInfo.breakStatus == "ignored") ||
placementInfo.breakStatus == "other"
) {
SkinController.instance.onShowNotiAds("cancel");
}
if (
placementInfo.breakName == "earn15Coin" &&
placementInfo.breakStatus == "notReady"
) {
SkinController.instance.onShowNotiAds("notReady");
}
if (
placementInfo.breakName == "earn15Coin" &&
placementInfo.breakStatus == "frequencyCapped"
) {
SkinController.instance.onShowNotiAds("frequencyLimit");
}
if (
placementInfo.breakName == "doubleCoin" &&
placementInfo.breakStatus == "viewed"
) {
GamePlay.instance.onShowNotiAds("ok");
}
if (
(placementInfo.breakName == "doubleCoin" &&
placementInfo.breakStatus == "ignored") ||
placementInfo.breakStatus == "other"
) {
GamePlay.instance.onShowNotiAds("cancel");
}
if (
placementInfo.breakName == "doubleCoin" &&
placementInfo.breakStatus == "notReady"
) {
SkinController.instance.onShowNotiAds("notReady");
}
if (
placementInfo.breakName == "doubleCoin" &&
placementInfo.breakStatus == "frequencyCapped"
) {
GamePlay.instance.onShowNotiAds("frequencyLimit");
}
},
});
} catch (e) {
console.log(e);
}
}
/**
* API to request Rewarded Ad.
* To show the Rewarded Ad you could call showRewardedAd after
* beforeReward callback.
*/
// export function requestRewardedAd(name: string) {
// try {
// console.log("try to show InterstitialAd");
// const gameInstance = game;
// adBreak({
// type: 'reward',
// name,
// beforeAd: () => {
// console.log("beforeAd");
// gameInstance.emit(RewardedVideoAdEvent.BEFORE_AD);
// },
// afterAd: () => {
// console.log("afterAd");
// gameInstance.emit(RewardedVideoAdEvent.AFTER_AD);
// },
// adBreakDone: (placementInfo: unknown) => {
// console.log("adBreakDone");
// console.log(placementInfo)
// gameInstance.emit(RewardedVideoAdEvent.AD_BREAK_DONE);
// },
// beforeReward: (showAdFn: () => void) => {
// showRewardedAdFn = showAdFn;
// console.log("beforeReward");
// gameInstance.emit(RewardedVideoAdEvent.BEFORE_REWARD);
// },
// adDismissed: () => {
// console.log("adDismissed");
// gameInstance.emit(RewardedVideoAdEvent.AD_DISMISSED);
// },
// adViewed: () => {
// console.log("adViewed");
// gameInstance.emit(RewardedVideoAdEvent.AD_VIEWED);
// },
// });
// } catch (e) {
// console.log(e);
// }
// }
/**
* API to show Rewarded Ad when available.
*/
// export function showRewardedAd() {
// if (!showRewardedAdFn) {
// console.log('No Rewarded Ad available');
// return;
// }
// showRewardedAdFn();
// showRewardedAdFn = null;
// }
{
"ver": "1.1.0",
"uuid": "b6763fe6-ff2c-4e97-a7f9-4b833b3bd756",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
import {InterstitialType} from './interstitial_type';
/**
* Interface for Interstitial AdBreak API Callback
*/
export interface InterstitialCallback {
type: InterstitialType;
name: string;
beforeAd: () => void;
afterAd: () => void;
adBreakDone: (placementInfo: unknown) => void;
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "34ce0e5e-8ebf-441d-ac42-2da72d04ed54",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
/**
* Interstitial Type for AdBreak
*/
export enum InterstitialType {
START = 'start',
PAUSE = 'pause',
NEXT = 'next',
BROWSE = 'browse',
REWARD = 'reward',
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "41c2c096-5666-4975-9e79-905a489bf100",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
/**
* Interface for Preroll AdBreak API Callback
*/
export interface PrerollCallback {
type: string;
adBreakDone: (placementInfo: unknown) => void;
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "5c029479-8a2c-42bb-a75f-7144f2b1ff01",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
/**
* Interface for Rewarded AdBreak API Callback
*/
export interface RewardedCallback {
type: string;
name: string;
beforeAd: () => void;
afterAd: () => void;
beforeReward: (showAdFn: () => void) => void;
adDismissed: () => void;
adViewed: () => void;
adBreakDone: (placementInfo: unknown) => void;
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "482f4afa-70f0-42f5-96a9-7ababa9481aa",
"importer": "typescript",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -124,7 +124,7 @@ h1 { ...@@ -124,7 +124,7 @@ h1 {
} }
#GameDiv { #GameDiv {
width: calc(100vh * 45 / 80); width: 100vh;
height: 100vh; height: 100vh;
margin: 0 auto; margin: 0 auto;
background: black; background: black;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment