feat: reward high score
parent
4b33f28733
commit
f5b376c67e
|
@ -64,16 +64,16 @@
|
|||
{
|
||||
"__type__": "cc.ObjectCurve",
|
||||
"_times": [
|
||||
0.15,
|
||||
0,
|
||||
0.16666666666666666
|
||||
],
|
||||
"_values": [
|
||||
{
|
||||
"__uuid__": "c60afd72-3284-4d02-a2fa-f70904bfd53a@f9941",
|
||||
"__uuid__": "95489261-c577-4a5b-b584-079a3221c1d2@f9941",
|
||||
"__expectedType__": "cc.SpriteFrame"
|
||||
},
|
||||
{
|
||||
"__uuid__": "95489261-c577-4a5b-b584-079a3221c1d2@f9941",
|
||||
"__uuid__": "c60afd72-3284-4d02-a2fa-f70904bfd53a@f9941",
|
||||
"__expectedType__": "cc.SpriteFrame"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -342,10 +342,6 @@
|
|||
},
|
||||
"playOnLoad": false,
|
||||
"_clips": [
|
||||
{
|
||||
"__uuid__": "cfd9afd6-9345-446c-bf56-b7ac3dbf2c1e",
|
||||
"__expectedType__": "cc.AnimationClip"
|
||||
},
|
||||
{
|
||||
"__uuid__": "a5dad1d5-e43f-440c-aede-0959b5c632f1",
|
||||
"__expectedType__": "cc.AnimationClip"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -27,6 +27,22 @@ import ObjectPool from '../Pool/ObjectPool';
|
|||
import { SoundManager } from '../Manager/SoundManager';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('Reward')
|
||||
class Reward {
|
||||
@property(CCInteger)
|
||||
public scoreMin: number = 0;
|
||||
@property(CCInteger)
|
||||
public scoreMax: number = 0;
|
||||
@property(Prefab)
|
||||
public rewardEffect: Prefab;
|
||||
|
||||
public pool: ObjectPool;
|
||||
|
||||
Init() {
|
||||
this.pool = new ObjectPool(this.rewardEffect, 5, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ccclass('CumulativeBar')
|
||||
export class CumulativeBar extends Component {
|
||||
@property({ type: Sprite, visible: true })
|
||||
|
@ -55,6 +71,9 @@ export class CumulativeBar extends Component {
|
|||
@property({ type: AudioClip, visible: true })
|
||||
private _collectStartSoundFx;
|
||||
|
||||
@property({ type: Reward, visible: true })
|
||||
private _rewards: Reward[] = [];
|
||||
|
||||
private _starPool: ObjectPool;
|
||||
private _fxPool: ObjectPool;
|
||||
private _currentValue = 0;
|
||||
|
@ -76,6 +95,8 @@ export class CumulativeBar extends Component {
|
|||
this._center = this._fillBar.node.getWorldPosition();
|
||||
this._center.add(this._centerOffset);
|
||||
this.calcPositionOnCircleLine(this._minAngle);
|
||||
|
||||
this._rewards.forEach((reward) => reward.Init());
|
||||
}
|
||||
|
||||
protected update(dt: number): void {
|
||||
|
@ -138,19 +159,8 @@ export class CumulativeBar extends Component {
|
|||
if (this._currentValue == 0) return;
|
||||
this._multiplier = 0;
|
||||
this._goal = true;
|
||||
await Utilities.delay(1);
|
||||
GameManager.instance.addScore(
|
||||
Math.round(this._currentValue),
|
||||
ScoreType.Combo,
|
||||
this.node.getWorldPosition(),
|
||||
{
|
||||
scaleMin: 2,
|
||||
scaleMax: 4,
|
||||
duration: 1,
|
||||
},
|
||||
);
|
||||
let items = Math.ceil(this._currentValue / 10);
|
||||
this.playCollectEffect(items);
|
||||
this.playCollectEffect(items, this._currentValue);
|
||||
this._goal = false;
|
||||
this._currentValue = 0;
|
||||
break;
|
||||
|
@ -158,10 +168,11 @@ export class CumulativeBar extends Component {
|
|||
this._fillValue = -clamp(this._currentValue / 2 / this._maxValue, 0, 0.5);
|
||||
}
|
||||
|
||||
private async playCollectEffect(items: number) {
|
||||
private async playCollectEffect(items: number, score: number) {
|
||||
const time = 0.04;
|
||||
const offset = new Vec3();
|
||||
while (items > 0) {
|
||||
|
||||
for (let i = 0; i < items; i++) {
|
||||
const obj = this._starPool.get(this._scoreUI);
|
||||
Vec3.random(offset, 30);
|
||||
offset.y = 0;
|
||||
|
@ -173,15 +184,39 @@ export class CumulativeBar extends Component {
|
|||
Tween.stopAllByTarget(this._scoreUI);
|
||||
tween(this._scoreUI)
|
||||
.set({ scale: Vec3.ONE })
|
||||
.to(0.1, { scale: new Vec3(1.2, 1.2, 1.2) })
|
||||
.set({ scale: Vec3.ONE })
|
||||
.to(0.1, { scale: new Vec3(1.3, 1.3, 1.3) })
|
||||
.to(0.1, { scale: Vec3.ONE })
|
||||
.start();
|
||||
})
|
||||
.start();
|
||||
items--;
|
||||
SoundManager.instance.playSfx(this._soundFx, 0.5);
|
||||
await Utilities.delay(time);
|
||||
}
|
||||
await Utilities.waitUntil(() => this._starPool.countActive == 0);
|
||||
SoundManager.instance.playSfx(this._soundFx, 0.5);
|
||||
GameManager.instance.addScore(Math.round(score), ScoreType.Combo, this.node.getWorldPosition(), {
|
||||
scaleMin: 2,
|
||||
scaleMax: 4,
|
||||
duration: 1,
|
||||
});
|
||||
await Utilities.delay(1);
|
||||
this.calcReward(score);
|
||||
}
|
||||
|
||||
private async calcReward(score: number) {
|
||||
let selectReward: Reward;
|
||||
for (let i = 0; i < this._rewards.length; i++) {
|
||||
const reward = this._rewards[i];
|
||||
if (score >= reward.scoreMin && score <= reward.scoreMax) {
|
||||
selectReward = reward;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (selectReward) {
|
||||
const fx = selectReward.pool.get(ParticleSystem, GameManager.instance.topContainer);
|
||||
fx.node.setWorldPosition(this.node.worldPosition);
|
||||
await Utilities.waitUntil(() => fx.isStopped);
|
||||
selectReward.pool.release(fx);
|
||||
}
|
||||
}
|
||||
|
||||
private calcPositionOnCircleLine(angle: number) {
|
||||
|
|
|
@ -77,8 +77,13 @@ export class Ball extends Component implements IPoolable {
|
|||
public eventGoal = new EventTarget();
|
||||
|
||||
public init(boosterActive: boolean) {
|
||||
if (boosterActive) this._fireParticle.play();
|
||||
else this._fireParticle.stop();
|
||||
if (boosterActive) {
|
||||
this._cheeseModeSprite.node.active = true;
|
||||
this._normalSprite.node.active = false;
|
||||
} else {
|
||||
this._cheeseModeSprite.node.active = false;
|
||||
this._normalSprite.node.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected onLoad(): void {
|
||||
|
@ -122,6 +127,21 @@ export class Ball extends Component implements IPoolable {
|
|||
}
|
||||
}
|
||||
|
||||
protected lateUpdate(dt: number): void {
|
||||
if (this._rigidBody.linearVelocity.length() > 60) {
|
||||
this._fireParticle.rateOverTime.constant = 8;
|
||||
this._fireParticle.rateOverDistance.constant = 0.02;
|
||||
// if (this._fireParticle.isStopped) {
|
||||
// }
|
||||
} else {
|
||||
this._fireParticle.rateOverDistance.constant = 0;
|
||||
this._fireParticle.rateOverTime.constant = 0;
|
||||
// if (this._fireParticle.isPlaying) {
|
||||
// this._fireParticle.stopEmitting();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private async onBeginContact(
|
||||
selfCollider: Collider2D,
|
||||
otherCollider: Collider2D,
|
||||
|
@ -171,15 +191,6 @@ export class Ball extends Component implements IPoolable {
|
|||
|
||||
private afterPhysicUpdate() {
|
||||
let velocity = this._rigidBody.linearVelocity.length();
|
||||
if (velocity > 30) {
|
||||
if (this._fireParticle.isStopped) {
|
||||
this._fireParticle.play();
|
||||
}
|
||||
} else {
|
||||
if (this._fireParticle.isPlaying) {
|
||||
this._fireParticle.stopEmitting();
|
||||
}
|
||||
}
|
||||
|
||||
if (velocity > this._maxSpeed) {
|
||||
this._rigidBody.linearVelocity = this._rigidBody.linearVelocity.normalize().multiplyScalar(this._maxSpeed);
|
||||
|
@ -217,6 +228,8 @@ export class Ball extends Component implements IPoolable {
|
|||
this._isHit = false;
|
||||
this._rigidBody.enabled = true;
|
||||
this._parent = this.node.getParent();
|
||||
this._fireParticle.rateOverDistance.constant = 0;
|
||||
this._fireParticle.rateOverTime.constant = 0;
|
||||
}
|
||||
|
||||
onRelease() {
|
||||
|
|
|
@ -59,7 +59,7 @@ export class GameManager extends Singleton<GameManager>() {
|
|||
@property({ type: Prefab, visible: true })
|
||||
private _floatingScoreText: Prefab;
|
||||
@property({ type: Node, visible: true })
|
||||
private _floatingTextContainer: Node;
|
||||
private _topContainer: Node;
|
||||
@property({ type: Node, visible: true })
|
||||
private _ballHolder: Node;
|
||||
@property({ visible: true })
|
||||
|
@ -93,6 +93,10 @@ export class GameManager extends Singleton<GameManager>() {
|
|||
private _warningTime = false;
|
||||
private _currentBallInGame = 0;
|
||||
|
||||
public get topContainer() {
|
||||
return this._topContainer;
|
||||
}
|
||||
|
||||
public get score() {
|
||||
return this._score;
|
||||
}
|
||||
|
@ -163,7 +167,7 @@ export class GameManager extends Singleton<GameManager>() {
|
|||
opts: { scaleMin: number; scaleMax: number; duration: number },
|
||||
) {
|
||||
this._score += score;
|
||||
const floatingScore = this._FloatingScorePool.get(FloatingText, this._floatingTextContainer);
|
||||
const floatingScore = this._FloatingScorePool.get(FloatingText, this._topContainer);
|
||||
floatingScore.show(`+${score}`, position, score >= 100 ? opts.scaleMax : opts.scaleMin, opts.duration);
|
||||
EventManger.instance.emit(GameEvent.Score, [this._score, score, type, position]);
|
||||
}
|
||||
|
@ -262,7 +266,7 @@ export class GameManager extends Singleton<GameManager>() {
|
|||
}
|
||||
if (bonusTime) {
|
||||
this.addTime(bonusTime);
|
||||
const floatingScore = this._FloatingScorePool.get(FloatingText, this._floatingTextContainer);
|
||||
const floatingScore = this._FloatingScorePool.get(FloatingText, this._topContainer);
|
||||
floatingScore.show(`+${bonusTime}`, position, 1.5, 1, this._clockIcon);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,9 @@ export class StickerManager extends Singleton<StickerManager>() {
|
|||
this._popup.setScale(Vec3.ZERO);
|
||||
}
|
||||
|
||||
public Show(stickerName: string) {
|
||||
public Show(stickerName: string, position: Vec3 = Vec3.ZERO) {
|
||||
let sticker = this._stickers.find((s) => s.Name == stickerName);
|
||||
this._popup.setPosition(position);
|
||||
this._popup.getComponent(Sprite).spriteFrame = sticker.SpriteFrame;
|
||||
tween(this._popup)
|
||||
.set({ scale: Vec3.ZERO })
|
||||
|
|
|
@ -55,8 +55,13 @@ export class TimeUI extends Component {
|
|||
if (warning) {
|
||||
this._fill.color = Color.RED;
|
||||
tween(this._timeIcon)
|
||||
.to(0.2, { scale: new Vec3(1.2, 1.2, 1.2) })
|
||||
.to(0.2, { scale: Vec3.ONE })
|
||||
.to(0.05, { position: new Vec3(3.117, 3.177) })
|
||||
.to(0.08, { scale: new Vec3(0.9, 1.1) })
|
||||
.to(0.12, { position: new Vec3(1.559, 1.559) })
|
||||
.to(0.17, {
|
||||
scale: new Vec3(1, 1, 1),
|
||||
position: new Vec3(1.559, -0.803),
|
||||
})
|
||||
.union()
|
||||
.repeatForever()
|
||||
.start();
|
||||
|
|
|
@ -41,7 +41,7 @@ export class UIController extends Component {
|
|||
private async onScore(score: number, points: number, type: ScoreType) {
|
||||
this._scoreLabel.string = score.toString();
|
||||
if (type == ScoreType.Goal) {
|
||||
StickerManager.instance.Show('Goal');
|
||||
StickerManager.instance.Show('Goal', new Vec3(0, 700));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue