choke: update animation end game
parent
a29e6b62af
commit
c448991110
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
||||||
import { _decorator, AudioClip, Component, Label, Node, Prefab, randomRange, Tween, tween, Vec3 } from 'cc';
|
import { _decorator, AudioClip, Component, geometry, Label, Node, Prefab, Tween, tween, Vec2, Vec3 } from 'cc';
|
||||||
import BEConnector from '../API/BEConnector';
|
import BEConnector from '../API/BEConnector';
|
||||||
import { GameManager } from '../Manager/GameManager';
|
import { GameManager } from '../Manager/GameManager';
|
||||||
import ObjectPool from '../Pool/ObjectPool';
|
import ObjectPool from '../Pool/ObjectPool';
|
||||||
|
@ -30,6 +30,12 @@ export class GameOverPanel extends Component {
|
||||||
@property({ type: AudioClip, visible: true })
|
@property({ type: AudioClip, visible: true })
|
||||||
private _soundCollectCoinFx: AudioClip;
|
private _soundCollectCoinFx: AudioClip;
|
||||||
|
|
||||||
|
@property({ type: geometry.AnimationCurve, visible: true })
|
||||||
|
private _starSpeedCurve: geometry.AnimationCurve = new geometry.AnimationCurve();
|
||||||
|
|
||||||
|
@property({ type: geometry.AnimationCurve, visible: true })
|
||||||
|
private _starScaleCurve: geometry.AnimationCurve = new geometry.AnimationCurve();
|
||||||
|
|
||||||
private _pool: ObjectPool;
|
private _pool: ObjectPool;
|
||||||
private _active = false;
|
private _active = false;
|
||||||
private _clicked = false;
|
private _clicked = false;
|
||||||
|
@ -116,32 +122,54 @@ export class GameOverPanel extends Component {
|
||||||
items = 50;
|
items = 50;
|
||||||
x = Math.round(gameScore / items);
|
x = Math.round(gameScore / items);
|
||||||
}
|
}
|
||||||
const time = 0.04;
|
|
||||||
const totalScore = gameScore + currentScore;
|
const totalScore = gameScore + currentScore;
|
||||||
let score = currentScore;
|
let score = currentScore;
|
||||||
const target = this.yourScore.node.getWorldPosition();
|
const target = this.yourScore.node.getWorldPosition();
|
||||||
|
let duration = 0;
|
||||||
for (let i = 0; i < items; i++) {
|
for (let i = 0; i < items; i++) {
|
||||||
score += x;
|
score += x;
|
||||||
|
duration = this._starSpeedCurve.evaluate(i / items - 1);
|
||||||
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);
|
obj.setWorldPosition(this._scoreUI.worldPosition);
|
||||||
tween(obj)
|
tween(obj)
|
||||||
.to(0.3, { worldPosition: target }, { easing: 'sineIn' })
|
.to(
|
||||||
|
duration,
|
||||||
|
{ worldPosition: target },
|
||||||
|
{
|
||||||
|
easing: 'sineIn',
|
||||||
|
onUpdate: (target: Node, ratio: number) => {
|
||||||
|
const scale = this._starScaleCurve.evaluate(ratio) * 1.5;
|
||||||
|
target.setScale(new Vec3(scale, scale));
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
.call(() => this._pool.release(obj))
|
.call(() => this._pool.release(obj))
|
||||||
.call(async () => {
|
.call(async () => {
|
||||||
if (i == items - 1) {
|
if (i == items - 1) {
|
||||||
this.yourScore.string = totalScore.toString();
|
this.yourScore.string = totalScore.toString();
|
||||||
|
Tween.stopAllByTarget(this.yourScore.node);
|
||||||
|
tween(this.yourScore.node)
|
||||||
|
.set({ scale: Vec3.ONE })
|
||||||
|
.to(0.3, { scale: new Vec3(1.8, 1.8) }, { easing: 'backIn' })
|
||||||
|
.to(0.3, { scale: new Vec3(1, 1) }, { easing: 'backOut' })
|
||||||
|
.start();
|
||||||
if (this._end) {
|
if (this._end) {
|
||||||
await Utilities.delay(1);
|
await Utilities.delay(1);
|
||||||
BEConnector.instance.postScoreToServer();
|
BEConnector.instance.postScoreToServer();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Tween.stopAllByTarget(this.yourScore.node);
|
||||||
this.yourScore.string = score.toString();
|
this.yourScore.string = score.toString();
|
||||||
|
tween(this.yourScore.node)
|
||||||
|
.to(duration / 6, { scale: new Vec3(1.3, 1.3) })
|
||||||
|
.to(duration / 6, { scale: new Vec3(1, 1) })
|
||||||
|
.start();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.start();
|
.start();
|
||||||
SoundManager.instance.playSfx(this._soundCollectCoinFx);
|
SoundManager.instance.playSfx(this._soundCollectCoinFx);
|
||||||
await Utilities.delay(time);
|
await Utilities.delay(duration / 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue