fix: bug 5/4

main
tiendat3699 2024-04-05 11:43:09 +07:00
parent aff88f1d3f
commit 8e082bace0
5 changed files with 37 additions and 15 deletions

View File

@ -7414,7 +7414,15 @@
"__uuid__": "35274179-f40e-4de9-a5d5-43fba9c12669", "__uuid__": "35274179-f40e-4de9-a5d5-43fba9c12669",
"__expectedType__": "cc.Prefab" "__expectedType__": "cc.Prefab"
}, },
"_radius": 380, "_centerOffset": {
"__type__": "cc.Vec3",
"x": 0,
"y": -60,
"z": 0
},
"_radius": 400,
"_minAngle": 10,
"_maxAngle": 170,
"_soundFx": { "_soundFx": {
"__uuid__": "65a023cb-b98f-4470-ba2d-4eba9fe184fe", "__uuid__": "65a023cb-b98f-4470-ba2d-4eba9fe184fe",
"__expectedType__": "cc.AudioClip" "__expectedType__": "cc.AudioClip"
@ -27552,7 +27560,7 @@
"_prefab": null, "_prefab": null,
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": -450, "x": -460,
"y": -700, "y": -700,
"z": 0 "z": 0
}, },
@ -29523,7 +29531,7 @@
"_prefab": null, "_prefab": null,
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 450, "x": 460,
"y": -700, "y": -700,
"z": 0 "z": 0
}, },

View File

