feat: fix bug 4/4
parent
56d96e7a3c
commit
aff88f1d3f
|
@ -7178,7 +7178,7 @@
|
|||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 45,
|
||||
"y": -140,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
|
@ -7221,7 +7221,7 @@
|
|||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
"y": 0
|
||||
},
|
||||
"_id": "1bBEPnOg1GVqjf7uNKd3IM"
|
||||
},
|
||||
|
@ -7257,7 +7257,7 @@
|
|||
"y": 0
|
||||
},
|
||||
"_fillStart": 0.5,
|
||||
"_fillRange": -0.5,
|
||||
"_fillRange": -0.7,
|
||||
"_isTrimmedMode": true,
|
||||
"_useGrayscale": false,
|
||||
"_atlas": null,
|
||||
|
@ -7406,14 +7406,23 @@
|
|||
"_scoreUI": {
|
||||
"__id__": 211
|
||||
},
|
||||
"_starFxObjectPrefab": {
|
||||
"__uuid__": "9ae06eb1-5110-4cd8-b56d-371a29bf2fc5",
|
||||
"__expectedType__": "cc.Prefab"
|
||||
},
|
||||
"_scoreObjectPrefab": {
|
||||
"__uuid__": "35274179-f40e-4de9-a5d5-43fba9c12669",
|
||||
"__expectedType__": "cc.Prefab"
|
||||
},
|
||||
"_radius": 380,
|
||||
"_soundFx": {
|
||||
"__uuid__": "65a023cb-b98f-4470-ba2d-4eba9fe184fe",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"_collectStartSoundFx": {
|
||||
"__uuid__": "1ac12acc-dde3-4d31-9106-dfc30c030d40",
|
||||
"__expectedType__": "cc.AudioClip"
|
||||
},
|
||||
"_id": "e5qVdeXFZOu6/MatkdDEG6"
|
||||
},
|
||||
{
|
||||
|
@ -7475,7 +7484,7 @@
|
|||
"__id__": 211
|
||||
},
|
||||
{
|
||||
"__id__": 395
|
||||
"__id__": 411
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
|
@ -7661,19 +7670,19 @@
|
|||
"__id__": 214
|
||||
},
|
||||
{
|
||||
"__id__": 398
|
||||
"__id__": 395
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 410
|
||||
"__id__": 407
|
||||
},
|
||||
{
|
||||
"__id__": 411
|
||||
"__id__": 408
|
||||
},
|
||||
{
|
||||
"__id__": 412
|
||||
"__id__": 409
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
|
@ -8647,7 +8656,7 @@
|
|||
"__id__": 296
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_active": false,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 306
|
||||
|
@ -11771,8 +11780,8 @@
|
|||
"__prefab": null,
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 200,
|
||||
"height": 50
|
||||
"width": 400,
|
||||
"height": 100
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
|
@ -11803,10 +11812,10 @@
|
|||
"_string": "Tap to quit",
|
||||
"_horizontalAlign": 1,
|
||||
"_verticalAlign": 1,
|
||||
"_actualFontSize": 40,
|
||||
"_fontSize": 40,
|
||||
"_actualFontSize": 60,
|
||||
"_fontSize": 60,
|
||||
"_fontFamily": "Arial",
|
||||
"_lineHeight": 40,
|
||||
"_lineHeight": 60,
|
||||
"_overflow": 1,
|
||||
"_enableWrapText": false,
|
||||
"_font": {
|
||||
|
@ -11833,7 +11842,7 @@
|
|||
"__prefab": null,
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 250,
|
||||
"width": 400,
|
||||
"height": 100
|
||||
},
|
||||
"_anchorPoint": {
|
||||
|
@ -12081,7 +12090,7 @@
|
|||
"__id__": 382
|
||||
},
|
||||
"_scoreUI": {
|
||||
"__id__": 395
|
||||
"__id__": 211
|
||||
},
|
||||
"_scorePrefab": {
|
||||
"__uuid__": "35274179-f40e-4de9-a5d5-43fba9c12669",
|
||||
|
@ -12093,115 +12102,6 @@
|
|||
},
|
||||
"_id": "bbcyvzebBDsJfOOH9VNeON"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Score",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 212
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 396
|
||||
},
|
||||
{
|
||||
"__id__": 397
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": -34.66799999999999,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
"__type__": "cc.Quat",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"_lscale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"z": 1
|
||||
},
|
||||
"_mobility": 0,
|
||||
"_layer": 33554432,
|
||||
"_euler": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_id": "744OsjVN1AnaYr+1LWPe+M"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 395
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 146.391,
|
||||
"height": 70
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0.5
|
||||
},
|
||||
"_id": "e38Vc4/9NI+o6RKyCrAcRF"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 395
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
"_dstBlendFactor": 4,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_string": "9999",
|
||||
"_horizontalAlign": 1,
|
||||
"_verticalAlign": 1,
|
||||
"_actualFontSize": 61,
|
||||
"_fontSize": 60,
|
||||
"_fontFamily": "Arial",
|
||||
"_lineHeight": 40,
|
||||
"_overflow": 2,
|
||||
"_enableWrapText": true,
|
||||
"_font": {
|
||||
"__uuid__": "4eb60b5b-72b8-497c-b499-d7921c9b84db",
|
||||
"__expectedType__": "cc.TTFFont"
|
||||
},
|
||||
"_isSystemFontUsed": false,
|
||||
"_spacingX": 0,
|
||||
"_isItalic": false,
|
||||
"_isBold": false,
|
||||
"_isUnderline": false,
|
||||
"_underlineHeight": 2,
|
||||
"_cacheMode": 0,
|
||||
"_id": "f5byB1+jNCNqjN+Tt3NUoI"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "StartPanel",
|
||||
|
@ -12211,19 +12111,19 @@
|
|||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 399
|
||||
"__id__": 396
|
||||
}
|
||||
],
|
||||
"_active": false,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 407
|
||||
"__id__": 404
|
||||
},
|
||||
{
|
||||
"__id__": 408
|
||||
"__id__": 405
|
||||
},
|
||||
{
|
||||
"__id__": 409
|
||||
"__id__": 406
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
|
@ -12261,23 +12161,23 @@
|
|||
"_name": "StartButton",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 398
|
||||
"__id__": 395
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 400
|
||||
"__id__": 397
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 403
|
||||
"__id__": 400
|
||||
},
|
||||
{
|
||||
"__id__": 404
|
||||
"__id__": 401
|
||||
},
|
||||
{
|
||||
"__id__": 405
|
||||
"__id__": 402
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
|
@ -12315,16 +12215,16 @@
|
|||
"_name": "Start",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 399
|
||||
"__id__": 396
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 401
|
||||
"__id__": 398
|
||||
},
|
||||
{
|
||||
"__id__": 402
|
||||
"__id__": 399
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
|
@ -12362,7 +12262,7 @@
|
|||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 400
|
||||
"__id__": 397
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
|
@ -12383,7 +12283,7 @@
|
|||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 400
|
||||
"__id__": 397
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
|
@ -12424,7 +12324,7 @@
|
|||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 399
|
||||
"__id__": 396
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
|
@ -12445,7 +12345,7 @@
|
|||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 399
|
||||
"__id__": 396
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
|
@ -12483,13 +12383,13 @@
|
|||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 399
|
||||
"__id__": 396
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 406
|
||||
"__id__": 403
|
||||
}
|
||||
],
|
||||
"_interactable": true,
|
||||
|
@ -12529,7 +12429,7 @@
|
|||
"_duration": 0.1,
|
||||
"_zoomScale": 1.2,
|
||||
"_target": {
|
||||
"__id__": 399
|
||||
"__id__": 396
|
||||
},
|
||||
"_id": "b5HEsyyjZJ8Yb2u2q1fD82"
|
||||
},
|
||||
|
@ -12548,7 +12448,7 @@
|
|||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 398
|
||||
"__id__": 395
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
|
@ -12569,7 +12469,7 @@
|
|||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 398
|
||||
"__id__": 395
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
|
@ -12607,7 +12507,7 @@
|
|||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 398
|
||||
"__id__": 395
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
|
@ -12691,7 +12591,7 @@
|
|||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"_scoreLabel": {
|
||||
"__id__": 397
|
||||
"__id__": 410
|
||||
},
|
||||
"_ticketLabel": {
|
||||
"__id__": 413
|
||||
|
@ -12703,17 +12603,126 @@
|
|||
"__id__": 314
|
||||
},
|
||||
"_buffFx": null,
|
||||
"_tutorialPanel": {
|
||||
"__id__": 296
|
||||
"_controlPanel": {
|
||||
"__id__": 289
|
||||
},
|
||||
"_startPanel": {
|
||||
"__id__": 398
|
||||
"__id__": 395
|
||||
},
|
||||
"_overPanel": {
|
||||
"__id__": 317
|
||||
},
|
||||
"_id": "449hzGcyZL+Lsj/r1gnEMe"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 411
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"_customMaterial": null,
|
||||
"_srcBlendFactor": 2,
|
||||
"_dstBlendFactor": 4,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_string": "9999",
|
||||
"_horizontalAlign": 1,
|
||||
"_verticalAlign": 1,
|
||||
"_actualFontSize": 61,
|
||||
"_fontSize": 60,
|
||||
"_fontFamily": "Arial",
|
||||
"_lineHeight": 40,
|
||||
"_overflow": 2,
|
||||
"_enableWrapText": true,
|
||||
"_font": {
|
||||
"__uuid__": "4eb60b5b-72b8-497c-b499-d7921c9b84db",
|
||||
"__expectedType__": "cc.TTFFont"
|
||||
},
|
||||
"_isSystemFontUsed": false,
|
||||
"_spacingX": 0,
|
||||
"_isItalic": false,
|
||||
"_isBold": false,
|
||||
"_isUnderline": false,
|
||||
"_underlineHeight": 2,
|
||||
"_cacheMode": 0,
|
||||
"_id": "f5byB1+jNCNqjN+Tt3NUoI"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Score",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 212
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 412
|
||||
},
|
||||
{
|
||||
"__id__": 410
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_lpos": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": -34.66799999999999,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_lrot": {
|
||||
"__type__": "cc.Quat",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0,
|
||||
"w": 1
|
||||
},
|
||||
"_lscale": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"z": 1
|
||||
},
|
||||
"_mobility": 0,
|
||||
"_layer": 33554432,
|
||||
"_euler": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_id": "744OsjVN1AnaYr+1LWPe+M"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 411
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 146.391,
|
||||
"height": 70
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0.5
|
||||
},
|
||||
"_id": "e38Vc4/9NI+o6RKyCrAcRF"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
"_name": "",
|
||||
|
@ -31753,7 +31762,7 @@
|
|||
{
|
||||
"__type__": "cc.TargetOverrideInfo",
|
||||
"source": {
|
||||
"__id__": 412
|
||||
"__id__": 409
|
||||
},
|
||||
"sourceInfo": null,
|
||||
"propertyPath": [
|
||||
|
|
|
@ -13,20 +13,19 @@ export class BoosterBase extends Component implements IPoolable {
|
|||
protected _collider: Collider2D;
|
||||
@property({ type: Animation, visible: true })
|
||||
private _animation: Animation;
|
||||
@property({ type: AudioClip, visible: true })
|
||||
private _collectSound: AudioClip;
|
||||
|
||||
@property(CCFloat)
|
||||
protected time: number = 10;
|
||||
|
||||
protected onLoad(): void {
|
||||
this._collider.on(Contact2DType.BEGIN_CONTACT, this.onContactBegin, this);
|
||||
this._collider.enabled = false;
|
||||
}
|
||||
|
||||
private onContactBegin(self: Collider2D, other: Collider2D) {
|
||||
this.boosterActive();
|
||||
this._collider.enabled = false;
|
||||
EventManger.instance.emit(GameEvent.ObjectRelease, this.node);
|
||||
SoundManager.instance.playSfx(this._collectSound);
|
||||
ObjectPool.release(this.node);
|
||||
}
|
||||
|
||||
|
@ -37,5 +36,7 @@ export class BoosterBase extends Component implements IPoolable {
|
|||
await Utilities.delay(this._animation.defaultClip.duration);
|
||||
this._collider.enabled = true;
|
||||
}
|
||||
onRelease() {}
|
||||
onRelease() {
|
||||
this._collider.enabled = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,11 @@ import {
|
|||
Vec3,
|
||||
Label,
|
||||
AudioClip,
|
||||
randomRange,
|
||||
math,
|
||||
CCFloat,
|
||||
clamp01,
|
||||
ParticleSystem,
|
||||
} from 'cc';
|
||||
import { EventManger } from '../Manager/EventManger';
|
||||
import GameEvent from '../Events/GameEvent';
|
||||
|
@ -31,26 +36,40 @@ export class CumulativeBar extends Component {
|
|||
private _maxValue = 1000;
|
||||
@property({ type: Node, visible: true })
|
||||
private _scoreUI: Node;
|
||||
|
||||
@property({ type: Prefab, visible: true })
|
||||
private _starFxObjectPrefab: Prefab;
|
||||
@property({ type: Prefab, visible: true })
|
||||
private _scoreObjectPrefab: Prefab;
|
||||
|
||||
@property({ type: CCFloat, visible: true })
|
||||
private _radius: number = 0;
|
||||
|
||||
@property({ type: AudioClip, visible: true })
|
||||
private _soundFx;
|
||||
@property({ type: AudioClip, visible: true })
|
||||
private _collectStartSoundFx;
|
||||
|
||||
private _pool: ObjectPool;
|
||||
private _fxPool: ObjectPool;
|
||||
private _currentValue = 0;
|
||||
private _fillValue = 0;
|
||||
private _active = false;
|
||||
private _goal = false;
|
||||
private _timer = 0;
|
||||
private _multiplier = 1;
|
||||
private _currentValuePosition = new Vec3();
|
||||
private _center = new Vec3();
|
||||
|
||||
protected onLoad(): void {
|
||||
this._fillBar.fillRange = 0;
|
||||
this._pool = 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);
|
||||
}
|
||||
|
||||
protected update(dt: number): void {
|
||||
|
@ -69,18 +88,46 @@ 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);
|
||||
this.calcPositionOnCircleLine(angle);
|
||||
}
|
||||
}
|
||||
|
||||
private async onScore(score: number, points: number, type: ScoreType) {
|
||||
private async onScore(score: number, points: number, type: ScoreType, position: Vec3) {
|
||||
switch (type) {
|
||||
case ScoreType.DestroyObject:
|
||||
if (!this._active) return;
|
||||
const star = this._pool.get(this.node);
|
||||
star.setWorldPosition(position);
|
||||
tween(star)
|
||||
.to(
|
||||
1,
|
||||
{ worldPosition: this._currentValuePosition },
|
||||
{
|
||||
onUpdate: (target: Node, ratio: number) => {
|
||||
target.worldPosition = target.worldPosition.lerp(this._currentValuePosition, ratio);
|
||||
},
|
||||
},
|
||||
)
|
||||
.call(async () => {
|
||||
const fx = this._fxPool.get(ParticleSystem, this.node);
|
||||
fx.node.setWorldPosition(star.worldPosition);
|
||||
this._pool.release(star);
|
||||
SoundManager.instance.playSfx(this._collectStartSoundFx);
|
||||
await Utilities.waitUntil(() => {
|
||||
return fx.isStopped;
|
||||
}, 0.1);
|
||||
this._fxPool.release(fx);
|
||||
})
|
||||
.start();
|
||||
|
||||
this._multiplier++;
|
||||
this._currentValue += points * this._multiplier;
|
||||
if (this._currentValue > this._maxValue) this._currentValue = this._maxValue;
|
||||
break;
|
||||
|
||||
if (this._currentValue > this._maxValue) this._currentValue = this._maxValue;
|
||||
|
||||
break;
|
||||
case ScoreType.Goal:
|
||||
if (this._currentValue == 0) return;
|
||||
this._multiplier = 0;
|
||||
|
@ -107,11 +154,14 @@ export class CumulativeBar extends Component {
|
|||
|
||||
private async playCollectEffect(items: number) {
|
||||
const time = 0.04;
|
||||
const offset = new Vec3();
|
||||
while (items > 0) {
|
||||
const obj = this._pool.get(this._scoreUI);
|
||||
obj.setWorldPosition(this.node.worldPosition);
|
||||
Vec3.random(offset, 30);
|
||||
offset.y = 0;
|
||||
obj.setWorldPosition(this.node.getWorldPosition().add(offset));
|
||||
tween(obj)
|
||||
.to(0.4, { worldPosition: this._scoreUI.worldPosition })
|
||||
.to(randomRange(0.3, 0.4), { worldPosition: this._scoreUI.worldPosition }, { easing: 'sineIn' })
|
||||
.call(() => {
|
||||
Tween.stopAllByTarget(this._scoreUI);
|
||||
tween(this._scoreUI)
|
||||
|
@ -120,17 +170,23 @@ export class CumulativeBar extends Component {
|
|||
.set({ scale: Vec3.ONE })
|
||||
.start();
|
||||
})
|
||||
.call(() => ObjectPool.release(obj))
|
||||
.call(() => this._pool.release(obj))
|
||||
.start();
|
||||
items--;
|
||||
SoundManager.instance.playSfx(this._soundFx);
|
||||
SoundManager.instance.playSfx(this._soundFx, 0.5);
|
||||
await Utilities.delay(time);
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
private onBoosterActive(type: BoosterType) {
|
||||
if (type == BoosterType.CumulativeBar) this._active = true;
|
||||
}
|
||||
|
||||
private onBoosterDisable(type: BoosterType) {
|
||||
if (type == BoosterType.CumulativeBar) {
|
||||
this._multiplier = 0;
|
||||
|
|
|
@ -45,6 +45,7 @@ export class ScoreObject extends Component implements IPoolable {
|
|||
protected onLoad(): void {
|
||||
this._collider.on(Contact2DType.BEGIN_CONTACT, this.onContactBegin, this);
|
||||
this._originColor = this._sprite.color.clone();
|
||||
this._collider.enabled = false;
|
||||
}
|
||||
|
||||
protected update(dt: number): void {
|
||||
|
@ -94,6 +95,7 @@ export class ScoreObject extends Component implements IPoolable {
|
|||
|
||||
public onRelease() {
|
||||
this._isHit = false;
|
||||
this._collider.enabled = false;
|
||||
this.node.angle = 0;
|
||||
this.node.setScale(Vec3.ONE);
|
||||
this._sprite.color = this._originColor;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Node } from 'cc';
|
||||
import { Node, Vec3 } from 'cc';
|
||||
import GameState from '../Enum/GameState';
|
||||
import ScoreType from '../Enum/ScoreType';
|
||||
import BoosterType from '../Enum/BoosterType';
|
||||
|
@ -18,7 +18,7 @@ enum GameEvent {
|
|||
}
|
||||
|
||||
export interface GameEventCallbackMap {
|
||||
[GameEvent.Score]: (score: number, points?: number, type?: ScoreType) => void;
|
||||
[GameEvent.Score]: (score: number, points?: number, type?: ScoreType, position?: Vec3) => void;
|
||||
[GameEvent.BallOut]: () => void;
|
||||
[GameEvent.MultiBall]: (active: boolean) => void;
|
||||
[GameEvent.TimeUpdate]: (time: number) => void;
|
||||
|
@ -31,7 +31,7 @@ export interface GameEventCallbackMap {
|
|||
}
|
||||
|
||||
export interface GameEventArgMap {
|
||||
[GameEvent.Score]: [number, number, ScoreType];
|
||||
[GameEvent.Score]: [number, number, ScoreType, Vec3];
|
||||
[GameEvent.BallOut]: null;
|
||||
[GameEvent.MultiBall]: boolean;
|
||||
[GameEvent.TimeUpdate]: number;
|
||||
|
|
|
@ -161,7 +161,7 @@ export class GameManager extends Singleton<GameManager>() {
|
|||
this._score += score;
|
||||
const floatingScore = this._FloatingScorePool.get(FloatingText, this._floatingTextContainer);
|
||||
floatingScore.show(`+${score}`, position, score >= 100 ? opts.scaleMax : opts.scaleMin, opts.duration);
|
||||
EventManger.instance.emit(GameEvent.Score, [this._score, score, type]);
|
||||
EventManger.instance.emit(GameEvent.Score, [this._score, score, type, position]);
|
||||
}
|
||||
|
||||
private async countTime() {
|
||||
|
@ -312,7 +312,6 @@ export class GameManager extends Singleton<GameManager>() {
|
|||
}
|
||||
this._boostersActive.push(new Booster(type, time));
|
||||
EventManger.instance.emit(GameEvent.BoosterActive, type);
|
||||
await Utilities.delay(0.2);
|
||||
SoundManager.instance.playSfx(this._boosterActiveSound);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { Component, Node } from 'cc';
|
||||
|
||||
export default function Singleton<T>(component?: string) {
|
||||
export default function Singleton<T>(componentName?: string) {
|
||||
class Singleton extends Component {
|
||||
//singleton
|
||||
private static _instance: T = null;
|
||||
public static get instance(): T {
|
||||
if (component && !Singleton._instance) {
|
||||
Singleton._instance = new Node(component).addComponent(component) as T;
|
||||
if (componentName && !Singleton._instance) {
|
||||
Singleton._instance = new Node(componentName).addComponent(componentName) as T;
|
||||
}
|
||||
return Singleton._instance;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { _decorator, AudioClip, Component, Label, Node, Prefab, Tween, tween, Vec3 } from 'cc';
|
||||
import { _decorator, AudioClip, Component, Label, Node, Prefab, randomRange, Tween, tween, Vec3 } from 'cc';
|
||||
import BEConnector from '../API/BEConnector';
|
||||
import { GameManager } from '../Manager/GameManager';
|
||||
import ObjectPool from '../Pool/ObjectPool';
|
||||
|
@ -117,20 +117,22 @@ export class GameOverPanel extends Component {
|
|||
x = Math.round(gameScore / items);
|
||||
}
|
||||
const time = 0.04;
|
||||
const totalScore = gameScore + currentScore;
|
||||
let score = currentScore;
|
||||
const target = this.yourScore.node.getWorldPosition();
|
||||
for (let i = 0; i < items; i++) {
|
||||
score += x;
|
||||
score = score > totalScore ? totalScore : score;
|
||||
const obj = this._pool.get(this._scoreUI);
|
||||
obj.setWorldPosition(this._scoreUI.worldPosition);
|
||||
tween(obj)
|
||||
.to(0.3, { worldPosition: this.yourScore.node.worldPosition })
|
||||
.to(randomRange(0.3, 0.4), { worldPosition: target })
|
||||
.call(() => {
|
||||
Tween.stopAllByTarget(this.yourScore);
|
||||
tween(this.yourScore.node)
|
||||
.to(0.1, { scale: new Vec3(1.3, 1.3, 1.3) })
|
||||
.to(0.1, { scale: new Vec3(1.3, 1.3, 1.3) }, { easing: 'sineIn' })
|
||||
.call(async () => {
|
||||
if (i == items - 1) {
|
||||
this.yourScore.string = (gameScore + BEConnector.instance.currentScore).toString();
|
||||
this.yourScore.string = totalScore.toString();
|
||||
if (this._end) {
|
||||
await Utilities.delay(1);
|
||||
BEConnector.instance.postScoreToServer(gameScore);
|
||||
|
@ -142,7 +144,7 @@ export class GameOverPanel extends Component {
|
|||
.set({ scale: Vec3.ONE })
|
||||
.start();
|
||||
})
|
||||
.call(() => ObjectPool.release(obj))
|
||||
.call(() => this._pool.release(obj))
|
||||
.start();
|
||||
SoundManager.instance.playSfx(this._soundCollectCoinFx);
|
||||
await Utilities.delay(time);
|
||||
|
|
|
@ -23,7 +23,7 @@ export class UIController extends Component {
|
|||
private _buffFx: ParticleSystem;
|
||||
|
||||
@property({ type: Node, visible: true })
|
||||
private _tutorialPanel: Node;
|
||||
private _controlPanel: Node;
|
||||
@property({ type: Node, visible: true })
|
||||
private _startPanel: Node;
|
||||
@property({ type: Node, visible: true })
|
||||
|
@ -84,7 +84,7 @@ export class UIController extends Component {
|
|||
this._timeLabel.string = this.secondsToTime(GameManager.instance.gameTime);
|
||||
break;
|
||||
case GameState.Ready:
|
||||
this._tutorialPanel.active = true;
|
||||
this._controlPanel.active = true;
|
||||
this._startPanel.active = false;
|
||||
break;
|
||||
case GameState.Playing:
|
||||
|
@ -93,13 +93,13 @@ export class UIController extends Component {
|
|||
|
||||
break;
|
||||
case GameState.GameOver:
|
||||
this.showEventLabel('TIME UP!!!');
|
||||
this.showEventLabel('TIME UP!!!', new Color('#ed3a18'), Color.WHITE);
|
||||
await Utilities.delay(1.2);
|
||||
this._buffFx.stop();
|
||||
this._overPanel.active = true;
|
||||
break;
|
||||
case GameState.End:
|
||||
this.showEventLabel('TIME UP!!!');
|
||||
this.showEventLabel('TIME UP!!!', new Color('#ed3a18'), Color.WHITE);
|
||||
await Utilities.delay(1.2);
|
||||
this._overPanel.active = true;
|
||||
break;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "68aadf41-730b-4e02-a9cc-740c2d015d56@6c48a",
|
||||
"displayName": "Goal",
|
||||
"displayName": "goal",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
|
@ -35,7 +35,7 @@
|
|||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "68aadf41-730b-4e02-a9cc-740c2d015d56@f9941",
|
||||
"displayName": "Goal",
|
||||
"displayName": "goal",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "8076f9a3-f994-4d23-96ef-cdeb3bea2c13@6c48a",
|
||||
"displayName": "Slingshot",
|
||||
"displayName": "slingshot",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
|
@ -35,7 +35,7 @@
|
|||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "8076f9a3-f994-4d23-96ef-cdeb3bea2c13@f9941",
|
||||
"displayName": "Slingshot",
|
||||
"displayName": "slingshot",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "4996d2f0-34aa-4c6f-a5c2-eadc7c0eeda4@6c48a",
|
||||
"displayName": "Wall",
|
||||
"displayName": "wall",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
|
@ -35,7 +35,7 @@
|
|||
"f9941": {
|
||||
"importer": "sprite-frame",
|
||||
"uuid": "4996d2f0-34aa-4c6f-a5c2-eadc7c0eeda4@f9941",
|
||||
"displayName": "Wall",
|
||||
"displayName": "wall",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"ver": "1.1.43",
|
||||
"importer": "prefab",
|
||||
"imported": true,
|
||||
"uuid": "9ae06eb1-5110-4cd8-b56d-371a29bf2fc5",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"syncNodeName": "StartCollectFx"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue