Merge branch 'feat/mutil-theme' into origin/feat/Skin1/TA
commit
1497ad137e
|
@ -548,7 +548,7 @@
|
|||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 1060,
|
||||
"height": 2203
|
||||
"height": 2100
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
|
|
|
@ -34434,7 +34434,7 @@
|
|||
"y": -1200,
|
||||
"z": 0
|
||||
},
|
||||
"_timePlay": 30,
|
||||
"_timePlay": 120,
|
||||
"_clockIcon": {
|
||||
"__uuid__": "f7bd5166-9d5f-4d43-a3d3-58ae9a4957fc@f9941",
|
||||
"__expectedType__": "cc.SpriteFrame"
|
||||
|
|
|
@ -1,37 +1,24 @@
|
|||
import { _decorator } from 'cc';
|
||||
import * as CryptoES from 'crypto-es';
|
||||
import Singleton from '../Singleton';
|
||||
export let CryptoESDefault = CryptoES.default;
|
||||
import CryptoES from 'crypto-es';
|
||||
import { get, post } from './HttpRequest';
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('BEConnector')
|
||||
export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
|
||||
private token: string;
|
||||
private skinId: string;
|
||||
private tournamentId: string;
|
||||
private key: string;
|
||||
private deviceInfo: string;
|
||||
export default class BEConnector {
|
||||
private static token: string;
|
||||
private static skinId: string;
|
||||
private static tournamentId: string;
|
||||
private static key: string;
|
||||
private static deviceInfo: string;
|
||||
|
||||
// Ticket info
|
||||
public numberTicket: number;
|
||||
public maxScore: number;
|
||||
public currentScore: number;
|
||||
public topScores: [] = [];
|
||||
private mileStone: string;
|
||||
public static numberTicket: number;
|
||||
public static maxScore: number;
|
||||
public static currentScore: number;
|
||||
public static topScores: [] = [];
|
||||
private static mileStone: string;
|
||||
public static gameScore: number = 0;
|
||||
private static gameURL: string = '';
|
||||
|
||||
public gameScore: number = 0;
|
||||
|
||||
private gameURL: string = '';
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.getGameData();
|
||||
}
|
||||
|
||||
public getGameData() {
|
||||
public static getGameData() {
|
||||
let url = new URLSearchParams(window.location.search);
|
||||
|
||||
this.token = url.get('token');
|
||||
this.skinId = url.get('skinId');
|
||||
this.tournamentId = url.get('tournamentId');
|
||||
|
@ -44,54 +31,40 @@ export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
|
|||
this.gameURL = ENV_CONFIG[url.get('env')];
|
||||
}
|
||||
|
||||
public async getInfo() {
|
||||
public static async authenticate() {
|
||||
try {
|
||||
const res = await fetch(`${this.gameURL}/promotions/detail/${this.tournamentId}`);
|
||||
const json = await res.json();
|
||||
this.topScores = json.tScores;
|
||||
const res = await get(
|
||||
`${this.gameURL}/promotions/authenticate-tournament?token=${this.token}&tournamentId=${this.tournamentId}&skinId=${this.skinId}&deviceInfo=${this.deviceInfo}`,
|
||||
);
|
||||
const data = await res.json();
|
||||
if (data.ResultCode == 1) {
|
||||
this.key = data.Data.Key;
|
||||
console.log('Authenticate success');
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Authenticate failed', error);
|
||||
}
|
||||
}
|
||||
|
||||
public static async ticketMinus(type: 'auth' | 'revive') {
|
||||
const numberTicket = type === 'auth' ? 1 : this.getTicketCanBeMinus();
|
||||
const dataEncrypted: string = this.getDataEncrypted({ type: type, total: numberTicket });
|
||||
const JsonData = JSON.stringify({ data: dataEncrypted });
|
||||
try {
|
||||
await post(
|
||||
`${this.gameURL}/promotions/ticket-minus/${this.tournamentId}/${this.skinId}?cocos=1`,
|
||||
this.token,
|
||||
JsonData,
|
||||
);
|
||||
|
||||
this.numberTicket -= numberTicket;
|
||||
return this.numberTicket;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
public async authenticate() {
|
||||
await fetch(
|
||||
`${this.gameURL}/promotions/authenticate-tournament?token=${this.token}&tournamentId=${this.tournamentId}&skinId=${this.skinId}&deviceInfo=${this.deviceInfo}`,
|
||||
)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
if (data.ResultCode == 1) {
|
||||
this.key = data.Data.Key;
|
||||
console.log('authen success', this.key);
|
||||
} else {
|
||||
throw new Error('');
|
||||
}
|
||||
})
|
||||
.catch((err) => console.log('authen failed'));
|
||||
}
|
||||
|
||||
public ticketMinus(type: 'auth' | 'revive') {
|
||||
let numberTicket = type === 'auth' ? 1 : this.getTicketCanBeMinus();
|
||||
let dataEncrypted: string = this.getDataEncrypted({ type: type, total: numberTicket });
|
||||
|
||||
fetch(`${this.gameURL}/promotions/ticket-minus/${this.tournamentId}/${this.skinId}?cocos=1`, {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'x-access-refactor-token': this.token,
|
||||
},
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ data: dataEncrypted }),
|
||||
}).then(() => {
|
||||
this.numberTicket -= numberTicket;
|
||||
});
|
||||
}
|
||||
|
||||
public calculatingTicketToContinue(scoreRange: object, yourScore: number) {
|
||||
public static calculatingTicketToContinue(scoreRange: object, yourScore: number) {
|
||||
let closestMilestone: number = 0;
|
||||
for (const milestone in scoreRange) {
|
||||
if (parseInt(milestone) <= yourScore) {
|
||||
|
@ -105,25 +78,25 @@ export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
|
|||
return closestMilestone;
|
||||
}
|
||||
|
||||
public async checkGameScoreTicket() {
|
||||
let totalScore: number = this.gameScore;
|
||||
let dataEncrypted: string = this.getDataEncrypted({
|
||||
public static async checkGameScoreTicket() {
|
||||
const totalScore: number = this.gameScore;
|
||||
const dataEncrypted: string = this.getDataEncrypted({
|
||||
score: totalScore,
|
||||
ticket: this.getTicketCanBeMinus(),
|
||||
});
|
||||
|
||||
await fetch(`${this.gameURL}/promotions/check-game-score-ticket/${this.tournamentId}/${this.skinId}?cocos=1`, {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'x-access-refactor-token': this.token,
|
||||
},
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ data: dataEncrypted }),
|
||||
});
|
||||
const data = JSON.stringify({ data: dataEncrypted });
|
||||
try {
|
||||
await post(
|
||||
`${this.gameURL}/promotions/check-game-score-ticket/${this.tournamentId}/${this.skinId}?cocos=1`,
|
||||
this.token,
|
||||
data,
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
public postMessage() {
|
||||
public static postMessage() {
|
||||
let totalScore: number = this.gameScore + this.currentScore;
|
||||
window.parent.postMessage(
|
||||
JSON.stringify({
|
||||
|
@ -136,47 +109,45 @@ export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
|
|||
);
|
||||
}
|
||||
|
||||
public postScoreToServer() {
|
||||
let dataEncrypted: string = this.getDataEncrypted({
|
||||
public static async postScoreToServer() {
|
||||
const dataEncrypted: string = this.getDataEncrypted({
|
||||
Score: this.gameScore,
|
||||
TournamentId: this.tournamentId,
|
||||
SkinId: this.skinId,
|
||||
});
|
||||
|
||||
fetch(
|
||||
`${this.gameURL}/promotions/store-score-tournament?tournamentId=${this.tournamentId}&skinId=${this.skinId}&cocos=1`,
|
||||
{
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'x-access-refactor-token': this.token,
|
||||
},
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ data: dataEncrypted }),
|
||||
},
|
||||
).catch((err) => console.log(err));
|
||||
console.log('send score to server: ' + this.gameScore);
|
||||
const data = JSON.stringify({ data: dataEncrypted });
|
||||
try {
|
||||
const res = await post(
|
||||
`${this.gameURL}/promotions/store-score-tournament?tournamentId=${this.tournamentId}&skinId=${this.skinId}&cocos=1`,
|
||||
this.token,
|
||||
data,
|
||||
);
|
||||
|
||||
window.parent.postMessage(
|
||||
JSON.stringify({
|
||||
error: false,
|
||||
message: 'Hello World',
|
||||
score: this.gameScore + this.currentScore,
|
||||
type: 'game_tournament',
|
||||
}),
|
||||
'*',
|
||||
);
|
||||
console.log('send score to server: ' + this.gameScore);
|
||||
window.parent.postMessage(
|
||||
JSON.stringify({
|
||||
error: false,
|
||||
message: 'Hello World',
|
||||
score: this.gameScore + this.currentScore,
|
||||
type: 'game_tournament',
|
||||
}),
|
||||
'*',
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
private getDataEncrypted(data: any): string {
|
||||
return CryptoESDefault.AES.encrypt(JSON.stringify(data), this.key, {
|
||||
iv: CryptoESDefault.enc.Utf8.parse('16'),
|
||||
mode: CryptoESDefault.mode.CBC,
|
||||
padding: CryptoESDefault.pad.Pkcs7,
|
||||
private static getDataEncrypted(data: any): string {
|
||||
return CryptoES.AES.encrypt(JSON.stringify(data), this.key, {
|
||||
iv: CryptoES.enc.Utf8.parse('16'),
|
||||
mode: CryptoES.mode.CBC,
|
||||
padding: CryptoES.pad.Pkcs7,
|
||||
}).toString();
|
||||
}
|
||||
|
||||
public getTicketCanBeMinus() {
|
||||
public static getTicketCanBeMinus() {
|
||||
if (!this.mileStone) return 0;
|
||||
let mileStone = JSON.parse(this.mileStone);
|
||||
let currentScore = this.gameScore;
|
||||
|
@ -184,7 +155,7 @@ export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
|
|||
return total;
|
||||
}
|
||||
|
||||
public canRelive() {
|
||||
public static canRelive() {
|
||||
return this.numberTicket > this.getTicketCanBeMinus();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
const headersInit = {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
|
||||
export const get = async (path: RequestInfo) => {
|
||||
const res = await fetch(path, {
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(res.statusText);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const post = async (path: RequestInfo, token?: string, data?: string) => {
|
||||
const res = await fetch(path, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...headersInit,
|
||||
'x-access-refactor-token': token,
|
||||
},
|
||||
body: data,
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(res.statusText);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const put = async (path: RequestInfo, token?: string, data?: string) => {
|
||||
const res = await fetch(path, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
...headersInit,
|
||||
'x-access-refactor-token': token,
|
||||
},
|
||||
body: data,
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(res.statusText);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const del = async (path: RequestInfo, token?: string, data?: string) => {
|
||||
const res = await fetch(path, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
...headersInit,
|
||||
'x-access-refactor-token': token,
|
||||
},
|
||||
body: data,
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(res.statusText);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "04c2a240-38c0-4d9c-993a-3773d709137f",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import { _decorator, CCFloat, Collider2D, Component, Contact2DType, Animation, AudioClip } from 'cc';
|
||||
import { _decorator, CCFloat, Collider2D, Component, Contact2DType, Animation, AudioClip, CCString } from 'cc';
|
||||
import ObjectPool from '../Pool/ObjectPool';
|
||||
import { EventManger } from '../Manager/EventManger';
|
||||
import GameEvent from '../Events/GameEvent';
|
||||
|
@ -15,6 +15,8 @@ export class BoosterBase extends Component implements IPoolable {
|
|||
protected _collectSound: AudioClip;
|
||||
@property({ type: Animation, visible: true })
|
||||
private _animation: Animation;
|
||||
@property()
|
||||
public readonly displayName: string = 'CHEESE';
|
||||
|
||||
@property(CCFloat)
|
||||
protected time: number = 10;
|
||||
|
|
|
@ -7,6 +7,6 @@ const { ccclass, property } = _decorator;
|
|||
@ccclass('CumulativeBooster')
|
||||
export class CumulativeBooster extends BoosterBase {
|
||||
protected boosterActive(): void {
|
||||
GameManager.instance.ActiveBooster(BoosterType.CumulativeBar, this.time);
|
||||
GameManager.instance.ActiveBooster(BoosterType.CumulativeBar, this.time, this.displayName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ enum GameEvent {
|
|||
ControlTouchStart,
|
||||
ControlTouchEnd,
|
||||
WarningTime,
|
||||
TicketUpdate,
|
||||
}
|
||||
|
||||
export interface GameEventCallbackMap {
|
||||
|
@ -25,11 +26,12 @@ export interface GameEventCallbackMap {
|
|||
[GameEvent.TimeUpdate]: (time: number) => void;
|
||||
[GameEvent.GameStateChange]: (state: GameState) => void;
|
||||
[GameEvent.ObjectRelease]: (obj: Node) => void;
|
||||
[GameEvent.BoosterActive]: (boosterType: BoosterType) => void;
|
||||
[GameEvent.BoosterActive]: (boosterType: BoosterType, displayName: string) => void;
|
||||
[GameEvent.BoosterDisable]: (boosterType: BoosterType) => void;
|
||||
[GameEvent.ControlTouchStart]: (touchSide: ControllerSide) => void;
|
||||
[GameEvent.ControlTouchEnd]: (touchSide: ControllerSide) => void;
|
||||
[GameEvent.WarningTime]: (warning: boolean) => void;
|
||||
[GameEvent.TicketUpdate]: (ticket: number) => void;
|
||||
}
|
||||
|
||||
export interface GameEventArgMap {
|
||||
|
@ -39,11 +41,12 @@ export interface GameEventArgMap {
|
|||
[GameEvent.TimeUpdate]: number;
|
||||
[GameEvent.GameStateChange]: GameState;
|
||||
[GameEvent.ObjectRelease]: Node;
|
||||
[GameEvent.BoosterActive]: BoosterType;
|
||||
[GameEvent.BoosterActive]: [BoosterType, string];
|
||||
[GameEvent.BoosterDisable]: BoosterType;
|
||||
[GameEvent.ControlTouchStart]: ControllerSide;
|
||||
[GameEvent.ControlTouchEnd]: ControllerSide;
|
||||
[GameEvent.WarningTime]: boolean;
|
||||
[GameEvent.TicketUpdate]: number;
|
||||
}
|
||||
|
||||
export default GameEvent;
|
||||
|
|
|
@ -116,7 +116,7 @@ export class Flipper extends Component {
|
|||
//#endregion
|
||||
|
||||
private activeFlipper(): void {
|
||||
SoundManager.instance.playSfx(this._activeSound, 0.5);
|
||||
SoundManager.instance.playSfx(this._activeSound, { volume: 0.5 });
|
||||
this._hingeJoint.motorSpeed = this._motorSpeedActive;
|
||||
}
|
||||
private deActiveFlipper(): void {
|
||||
|
|
|
@ -35,7 +35,7 @@ window.addEventListener('message', (data) => {
|
|||
if (objectRes) {
|
||||
const { type, value } = objectRes;
|
||||
if (type === 'newTicket') {
|
||||
BEConnector.instance.numberTicket += value;
|
||||
BEConnector.numberTicket += value;
|
||||
GameManager.instance.gameRelive();
|
||||
}
|
||||
}
|
||||
|
@ -120,12 +120,12 @@ export class GameManager extends Singleton<GameManager>() {
|
|||
super.onLoad();
|
||||
this._ballPool = new ObjectPool(this._ballPrefab, 10, true, Ball);
|
||||
this._FloatingScorePool = new ObjectPool(this._floatingScoreText, 10, true);
|
||||
BEConnector.getGameData();
|
||||
if (this._colliderDebug) PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Shape;
|
||||
}
|
||||
|
||||
protected start(): void {
|
||||
this.changeGameState(GameState.Init);
|
||||
BEConnector.instance.getInfo();
|
||||
}
|
||||
|
||||
protected update(dt: number): void {
|
||||
|
@ -146,23 +146,25 @@ export class GameManager extends Singleton<GameManager>() {
|
|||
private async changeGameState(state: GameState) {
|
||||
this._gameState = state;
|
||||
EventManger.instance.emit(GameEvent.GameStateChange, this._gameState);
|
||||
|
||||
let ticket = 0;
|
||||
switch (state) {
|
||||
case GameState.Init:
|
||||
BEConnector.instance.authenticate();
|
||||
BEConnector.authenticate();
|
||||
break;
|
||||
case GameState.Ready:
|
||||
break;
|
||||
case GameState.Playing:
|
||||
this.countTime();
|
||||
BEConnector.instance.ticketMinus('auth');
|
||||
ticket = await BEConnector.ticketMinus('auth');
|
||||
EventManger.instance.emit(GameEvent.TicketUpdate, ticket);
|
||||
break;
|
||||
case GameState.GameOver:
|
||||
break;
|
||||
case GameState.End:
|
||||
break;
|
||||
case GameState.Relive:
|
||||
BEConnector.instance.ticketMinus('revive');
|
||||
ticket = await BEConnector.ticketMinus('revive');
|
||||
EventManger.instance.emit(GameEvent.TicketUpdate, ticket);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Argument Out Of Range Exception: ${GameState[state]}`);
|
||||
|
@ -220,7 +222,7 @@ export class GameManager extends Singleton<GameManager>() {
|
|||
|
||||
private setCurrentBallInGame(value: number) {
|
||||
this._currentBallInGame += value;
|
||||
if (this._currentBallInGame >= 2) {
|
||||
if (value > 0 && this._currentBallInGame >= 2) {
|
||||
this._isMultiBall = true;
|
||||
EventManger.instance.emit(GameEvent.MultiBall, true);
|
||||
this._ballPool.actives.forEach((ball) => ball.getComponent(Ball).playMultiBallEffect());
|
||||
|
@ -306,7 +308,7 @@ export class GameManager extends Singleton<GameManager>() {
|
|||
this.DisableAllBooster();
|
||||
SoundManager.instance.playBGM(this._gameOverMusic);
|
||||
StickerManager.instance.showLabel('TIME UP!!!', { color: new Color('#ed3a18'), outLineColor: Color.WHITE });
|
||||
BEConnector.instance.gameScore = this.score;
|
||||
BEConnector.gameScore = this.score;
|
||||
if (this.isReplayed) {
|
||||
this.changeGameState(GameState.End);
|
||||
return;
|
||||
|
@ -351,14 +353,14 @@ export class GameManager extends Singleton<GameManager>() {
|
|||
SoundManager.instance.setPlayRateBGM(1);
|
||||
}
|
||||
|
||||
public async ActiveBooster(type: BoosterType, time: number) {
|
||||
public async ActiveBooster(type: BoosterType, time: number, displayName: string) {
|
||||
//check booster already active
|
||||
for (let i = 0; i < this._boostersActive.length; i++) {
|
||||
const booster = this._boostersActive[i];
|
||||
if (booster.type == type) return;
|
||||
}
|
||||
this._boostersActive.push(new Booster(type, time));
|
||||
EventManger.instance.emit(GameEvent.BoosterActive, type);
|
||||
EventManger.instance.emit(GameEvent.BoosterActive, [type, displayName]);
|
||||
SoundManager.instance.playSfx(this._boosterActiveSound);
|
||||
SoundManager.instance.setPlayRateBGM(1.25);
|
||||
}
|
||||
|
|
|
@ -48,11 +48,11 @@ export class GameOverPanel extends Component {
|
|||
}
|
||||
|
||||
protected onEnable(): void {
|
||||
this._ticketMinus.string = '-' + BEConnector.instance.getTicketCanBeMinus().toString();
|
||||
this.topScore.string = BEConnector.instance.maxScore.toString();
|
||||
this.yourScore.string = BEConnector.instance.currentScore.toString();
|
||||
this._ticketMinus.string = '-' + BEConnector.getTicketCanBeMinus().toString();
|
||||
this.topScore.string = BEConnector.maxScore.toString();
|
||||
this.yourScore.string = BEConnector.currentScore.toString();
|
||||
const gameScore = GameManager.instance.score;
|
||||
const currentScore = BEConnector.instance.currentScore;
|
||||
const currentScore = BEConnector.currentScore;
|
||||
this.playCollectEffect(gameScore, currentScore);
|
||||
this.scheduleOnce(this.endGame, 60);
|
||||
this._active = true;
|
||||
|
@ -74,7 +74,7 @@ export class GameOverPanel extends Component {
|
|||
this._end = true;
|
||||
if (this._active) {
|
||||
await Utilities.delay(1);
|
||||
BEConnector.instance.postScoreToServer();
|
||||
BEConnector.postScoreToServer();
|
||||
}
|
||||
break;
|
||||
case GameState.Relive:
|
||||
|
@ -85,9 +85,8 @@ export class GameOverPanel extends Component {
|
|||
onClickYesButton() {
|
||||
if (this._clicked) return;
|
||||
this._clicked = true;
|
||||
if (BEConnector.instance.canRelive()) {
|
||||
BEConnector.instance
|
||||
.checkGameScoreTicket()
|
||||
if (BEConnector.canRelive()) {
|
||||
BEConnector.checkGameScoreTicket()
|
||||
.then(() => {
|
||||
this._clicked = false;
|
||||
GameManager.instance.gameRelive();
|
||||
|
@ -98,7 +97,7 @@ export class GameOverPanel extends Component {
|
|||
});
|
||||
} else {
|
||||
this._clicked = false;
|
||||
BEConnector.instance.postMessage();
|
||||
BEConnector.postMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,7 +168,7 @@ export class GameOverPanel extends Component {
|
|||
.start();
|
||||
if (!this._end) return;
|
||||
await Utilities.delay(1);
|
||||
BEConnector.instance.postScoreToServer();
|
||||
BEConnector.postScoreToServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { _decorator, Color, Component, Label, LabelOutline, Node, ParticleSystem, Tween, tween, Vec3 } from 'cc';
|
||||
import { _decorator, Color, Component, Label, Node, ParticleSystem, Vec3 } from 'cc';
|
||||
import { EventManger } from '../Manager/EventManger';
|
||||
import GameEvent from '../Events/GameEvent';
|
||||
import ScoreType from '../Enum/ScoreType';
|
||||
|
@ -7,6 +7,7 @@ import { GameManager } from '../Manager/GameManager';
|
|||
import BEConnector from '../API/BEConnector';
|
||||
import Utilities from '../Utilities';
|
||||
import { StickerManager } from '../Manager/StickerManager';
|
||||
import BoosterType from '../Enum/BoosterType';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('UIController')
|
||||
|
@ -33,6 +34,7 @@ export class UIController extends Component {
|
|||
EventManger.instance.on(GameEvent.MultiBall, this.onMultiBall, this);
|
||||
EventManger.instance.on(GameEvent.BoosterActive, this.onBoosterActive, this);
|
||||
EventManger.instance.on(GameEvent.BoosterDisable, this.onBoosterDisable, this);
|
||||
EventManger.instance.on(GameEvent.TicketUpdate, this.onTicketUpdate, this);
|
||||
}
|
||||
|
||||
private async onScore(score: number, points: number, type: ScoreType) {
|
||||
|
@ -46,11 +48,15 @@ export class UIController extends Component {
|
|||
StickerManager.instance.Show('BallOut');
|
||||
}
|
||||
|
||||
private onTicketUpdate(ticket: number) {
|
||||
this._ticketLabel.string = ticket.toString();
|
||||
}
|
||||
|
||||
private async onGameStateChange(state: GameState) {
|
||||
switch (state) {
|
||||
case GameState.Init:
|
||||
this._startPanel.active = true;
|
||||
this._ticketLabel.string = BEConnector.instance.numberTicket.toString();
|
||||
this._ticketLabel.string = BEConnector.numberTicket.toString();
|
||||
this._scoreLabel.string = '0';
|
||||
break;
|
||||
case GameState.Ready:
|
||||
|
@ -59,7 +65,6 @@ export class UIController extends Component {
|
|||
break;
|
||||
case GameState.Playing:
|
||||
this._overPanel.active = false;
|
||||
this._ticketLabel.string = BEConnector.instance.numberTicket.toString();
|
||||
|
||||
break;
|
||||
case GameState.GameOver:
|
||||
|
@ -74,8 +79,6 @@ export class UIController extends Component {
|
|||
break;
|
||||
case GameState.Relive:
|
||||
this._overPanel.active = false;
|
||||
this._ticketLabel.string = BEConnector.instance.numberTicket.toString();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -86,9 +89,9 @@ export class UIController extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
public onBoosterActive() {
|
||||
public onBoosterActive(type: BoosterType, displayName: string) {
|
||||
this._buffFx.play();
|
||||
StickerManager.instance.showLabel('CHEESE!!!', {
|
||||
StickerManager.instance.showLabel(displayName + '!!!', {
|
||||
color: new Color('#ffb517'),
|
||||
outLineColor: new Color('#ec830a'),
|
||||
});
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 292 KiB After Width: | Height: | Size: 291 KiB |
|
@ -47,9 +47,9 @@
|
|||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 1060,
|
||||
"height": 2203,
|
||||
"height": 2100,
|
||||
"rawWidth": 1060,
|
||||
"rawHeight": 2203,
|
||||
"rawHeight": 2100,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
|
@ -62,16 +62,16 @@
|
|||
"vertices": {
|
||||
"rawPosition": [
|
||||
-530,
|
||||
-1101.5,
|
||||
-1050,
|
||||
0,
|
||||
530,
|
||||
-1101.5,
|
||||
-1050,
|
||||
0,
|
||||
-530,
|
||||
1101.5,
|
||||
1050,
|
||||
0,
|
||||
530,
|
||||
1101.5,
|
||||
1050,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
|
@ -84,9 +84,9 @@
|
|||
],
|
||||
"uv": [
|
||||
0,
|
||||
2203,
|
||||
2100,
|
||||
1060,
|
||||
2203,
|
||||
2100,
|
||||
0,
|
||||
0,
|
||||
1060,
|
||||
|
@ -104,12 +104,12 @@
|
|||
],
|
||||
"minPos": [
|
||||
-530,
|
||||
-1101.5,
|
||||
-1050,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
530,
|
||||
1101.5,
|
||||
1050,
|
||||
0
|
||||
]
|
||||
},
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 23 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.3 MiB |
Loading…
Reference in New Issue