@ -81,7 +81,7 @@ export default class BEConnector extends Singleton<BEConnector>('BEConnector') {
this.deviceInfo = url.get('deviceInfo'); this.deviceInfo = url.get('deviceInfo');
this.numberTicket = parseInt(url.get('numberTicket')) || 0; 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.currentScore = parseInt(url.get('currentScore')) || 0;
this.mileStone = url.get('mileStone') || ''; this.mileStone = url.get('mileStone') || '';
this.gameURL = ENV_CONFIG[url.get('env')]; this.gameURL = ENV_CONFIG[url.get('env')];

View File

@ -42,15 +42,21 @@ export class CumulativeBar extends Component {
@property({ type: Prefab, visible: true }) @property({ type: Prefab, visible: true })
private _scoreObjectPrefab: Prefab; private _scoreObjectPrefab: Prefab;
@property({ visible: true })
private _centerOffset: Vec3 = new Vec3();
@property({ type: CCFloat, visible: true }) @property({ type: CCFloat, visible: true })
private _radius: number = 0; 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 }) @property({ type: AudioClip, visible: true })
private _soundFx; private _soundFx;
@property({ type: AudioClip, visible: true }) @property({ type: AudioClip, visible: true })
private _collectStartSoundFx; private _collectStartSoundFx;
private _pool: ObjectPool; private _starPool: ObjectPool;
private _fxPool: ObjectPool; private _fxPool: ObjectPool;
private _currentValue = 0; private _currentValue = 0;
private _fillValue = 0; private _fillValue = 0;
@ -63,13 +69,14 @@ export class CumulativeBar extends Component {
protected onLoad(): void { protected onLoad(): void {
this._fillBar.fillRange = 0; 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); this._fxPool = new ObjectPool(this._starFxObjectPrefab, 50, true);
EventManger.instance.on(GameEvent.Score, this.onScore, this); EventManger.instance.on(GameEvent.Score, this.onScore, this);
EventManger.instance.on(GameEvent.BoosterActive, this.onBoosterActive, this); EventManger.instance.on(GameEvent.BoosterActive, this.onBoosterActive, this);
EventManger.instance.on(GameEvent.BoosterDisable, this.onBoosterDisable, this); EventManger.instance.on(GameEvent.BoosterDisable, this.onBoosterDisable, this);
this._center = this._fillBar.node.getWorldPosition(); this._center = this._fillBar.node.getWorldPosition();
this.calcPositionOnCircleLine(0); this._center.add(this._centerOffset);
this.calcPositionOnCircleLine(this._minAngle);
} }
protected update(dt: number): void { protected update(dt: number): void {
@ -89,7 +96,7 @@ export class CumulativeBar extends Component {
if (Math.abs(this._fillValue - this._fillBar.fillRange) >= 0.001) { if (Math.abs(this._fillValue - this._fillBar.fillRange) >= 0.001) {
this._fillBar.fillRange = lerp(this._fillBar.fillRange, this._fillValue, dt * 3); this._fillBar.fillRange = lerp(this._fillBar.fillRange, this._fillValue, dt * 3);
const progress = clamp01(this._fillBar.fillRange / -0.5); 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); this.calcPositionOnCircleLine(angle);
} }
} }
@ -98,7 +105,7 @@ export class CumulativeBar extends Component {
switch (type) { switch (type) {
case ScoreType.DestroyObject: case ScoreType.DestroyObject:
if (!this._active) return; if (!this._active) return;
const star = this._pool.get(this.node); const star = this._starPool.get(this.node);
star.setWorldPosition(position); star.setWorldPosition(position);
tween(star) tween(star)
.to( .to(
@ -113,7 +120,7 @@ export class CumulativeBar extends Component {
.call(async () => { .call(async () => {
const fx = this._fxPool.get(ParticleSystem, this.node); const fx = this._fxPool.get(ParticleSystem, this.node);
fx.node.setWorldPosition(star.worldPosition); fx.node.setWorldPosition(star.worldPosition);
this._pool.release(star); this._starPool.release(star);
SoundManager.instance.playSfx(this._collectStartSoundFx); SoundManager.instance.playSfx(this._collectStartSoundFx);
await Utilities.waitUntil(() => { await Utilities.waitUntil(() => {
return fx.isStopped; return fx.isStopped;
@ -156,12 +163,13 @@ export class CumulativeBar extends Component {
const time = 0.04; const time = 0.04;
const offset = new Vec3(); const offset = new Vec3();
while (items > 0) { while (items > 0) {
const obj = this._pool.get(this._scoreUI); const obj = this._starPool.get(this._scoreUI);
Vec3.random(offset, 30); Vec3.random(offset, 30);
offset.y = 0; offset.y = 0;
obj.setWorldPosition(this.node.getWorldPosition().add(offset)); obj.setWorldPosition(this.node.getWorldPosition().add(offset));
tween(obj) tween(obj)
.to(randomRange(0.3, 0.4), { worldPosition: this._scoreUI.worldPosition }, { easing: 'sineIn' }) .to(randomRange(0.3, 0.4), { worldPosition: this._scoreUI.worldPosition }, { easing: 'sineIn' })
.call(() => this._starPool.release(obj))
.call(() => { .call(() => {
Tween.stopAllByTarget(this._scoreUI); Tween.stopAllByTarget(this._scoreUI);
tween(this._scoreUI) tween(this._scoreUI)
@ -170,7 +178,6 @@ export class CumulativeBar extends Component {
.set({ scale: Vec3.ONE }) .set({ scale: Vec3.ONE })
.start(); .start();
}) })
.call(() => this._pool.release(obj))
.start(); .start();
items--; items--;
SoundManager.instance.playSfx(this._soundFx, 0.5); SoundManager.instance.playSfx(this._soundFx, 0.5);

View File

@ -124,12 +124,14 @@ export class GameOverPanel extends Component {
score += x; score += x;
score = score > totalScore ? totalScore : score; score = score > totalScore ? totalScore : score;
const obj = this._pool.get(this._scoreUI); const obj = this._pool.get(this._scoreUI);
obj.setWorldPosition(this._scoreUI.worldPosition);
tween(obj) 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(() => { .call(() => {
Tween.stopAllByTarget(this.yourScore); Tween.stopAllByTarget(this.yourScore);
tween(this.yourScore.node) 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 () => { .call(async () => {
if (i == items - 1) { if (i == items - 1) {
this.yourScore.string = totalScore.toString(); this.yourScore.string = totalScore.toString();
@ -144,7 +146,6 @@ export class GameOverPanel extends Component {
.set({ scale: Vec3.ONE }) .set({ scale: Vec3.ONE })
.start(); .start();
}) })
.call(() => this._pool.release(obj))
.start(); .start();
SoundManager.instance.playSfx(this._soundCollectCoinFx); SoundManager.instance.playSfx(this._soundCollectCoinFx);
await Utilities.delay(time); await Utilities.delay(time);

View File

@ -17,6 +17,7 @@ export class TutorialController extends Component {
private _timer = 0; private _timer = 0;
private _showed = false; private _showed = false;
private _canShow = true; private _canShow = true;
private _playing = false;
protected onLoad(): void { protected onLoad(): void {
this.node.on(Input.EventType.TOUCH_START, this.onTouchStart, this); this.node.on(Input.EventType.TOUCH_START, this.onTouchStart, this);
@ -42,6 +43,7 @@ export class TutorialController extends Component {
} }
protected update(dt: number): void { protected update(dt: number): void {
if (!this._playing) return;
this._timer += dt; this._timer += dt;
if (!this._showed && this._timer > TimeConfig.Tutorial) { if (!this._showed && this._timer > TimeConfig.Tutorial) {
this._showed = true; this._showed = true;
@ -51,8 +53,12 @@ export class TutorialController extends Component {
private onGameStateChange(state: GameState) { private onGameStateChange(state: GameState) {
switch (state) { switch (state) {
case GameState.Playing:
this._playing = true;
break;
case GameState.GameOver: case GameState.GameOver:
case GameState.End: case GameState.End:
this._playing = false;
this._canShow = false; this._canShow = false;
break; break;
default: default: