feature/ads-smart-display
tiendat3699 2024-06-18 16:59:16 +07:00
parent b48f888558
commit 5702a3f49f
9 changed files with 207 additions and 25 deletions

View File

@ -11488,7 +11488,7 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 470.126953125,
"width": 441.2998962402344,
"height": 75.6
},
"_anchorPoint": {
@ -11846,7 +11846,7 @@
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": -227.5500030517578,
"x": -223.3154296875,
"y": -58.5,
"z": 0
},
@ -11885,7 +11885,7 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 33.369140625,
"width": 24.899993896484375,
"height": 75.6
},
"_anchorPoint": {
@ -11972,7 +11972,7 @@
"__prefab": null,
"_alignFlags": 10,
"_target": null,
"_left": 50,
"_left": 54.23457336425781,
"_right": 0,
"_top": 0,
"_bottom": 0,
@ -12470,7 +12470,7 @@
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": -227.5500030517578,
"x": -223.3154296875,
"y": -58.5,
"z": 0
},
@ -12509,7 +12509,7 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 33.369140625,
"width": 24.899993896484375,
"height": 75.6
},
"_anchorPoint": {
@ -12596,7 +12596,7 @@
"__prefab": null,
"_alignFlags": 10,
"_target": null,
"_left": 50,
"_left": 54.23457336425781,
"_right": 0,
"_top": 0,
"_bottom": 0,
@ -13245,7 +13245,7 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 273.544921875,
"width": 289.0199279785156,
"height": 75.6
},
"_anchorPoint": {
@ -13489,7 +13489,7 @@
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 44.4921875,
"width": 45.59999084472656,
"height": 100.8
},
"_anchorPoint": {
@ -35373,7 +35373,9 @@
},
"_enabled": true,
"__prefab": null,
"replayTimes": 0,
"_colliderDebug": false,
"_callAPI": false,
"_floatingScoreFactory": {
"__id__": 6
},

View File

