-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoreVisualizationSystem.ts
More file actions
99 lines (83 loc) · 2.68 KB
/
Copy pathScoreVisualizationSystem.ts
File metadata and controls
99 lines (83 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { Entity, World, Vector3Like, RigidBodyType, PlayerEntity } from 'hytopia';
/**
* Score Visualization System - Creates floating score numbers and visual feedback
*/
export class ScoreVisualizationSystem {
private static _instance: ScoreVisualizationSystem;
private _world: World | null = null;
private _floatingNumbers: Set<Entity> = new Set();
private constructor() {}
/**
* Get the singleton instance
*/
public static getInstance(): ScoreVisualizationSystem {
if (!ScoreVisualizationSystem._instance) {
ScoreVisualizationSystem._instance = new ScoreVisualizationSystem();
}
return ScoreVisualizationSystem._instance;
}
/**
* Initialize the system with a world instance
*/
public initialize(world: World): void {
this._world = world;
}
/**
* Create a floating score number
*/
public createFloatingScore(
position: Vector3Like,
score: number,
type: 'correct' | 'wrong' | 'bonus' | 'combo' = 'correct',
scale: number = 1.0
): void {
if (!this._world) {
console.error('[ScoreVisualizationSystem] Cannot create floating score - world not set');
return;
}
console.log(`[ScoreVisualizationSystem] Creating floating score: ${score} (${type})`);
// For now, just log the score creation - we'll implement the full visual later
// This avoids potential SDK compatibility issues during testing
}
/**
* Create a screen shake effect for big scores
*/
public createScreenShakeEffect(playerEntity: PlayerEntity, intensity: number = 1.0): void {
if (!playerEntity || !playerEntity.player) return;
console.log(`[ScoreVisualizationSystem] Screen shake effect: intensity ${intensity}`);
// For now, just log the effect - we'll implement the full shake later
}
/**
* Create a score burst effect
*/
public createScoreBurst(
position: Vector3Like,
scores: number[],
type: 'correct' | 'wrong' | 'bonus' = 'correct'
): void {
if (!this._world) return;
console.log(`[ScoreVisualizationSystem] Score burst: ${scores.join(', ')} (${type})`);
}
/**
* Clean up all floating scores
*/
public cleanup(): void {
console.log('[ScoreVisualizationSystem] Cleaning up floating scores...');
for (const floatingScore of this._floatingNumbers) {
try {
if (floatingScore.isSpawned) {
floatingScore.despawn();
}
} catch (error) {
console.error('[ScoreVisualizationSystem] Error cleaning up floating score:', error);
}
}
this._floatingNumbers.clear();
}
/**
* Get active floating score count
*/
public getActiveScoreCount(): number {
return this._floatingNumbers.size;
}
}