fix: bug 5/4

main
tiendat3699 2024-04-05 15:09:19 +07:00
parent 8e082bace0
commit d492ccbf21
15 changed files with 238 additions and 85 deletions

View File

@ -22,22 +22,25 @@
},
{
"__id__": 20
},
{
"__id__": 28
}
],
"_active": true,
"_components": [
{
"__id__": 28
"__id__": 40
},
{
"__id__": 30
"__id__": 42
},
{
"__id__": 32
"__id__": 44
}
],
"_prefab": {
"__id__": 34
"__id__": 46
},
"_lpos": {
"__type__": "cc.Vec3",
@ -619,6 +622,179 @@
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_prefab": {
"__id__": 29
},
"__editorExtras__": {}
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 28
},
"asset": {
"__uuid__": "08db7198-bf32-48a4-b5c6-cb88bdb15478",
"__expectedType__": "cc.Prefab"
},
"fileId": "8dLJOK/3dIHrry1f3GsMwX",
"instance": {
"__id__": 30
},
"targetOverrides": null
},
{
"__type__": "cc.PrefabInstance",
"fileId": "d2DUrhWMxJb6lzECsBr/jC",
"prefabRootNode": {
"__id__": 1
},
"mountedChildren": [],
"mountedComponents": [
{
"__id__": 31
}
],
"propertyOverrides": [
{
"__id__": 35
},
{
"__id__": 37
},
{
"__id__": 38
},
{
"__id__": 39
}
],
"removedComponents": []
},
{
"__type__": "cc.MountedComponentsInfo",
"targetInfo": {
"__id__": 32
},
"components": [
{
"__id__": 33
}
]
},
{
"__type__": "cc.TargetInfo",
"localID": [
"8dLJOK/3dIHrry1f3GsMwX"
]
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {
"mountedRoot": {
"__id__": 28
}
},
"node": {
"__id__": 28
},
"_enabled": true,
"__prefab": {
"__id__": 34
},
"_alignFlags": 18,
"_target": null,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "13+utr2VVK3KwmWKqO283a"
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 36
},
"propertyPath": [
"_name"
],
"value": "FxLeaderBoard"
},
{
"__type__": "cc.TargetInfo",
"localID": [
"8dLJOK/3dIHrry1f3GsMwX"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 36
},
"propertyPath": [
"_lpos"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": -90,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 36
},
"propertyPath": [
"_lrot"
],
"value": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 36
},
"propertyPath": [
"_euler"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
}
},
{
"__type__": "cc.UITransform",
"_name": "",
@ -628,7 +804,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 29
"__id__": 41
},
"_contentSize": {
"__type__": "cc.Size",
@ -655,7 +831,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 31
"__id__": 43
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@ -699,10 +875,10 @@
},
"_enabled": true,
"__prefab": {
"__id__": 33
"__id__": 45
},
"_bg": {
"__id__": 30
"__id__": 42
},
"_highLightColor": {
"__type__": "cc.Color",
@ -726,6 +902,12 @@
"__id__": 0
},
"fileId": "f9uSHaj7BMlIwLhcEY9s8R",
"targetOverrides": null
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": [
{
"__id__": 28
}
]
}
]

View File

