Skip to content

Commit

Permalink
Updated SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
neki-dev committed Nov 3, 2023
1 parent d7356cf commit 000e8c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
20 changes: 14 additions & 6 deletions src/game/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Game extends Phaser.Game implements IGame {

public usedSave: Nullable<StorageSave> = null;

private triedFullscreen: boolean = false;
private sessionsCount: number = 0;

constructor() {
super({
Expand Down Expand Up @@ -200,15 +200,25 @@ export class Game extends Phaser.Game implements IGame {

this.usedSave = null;

this.startGame();
if (this.sessionsCount === 0) {
this.startGame();
} else {
SDK.ShowAds(SDKAdsType.MIDGAME).then(() => {
this.startGame();
});
}
}

private startGame() {
if (this.state !== GameState.IDLE) {
return;
}

this.triggerFullscreen();
if (this.sessionsCount === 0) {
this.triggerFullscreen();
}

this.sessionsCount++;

if (this.usedSave) {
this.loadSavePayload(this.usedSave.payload.game);
Expand Down Expand Up @@ -348,16 +358,14 @@ export class Game extends Phaser.Game implements IGame {

private triggerFullscreen() {
if (
this.triedFullscreen
|| this.scale.isFullscreen
this.scale.isFullscreen
|| this.isDesktop()
|| Environment.Platform === 'development'
) {
return;
}

try {
this.triedFullscreen = true;
this.scale.startFullscreen();
} catch (error) {
//
Expand Down
8 changes: 6 additions & 2 deletions src/game/scenes/screen/interface/skills/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { useGame } from 'phaser-react-ui';
import React, { useEffect, useState } from 'react';

import { phrase } from '~lib/lang';
import { SDK } from '~lib/sdk';
import { Tutorial } from '~lib/tutorial';
import { Button } from '~scene/system/interface/button';
import { Hint } from '~scene/system/interface/hint';
import { IGame } from '~type/game';
import { SDKAdsType } from '~type/sdk';
import { TutorialStep } from '~type/tutorial';

import { Modal } from './modal';
Expand All @@ -24,8 +26,10 @@ export const Skills: React.FC = () => {
};

const onClose = () => {
setOpened(false);
game.toggleSystemPause(false);
SDK.ShowAds(SDKAdsType.MIDGAME).then(() => {
setOpened(false);
game.toggleSystemPause(false);
});
};

useEffect(() => (
Expand Down

0 comments on commit 000e8c5

Please sign in to comment.