@ -33,8 +33,12 @@ const { ccclass, property } = _decorator;
@ccclass('GameManager')
export class GameManager extends Singleton<GameManager>() {
@property(CCInteger)
private replayTimes: number = 1;
@property({ visible: true })
private _colliderDebug: boolean = false;
@property({ visible: true })
private _callAPI: boolean = true;
@property({ type: FloatingTextFactory, visible: true })
private _floatingScoreFactory: FloatingTextFactory;
@property({ type: Node, visible: true })
@ -44,7 +48,7 @@ export class GameManager extends Singleton<GameManager>() {
@property({ visible: true })
private _ballSpawnPosition: Vec3 = new Vec3();
@property({ type: CCInteger, visible: true })
private readonly _timePlay = 120;
private _timePlay = 120;
@property({ type: SpriteFrame, visible: true })
private _clockIcon: SpriteFrame;
@ -63,7 +67,6 @@ export class GameManager extends Singleton<GameManager>() {
private _activeBoosters: Map<BoosterType, BoosterBase> = new Map();
private _score = 0;
private isReplayed = false;
private _isMultiBall = false;
private _warningTime = false;
private _currentBallInGame = 0;
@ -96,6 +99,10 @@ export class GameManager extends Singleton<GameManager>() {
protected async start(): Promise<void> {
await P4PSDK.init(this.onBoughtTicket, this);
if (P4PSDK.getGameTime()) {
this._timePlay = P4PSDK.getGameTime();
}
P4PSDK.setCallAPI(this._callAPI);
await P4PSDK.authenticate();
this.changeGameState(GameState.Init);
}
@ -125,6 +132,7 @@ export class GameManager extends Singleton<GameManager>() {
EventManger.instance.emit(GameEvent.TicketUpdate, P4PSDK.getUserTicket());
break;
case GameState.GameOver:
this.replayTimes--;
break;
case GameState.End:
break;
@ -282,13 +290,7 @@ export class GameManager extends Singleton<GameManager>() {
this.cleanBooster();
AudioManager.playBGM(this._gameOverMusic);
StickerManager.instance.showLabel('TIME UP!!!', { color: new Color('#ed3a18'), outLineColor: Color.WHITE });
if (this.isReplayed) {
this.changeGameState(GameState.End);
return;
}
this.isReplayed = true;
this.changeGameState(GameState.GameOver);
this.changeGameState(this.replayTimes > 0 ? GameState.GameOver : GameState.End);
}
public Ready() {

View File

@ -3,10 +3,13 @@ export type postMessageType = 'paypal_modal' | 'game_tournament';
export type minusTicketType = 'auth' | 'revive';
export interface SDK {
setCallAPI(value: boolean): void;
getUserTicket(): number;
getTopScore(): number;
getLatestScore(): number;
getGameScore(): number;
getUserId(): string;
getGameTime(): number | null;
getTicketNeedToContinue(): number;
init(buyTicketCallBack: () => any, thisArg?: any): void;
updateScore(score: number): void;
@ -18,6 +21,13 @@ export interface SDK {
callPayPalModal(): void;
canRelive(): boolean;
spinGacha(id: string): Promise<Reward>;
getLeaderBoard(): Promise<PlayerInfo[]>;
}
export interface PlayerInfo {
userId: string;
displayName: string;
score: number;
}
export interface Reward {
@ -54,6 +64,14 @@ export default class P4PSDK {
return this._sdk?.getGameScore();
}
public static getUserId(): string {
return this._sdk.getUserId();
}
public static getGameTime(): number | null {
return this._sdk.getGameTime();
}
public static getTicketNeedToContinue(): number {
return this._sdk?.getTicketNeedToContinue();
}
@ -62,8 +80,7 @@ export default class P4PSDK {
return new Promise((resolve, reject) => {
const tag = document.createElement('script');
tag.type = 'module';
tag.src =
'https://firebasestorage.googleapis.com/v0/b/play-now-1aef8.appspot.com/o/SDK%2Fsdk.js?alt=media&token=dd9de5d9-3c09-40da-81ae-c4efae33a828';
tag.src = 'https://firebasestorage.googleapis.com/v0/b/play-now-1aef8.appspot.com/o/SDK%2Fsdk.js?alt=media';
tag.async = true;
tag.onload = async () => {
console.log('P4P SDK loaded');
@ -78,6 +95,10 @@ export default class P4PSDK {
});
}
public static setCallAPI(value: boolean) {
this._sdk?.setCallAPI(value);
}
public static async init(buyTicketCallBack: () => any, thisArg?: any): Promise<void> {
if (this._initState == InitState.Initialized) return;
await this.loadSDK();
@ -120,5 +141,9 @@ export default class P4PSDK {
public static async spinGacha(id: string): Promise<Reward> {
return this._sdk?.spinGacha(id);
}
public static async getLeaderBoard(): Promise<PlayerInfo[]> {
return this._sdk?.getLeaderBoard();
}
//#endregion
}

View File

@ -44,11 +44,11 @@ export class GameOverPanel extends Component {
private _clicked = false;
private _end = false;
protected onLoad(): void {
protected onEnable(): void {
EventManger.instance.on(GameEvent.GameStateChange, this.onGameStateChange, this);
}
protected onEnable(): void {
public show(end: boolean): void {
this._ticketMinus.string = P4PSDK.getTicketNeedToContinue().toString();
const currentScore = P4PSDK.getLatestScore();
const gameScore = P4PSDK.getGameScore();
@ -56,7 +56,12 @@ export class GameOverPanel extends Component {
this.yourScore.string = currentScore.toString();
this.playCollectEffect(gameScore, currentScore);
this.scheduleOnce(this.endGame, 60);
this._end = end;
this._active = true;
if (this._end) {
this._buyTicketBtn.active = false;
this._quitBtn.active = false;
}
}
private async onGameStateChange(state: GameState) {
@ -72,7 +77,6 @@ export class GameOverPanel extends Component {
case GameState.End:
this._buyTicketBtn.active = false;
this._quitBtn.active = false;
this._end = true;
if (this._active) {
await Utils.delay(1);
P4PSDK.postScoreToServer();
@ -96,6 +100,7 @@ export class GameOverPanel extends Component {
protected onDisable(): void {
this._active = false;
this.unschedule(this.endGame);
EventManger.instance.off(GameEvent.GameStateChange, this.onGameStateChange, this);
}
private endGame() {

View File

@ -8,6 +8,7 @@ import { GameManager } from '../Manager/GameManager';
import { StickerManager } from '../Manager/StickerManager';
import P4PSDK from '../P4PSDK';
import Utils from '../Utilities';
import { GameOverPanel } from './GameOverPanel';
const { ccclass, property } = _decorator;
@ccclass('UIController')
@ -82,10 +83,13 @@ export class UIController extends Component {
await Utils.waitUntil(() => !GameManager.instance.isWaitingUpdateScore);
await Utils.delay(2);
this._overPanel.active = true;
this._overPanel.getComponent(GameOverPanel).show(false);
break;
case GameState.End:
await Utils.waitUntil(() => !GameManager.instance.isWaitingUpdateScore);
await Utils.delay(2);
this._overPanel.active = true;
this._overPanel.getComponent(GameOverPanel).show(true);
break;
case GameState.Relive:
this._overPanel.active = false;

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

View File

@ -0,0 +1,134 @@
{
"ver": "1.0.26",
"importer": "image",
"imported": true,
"uuid": "da6ec5d3-3249-46a7-be04-ea2b43d364ea",
"files": [
".jpg",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "da6ec5d3-3249-46a7-be04-ea2b43d364ea@6c48a",
"displayName": "Logo ver 2",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"imageUuidOrDatabaseUri": "da6ec5d3-3249-46a7-be04-ea2b43d364ea",
"isUuid": true,
"visible": false,
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0
},
"ver": "1.0.22",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "da6ec5d3-3249-46a7-be04-ea2b43d364ea@f9941",
"displayName": "Logo ver 2",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1280,
"height": 1016,
"rawWidth": 1280,
"rawHeight": 1016,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"pixelsToUnit": 100,
"pivotX": 0.5,
"pivotY": 0.5,
"meshType": 0,
"vertices": {
"rawPosition": [
-640,
-508,
0,
640,
-508,
0,
-640,
508,
0,
640,
508,
0
],
"indexes": [
0,
1,
2,
2,
1,
3
],
"uv": [
0,
1016,
1280,
1016,
0,
0,
1280,
0
],
"nuv": [
0,
0,
1,
0,
0,
1,
1,
1
],
"minPos": [
-640,
-508,
0
],
"maxPos": [
640,
508,
0
]
},
"isUuid": true,
"imageUuidOrDatabaseUri": "da6ec5d3-3249-46a7-be04-ea2b43d364ea@6c48a",
"atlasUuid": ""
},
"ver": "1.0.12",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"type": "sprite-frame",
"hasAlpha": false,
"fixAlphaTransparencyArtifacts": false,
"redirect": "da6ec5d3-3249-46a7-be04-ea2b43d364ea@f9941"
}
}

BIN
settings/Logo ver 2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

View File

@ -1,13 +1,23 @@
{
"__version__": "1.3.7",
"splash-setting": {
"displayRatio": 1,
"displayRatio": 1.5,
"totalTime": 2000,
"watermarkLocation": "default",
"autoFit": true,
"logo": {
"type": "custom",
"image": "project://settings/splash.png"
"image": "project://settings/Logo ver 2.jpg"
},
"background": {
"image": "project://settings/Logo ver 2.jpg",
"type": "color",
"color": {
"x": 0,
"y": 0,
"z": 0,
"w": 1
}
}
}
}