From 8e082bace0ff597d6e1907b258988e1fc7fc203f Mon Sep 17 00:00:00 2001 From: tiendat3699 <96950844+tiendat3699@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:43:09 +0700 Subject: [PATCH] fix: bug 5/4 --- assets/_Game/Scenes/EndLessScene.scene | 14 ++++++++--- assets/_Game/Scripts/API/BEConnector.ts | 2 +- .../Scripts/Environments/CumulativeBar.ts | 23 ++++++++++++------- assets/_Game/Scripts/UI/GameOverPanel.ts | 7 +++--- assets/_Game/Scripts/UI/TutorialController.ts | 6 +++++ 5 files changed, 37 insertions(+), 15 deletions(-) diff --git a/assets/_Game/Scenes/EndLessScene.scene b/assets/_Game/Scenes/EndLessScene.scene index b7eca3f..2225cb9 100644 --- a/assets/_Game/Scenes/EndLessScene.scene +++ b/assets/_Game/Scenes/EndLessScene.scene @@ -7414,7 +7414,15 @@ "__uuid__": "35274179-f40e-4de9-a5d5-43fba9c12669", "__expectedType__": "cc.Prefab" }, - "_radius": 380, + "_centerOffset": { + "__type__": "cc.Vec3", + "x": 0, + "y": -60, + "z": 0 + }, + "_radius": 400, + "_minAngle": 10, + "_maxAngle": 170, "_soundFx": { "__uuid__": "65a023cb-b98f-4470-ba2d-4eba9fe184fe", "__expectedType__": "cc.AudioClip" @@ -27552,7 +27560,7 @@ "_prefab": null, "_lpos": { "__type__": "cc.Vec3", - "x": -450, + "x": -460, "y": -700, "z": 0 }, @@ -29523,7 +29531,7 @@ "_prefab": null, "_lpos": { "__type__": "cc.Vec3", - "x": 450, + "x": 460, "y": -700, "z": 0 }, diff --git a/assets/_Game/Scripts/API/BEConnector.ts b/assets/_Game/Scripts/API/BEConnector.ts index a73fe55..5d62f9b 100644 --- a/assets/_Game/Scripts/API/BEConnector.ts +++ b/assets/_Game/Scripts/API/BEConnector.ts @@ -81,7 +81,7 @@ export default class BEConnector extends Singleton('BEConnector') { this.deviceInfo = url.get('deviceInfo'); this.numberTicket = parseInt(url.get('numberTicket')) || 0; - this.maxScore = parseInt(url.get('maxScore')) || 99999; + this.maxScore = parseInt(url.get('maxScore')) || 0; this.currentScore = parseInt(url.get('currentScore')) || 0; this.mileStone = url.get('mileStone') || ''; this.gameURL = ENV_CONFIG[url.get('env')]; diff --git a/assets/_Game/Scripts/Environments/CumulativeBar.ts b/assets/_Game/Scripts/Environments/CumulativeBar.ts index 98b0ce0..f0e6949 100644 --- a/assets/_Game/Scripts/Environments/CumulativeBar.ts +++ b/assets/_Game/Scripts/Environments/CumulativeBar.ts @@ -42,15 +42,21 @@ export class CumulativeBar extends Component { @property({ type: Prefab, visible: true }) private _scoreObjectPrefab: Prefab; + @property({ visible: true }) + private _centerOffset: Vec3 = new Vec3(); @property({ type: CCFloat, visible: true }) private _radius: number = 0; + @property({ type: CCFloat, visible: true }) + private _minAngle: number = 0; + @property({ type: CCFloat, visible: true }) + private _maxAngle: number = 0; @property({ type: AudioClip, visible: true }) private _soundFx; @property({ type: AudioClip, visible: true }) private _collectStartSoundFx; - private _pool: ObjectPool; + private _starPool: ObjectPool; private _fxPool: ObjectPool; private _currentValue = 0; private _fillValue = 0; @@ -63,13 +69,14 @@ export class CumulativeBar extends Component { protected onLoad(): void { this._fillBar.fillRange = 0; - this._pool = new ObjectPool(this._scoreObjectPrefab, 50, true); + this._starPool = new ObjectPool(this._scoreObjectPrefab, 50, true); this._fxPool = new ObjectPool(this._starFxObjectPrefab, 50, true); EventManger.instance.on(GameEvent.Score, this.onScore, this); EventManger.instance.on(GameEvent.BoosterActive, this.onBoosterActive, this); EventManger.instance.on(GameEvent.BoosterDisable, this.onBoosterDisable, this); this._center = this._fillBar.node.getWorldPosition(); - this.calcPositionOnCircleLine(0); + this._center.add(this._centerOffset); + this.calcPositionOnCircleLine(this._minAngle); } protected update(dt: number): void { @@ -89,7 +96,7 @@ export class CumulativeBar extends Component { if (Math.abs(this._fillValue - this._fillBar.fillRange) >= 0.001) { this._fillBar.fillRange = lerp(this._fillBar.fillRange, this._fillValue, dt * 3); const progress = clamp01(this._fillBar.fillRange / -0.5); - const angle = lerp(0, 180, progress); + const angle = lerp(this._minAngle, this._maxAngle, progress); this.calcPositionOnCircleLine(angle); } } @@ -98,7 +105,7 @@ export class CumulativeBar extends Component { switch (type) { case ScoreType.DestroyObject: if (!this._active) return; - const star = this._pool.get(this.node); + const star = this._starPool.get(this.node); star.setWorldPosition(position); tween(star) .to( @@ -113,7 +120,7 @@ export class CumulativeBar extends Component { .call(async () => { const fx = this._fxPool.get(ParticleSystem, this.node); fx.node.setWorldPosition(star.worldPosition); - this._pool.release(star); + this._starPool.release(star); SoundManager.instance.playSfx(this._collectStartSoundFx); await Utilities.waitUntil(() => { return fx.isStopped; @@ -156,12 +163,13 @@ export class CumulativeBar extends Component { const time = 0.04; const offset = new Vec3(); while (items > 0) { - const obj = this._pool.get(this._scoreUI); + const obj = this._starPool.get(this._scoreUI); Vec3.random(offset, 30); offset.y = 0; obj.setWorldPosition(this.node.getWorldPosition().add(offset)); tween(obj) .to(randomRange(0.3, 0.4), { worldPosition: this._scoreUI.worldPosition }, { easing: 'sineIn' }) + .call(() => this._starPool.release(obj)) .call(() => { Tween.stopAllByTarget(this._scoreUI); tween(this._scoreUI) @@ -170,7 +178,6 @@ export class CumulativeBar extends Component { .set({ scale: Vec3.ONE }) .start(); }) - .call(() => this._pool.release(obj)) .start(); items--; SoundManager.instance.playSfx(this._soundFx, 0.5); diff --git a/assets/_Game/Scripts/UI/GameOverPanel.ts b/assets/_Game/Scripts/UI/GameOverPanel.ts index ad58e1c..02c35d4 100644 --- a/assets/_Game/Scripts/UI/GameOverPanel.ts +++ b/assets/_Game/Scripts/UI/GameOverPanel.ts @@ -124,12 +124,14 @@ export class GameOverPanel extends Component { score += x; score = score > totalScore ? totalScore : score; const obj = this._pool.get(this._scoreUI); + obj.setWorldPosition(this._scoreUI.worldPosition); tween(obj) - .to(randomRange(0.3, 0.4), { worldPosition: target }) + .to(randomRange(0.2, 0.3), { worldPosition: target }, { easing: 'sineIn' }) + .call(() => this._pool.release(obj)) .call(() => { Tween.stopAllByTarget(this.yourScore); tween(this.yourScore.node) - .to(0.1, { scale: new Vec3(1.3, 1.3, 1.3) }, { easing: 'sineIn' }) + .to(0.1, { scale: new Vec3(1.3, 1.3, 1.3) }) .call(async () => { if (i == items - 1) { this.yourScore.string = totalScore.toString(); @@ -144,7 +146,6 @@ export class GameOverPanel extends Component { .set({ scale: Vec3.ONE }) .start(); }) - .call(() => this._pool.release(obj)) .start(); SoundManager.instance.playSfx(this._soundCollectCoinFx); await Utilities.delay(time); diff --git a/assets/_Game/Scripts/UI/TutorialController.ts b/assets/_Game/Scripts/UI/TutorialController.ts index 28d7d4e..fd22820 100644 --- a/assets/_Game/Scripts/UI/TutorialController.ts +++ b/assets/_Game/Scripts/UI/TutorialController.ts @@ -17,6 +17,7 @@ export class TutorialController extends Component { private _timer = 0; private _showed = false; private _canShow = true; + private _playing = false; protected onLoad(): void { this.node.on(Input.EventType.TOUCH_START, this.onTouchStart, this); @@ -42,6 +43,7 @@ export class TutorialController extends Component { } protected update(dt: number): void { + if (!this._playing) return; this._timer += dt; if (!this._showed && this._timer > TimeConfig.Tutorial) { this._showed = true; @@ -51,8 +53,12 @@ export class TutorialController extends Component { private onGameStateChange(state: GameState) { switch (state) { + case GameState.Playing: + this._playing = true; + break; case GameState.GameOver: case GameState.End: + this._playing = false; this._canShow = false; break; default: