From d492ccbf213d7e47bfaf621136ea9ccaee0e24c3 Mon Sep 17 00:00:00 2001 From: tiendat3699 <96950844+tiendat3699@users.noreply.github.com> Date: Fri, 5 Apr 2024 15:09:19 +0700 Subject: [PATCH] fix: bug 5/4 --- assets/_Game/Prefabs/UI/itemTop1.prefab | 200 +++++++++++++++++- assets/_Game/Scenes/EndLessScene.scene | 3 +- assets/_Game/Scripts/API/BEConnector.ts | 66 ++---- assets/_Game/Scripts/Enum/ControllerSide.ts | 10 + .../_Game/Scripts/Enum/ControllerSide.ts.meta | 9 + assets/_Game/Scripts/Enum/PhysicGroup.ts | 4 +- assets/_Game/Scripts/Enum/TimeConfig.ts | 2 +- .../Scripts/Environments/CumulativeBar.ts | 6 +- assets/_Game/Scripts/Events/GameEvent.ts | 2 +- assets/_Game/Scripts/GamePlay/Cannon.ts | 2 +- assets/_Game/Scripts/Gameplay/Ball.ts | 1 - assets/_Game/Scripts/Gameplay/Flipper.ts | 10 +- assets/_Game/Scripts/Manager/GameManager.ts | 2 +- assets/_Game/Scripts/UI/GameOverPanel.ts | 4 +- assets/_Game/Scripts/UI/TouchController.ts | 2 +- 15 files changed, 238 insertions(+), 85 deletions(-) create mode 100644 assets/_Game/Scripts/Enum/ControllerSide.ts create mode 100644 assets/_Game/Scripts/Enum/ControllerSide.ts.meta diff --git a/assets/_Game/Prefabs/UI/itemTop1.prefab b/assets/_Game/Prefabs/UI/itemTop1.prefab index 4c442de..c436d4b 100644 --- a/assets/_Game/Prefabs/UI/itemTop1.prefab +++ b/assets/_Game/Prefabs/UI/itemTop1.prefab @@ -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 + } + ] } ] \ No newline at end of file diff --git a/assets/_Game/Scenes/EndLessScene.scene b/assets/_Game/Scenes/EndLessScene.scene index 2225cb9..58233f5 100644 --- a/assets/_Game/Scenes/EndLessScene.scene +++ b/assets/_Game/Scenes/EndLessScene.scene @@ -10087,8 +10087,7 @@ "instance": { "__id__": 331 }, - "targetOverrides": null, - "nestedPrefabInstanceRoots": null + "targetOverrides": null }, { "__type__": "cc.PrefabInstance", diff --git a/assets/_Game/Scripts/API/BEConnector.ts b/assets/_Game/Scripts/API/BEConnector.ts index 5d62f9b..0eda4f4 100644 --- a/assets/_Game/Scripts/API/BEConnector.ts +++ b/assets/_Game/Scripts/API/BEConnector.ts @@ -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') { private token: string; @@ -65,6 +20,8 @@ export default class BEConnector extends Singleton('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') { } 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') { } 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') { ); } - 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') { 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') { 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; } diff --git a/assets/_Game/Scripts/Enum/ControllerSide.ts b/assets/_Game/Scripts/Enum/ControllerSide.ts new file mode 100644 index 0000000..e15a3d9 --- /dev/null +++ b/assets/_Game/Scripts/Enum/ControllerSide.ts @@ -0,0 +1,10 @@ +import { Enum } from 'cc'; + +enum ControllerSide { + Left, + Right, +} + +Enum(ControllerSide); + +export default ControllerSide; diff --git a/assets/_Game/Scripts/Enum/ControllerSide.ts.meta b/assets/_Game/Scripts/Enum/ControllerSide.ts.meta new file mode 100644 index 0000000..63be926 --- /dev/null +++ b/assets/_Game/Scripts/Enum/ControllerSide.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "f54090c4-8d37-440f-8fb5-21fb086c47c6", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/_Game/Scripts/Enum/PhysicGroup.ts b/assets/_Game/Scripts/Enum/PhysicGroup.ts index 7b32d67..dd4c57b 100644 --- a/assets/_Game/Scripts/Enum/PhysicGroup.ts +++ b/assets/_Game/Scripts/Enum/PhysicGroup.ts @@ -10,4 +10,6 @@ enum PhysicsGroup { FLIPPER = 1 << 6, } -export default Enum(PhysicsGroup); +Enum(PhysicsGroup); + +export default PhysicsGroup; diff --git a/assets/_Game/Scripts/Enum/TimeConfig.ts b/assets/_Game/Scripts/Enum/TimeConfig.ts index 8567ba3..62e4ae7 100644 --- a/assets/_Game/Scripts/Enum/TimeConfig.ts +++ b/assets/_Game/Scripts/Enum/TimeConfig.ts @@ -4,7 +4,7 @@ enum TimeConfig { DelayGoal = 2, DelayCannonFire = 0.4, DelayCannonDone = 0.5, - Tutorial = 10, + Tutorial = 20, } export default TimeConfig; diff --git a/assets/_Game/Scripts/Environments/CumulativeBar.ts b/assets/_Game/Scripts/Environments/CumulativeBar.ts index f0e6949..dffb6be 100644 --- a/assets/_Game/Scripts/Environments/CumulativeBar.ts +++ b/assets/_Game/Scripts/Environments/CumulativeBar.ts @@ -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) { diff --git a/assets/_Game/Scripts/Events/GameEvent.ts b/assets/_Game/Scripts/Events/GameEvent.ts index 7cab164..7a0c008 100644 --- a/assets/_Game/Scripts/Events/GameEvent.ts +++ b/assets/_Game/Scripts/Events/GameEvent.ts @@ -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, diff --git a/assets/_Game/Scripts/GamePlay/Cannon.ts b/assets/_Game/Scripts/GamePlay/Cannon.ts index 4d3ec79..47aded0 100644 --- a/assets/_Game/Scripts/GamePlay/Cannon.ts +++ b/assets/_Game/Scripts/GamePlay/Cannon.ts @@ -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) { diff --git a/assets/_Game/Scripts/Gameplay/Ball.ts b/assets/_Game/Scripts/Gameplay/Ball.ts index 7a40ee1..d5ef9c9 100644 --- a/assets/_Game/Scripts/Gameplay/Ball.ts +++ b/assets/_Game/Scripts/Gameplay/Ball.ts @@ -19,7 +19,6 @@ import { CircleCollider2D, Animation, Sprite, - RealCurve, } from 'cc'; import IPoolable from '../Pool/IPoolable'; import { SoundManager } from '../Manager/SoundManager'; diff --git a/assets/_Game/Scripts/Gameplay/Flipper.ts b/assets/_Game/Scripts/Gameplay/Flipper.ts index fd5663f..b48e725 100644 --- a/assets/_Game/Scripts/Gameplay/Flipper.ts +++ b/assets/_Game/Scripts/Gameplay/Flipper.ts @@ -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 }) diff --git a/assets/_Game/Scripts/Manager/GameManager.ts b/assets/_Game/Scripts/Manager/GameManager.ts index 58e3ba6..46424a1 100644 --- a/assets/_Game/Scripts/Manager/GameManager.ts +++ b/assets/_Game/Scripts/Manager/GameManager.ts @@ -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() { } this._boostersActive = []; SoundManager.instance.playBGM(this._gameOverMusic); + BEConnector.instance.gameScore = this.score; if (this.isReplayed) { this.changeGameState(GameState.End); return; diff --git a/assets/_Game/Scripts/UI/GameOverPanel.ts b/assets/_Game/Scripts/UI/GameOverPanel.ts index 02c35d4..49f69a9 100644 --- a/assets/_Game/Scripts/UI/GameOverPanel.ts +++ b/assets/_Game/Scripts/UI/GameOverPanel.ts @@ -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(); diff --git a/assets/_Game/Scripts/UI/TouchController.ts b/assets/_Game/Scripts/UI/TouchController.ts index b93147c..dca1003 100644 --- a/assets/_Game/Scripts/UI/TouchController.ts +++ b/assets/_Game/Scripts/UI/TouchController.ts @@ -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')