@ -10087,8 +10087,7 @@
"instance": {
"__id__": 331
},
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
"targetOverrides": null
},
{
"__type__": "cc.PrefabInstance",

View File

@ -1,55 +1,10 @@
import { _decorator } from 'cc';
import * as CryptoES from 'crypto-es';
import { GameManager } from '../Manager/GameManager';
import Utilities from '../Utilities';
import Singleton from '../Singleton';
export let CryptoESDefault = CryptoES.default;
const { ccclass, property } = _decorator;
window.addEventListener('message', (data) => {
const { data: res } = data;
const objectRes = Utilities.getJson(res);
if (objectRes) {
const { type, value } = objectRes;
if (type === 'newTicket') {
BEConnector.instance.numberTicket += value;
GameManager.instance.gameRelive();
}
}
});
const faketSocre = [
{
userNickName: 'Poorgodzz',
score: 1785,
},
{
userNickName: 'a3',
score: 172,
},
{
userNickName: 'LeonNeilson',
score: 150,
},
{
userNickName: 'Promo_',
score: 142,
},
{
userNickName: 'H2O',
score: 90,
},
{
userNickName: 'lmao',
score: 30,
},
{
userNickName: 'Hellooo',
score: 14,
},
];
@ccclass('BEConnector')
export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
private token: string;
@ -65,6 +20,8 @@ export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
public topScores: [] = [];
private mileStone: string;
public gameScore: number = 0;
private gameURL: string = '';
constructor() {
@ -149,8 +106,11 @@ export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
}
public async checkGameScoreTicket() {
let totalScore: number = GameManager.instance.score;
let dataEncrypted: string = this.getDataEncrypted({ score: totalScore, ticket: this.getTicketCanBeMinus() });
let totalScore: number = this.gameScore;
let 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: {
@ -164,7 +124,7 @@ export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
}
public postMessage() {
let totalScore: number = GameManager.instance.score;
let totalScore: number = this.gameScore + this.currentScore;
window.parent.postMessage(
JSON.stringify({
error: false,
@ -176,9 +136,9 @@ export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
);
}
public postScoreToServer(score: number) {
public postScoreToServer() {
let dataEncrypted: string = this.getDataEncrypted({
Score: score,
Score: this.gameScore,
TournamentId: this.tournamentId,
SkinId: this.skinId,
});
@ -195,13 +155,13 @@ export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
body: JSON.stringify({ data: dataEncrypted }),
},
).catch((err) => console.log(err));
console.log('send score to server: ' + score);
console.log('send score to server: ' + this.gameScore);
window.parent.postMessage(
JSON.stringify({
error: false,
message: 'Hello World',
score: score + this.currentScore,
score: this.gameScore + this.currentScore,
type: 'game_tournament',
}),
'*',
@ -219,7 +179,7 @@ export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
public getTicketCanBeMinus() {
if (!this.mileStone) return 0;
let mileStone = JSON.parse(this.mileStone);
let currentScore = GameManager.instance.score;
let currentScore = this.gameScore;
let total = this.calculatingTicketToContinue(mileStone, currentScore);
return total;
}

View File

@ -0,0 +1,10 @@
import { Enum } from 'cc';
enum ControllerSide {
Left,
Right,
}
Enum(ControllerSide);
export default ControllerSide;

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f54090c4-8d37-440f-8fb5-21fb086c47c6",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -10,4 +10,6 @@ enum PhysicsGroup {
FLIPPER = 1 << 6,
}
export default Enum(PhysicsGroup);
Enum(PhysicsGroup);
export default PhysicsGroup;

View File

@ -4,7 +4,7 @@ enum TimeConfig {
DelayGoal = 2,
DelayCannonFire = 0.4,
DelayCannonDone = 0.5,
Tutorial = 10,
Tutorial = 20,
}
export default TimeConfig;

View File

@ -10,7 +10,6 @@ import {
Prefab,
Tween,
Vec3,
Label,
AudioClip,
randomRange,
math,
@ -186,8 +185,9 @@ export class CumulativeBar extends Component {
}
private calcPositionOnCircleLine(angle: number) {
this._currentValuePosition.x = this._center.x + this._radius * -Math.cos(math.toRadian(angle));
this._currentValuePosition.y = this._center.y + this._radius * Math.sin(math.toRadian(angle));
const rad = math.toRadian(angle);
this._currentValuePosition.x = this._center.x + this._radius * -Math.cos(rad);
this._currentValuePosition.y = this._center.y + this._radius * Math.sin(rad);
}
private onBoosterActive(type: BoosterType) {

View File

@ -2,7 +2,7 @@ import { Node, Vec3 } from 'cc';
import GameState from '../Enum/GameState';
import ScoreType from '../Enum/ScoreType';
import BoosterType from '../Enum/BoosterType';
import { ControllerSide } from '../GamePlay/Flipper';
import ControllerSide from '../Enum/ControllerSide';
enum GameEvent {
Score,

View File

@ -40,7 +40,7 @@ export class Cannon extends Component {
EventManger.instance.on(GameEvent.BallOut, this.onBallOut, this);
}
private async onBeginContact(seft: Collider2D, other: Collider2D) {
private async onBeginContact(self: Collider2D, other: Collider2D) {
const ball = other.getComponent(Ball);
this._collider.enabled = false;
if (ball) {

View File

@ -19,7 +19,6 @@ import {
CircleCollider2D,
Animation,
Sprite,
RealCurve,
} from 'cc';
import IPoolable from '../Pool/IPoolable';
import { SoundManager } from '../Manager/SoundManager';

View File

@ -7,25 +7,17 @@ import {
Input,
EventKeyboard,
KeyCode,
Enum,
Animation,
Vec3,
AnimationState,
AudioClip,
} from 'cc';
import { EventManger } from '../Manager/EventManger';
import GameEvent from '../Events/GameEvent';
import TimeConfig from '../Enum/TimeConfig';
import { SoundManager } from '../Manager/SoundManager';
import ControllerSide from '../Enum/ControllerSide';
const { ccclass, property } = _decorator;
export enum ControllerSide {
Left,
Right,
}
Enum(ControllerSide);
@ccclass('Flipper')
export class Flipper extends Component {
@property({ type: Animation, visible: true })

View File

@ -10,7 +10,6 @@ import {
Quat,
EPhysics2DDrawFlags,
PhysicsSystem2D,
game,
} from 'cc';
import ObjectPool from '../Pool/ObjectPool';
import { Ball } from '../GamePlay/Ball';
@ -269,6 +268,7 @@ export class GameManager extends Singleton<GameManager>() {
}
this._boostersActive = [];
SoundManager.instance.playBGM(this._gameOverMusic);
BEConnector.instance.gameScore = this.score;
if (this.isReplayed) {
this.changeGameState(GameState.End);
return;

View File

@ -67,7 +67,7 @@ export class GameOverPanel extends Component {
this._end = true;
if (this._active) {
await Utilities.delay(1);
BEConnector.instance.postScoreToServer(GameManager.instance.score);
BEConnector.instance.postScoreToServer();
}
break;
case GameState.Relive:
@ -137,7 +137,7 @@ export class GameOverPanel extends Component {
this.yourScore.string = totalScore.toString();
if (this._end) {
await Utilities.delay(1);
BEConnector.instance.postScoreToServer(gameScore);
BEConnector.instance.postScoreToServer();
}
} else {
this.yourScore.string = score.toString();

View File

@ -1,7 +1,7 @@
import { _decorator, Component, Input, Node } from 'cc';
import { EventManger } from '../Manager/EventManger';
import GameEvent from '../Events/GameEvent';
import { ControllerSide } from '../GamePlay/Flipper';
import ControllerSide from '../Enum/ControllerSide';
const { ccclass, property } = _decorator;
@ccclass('TouchController')