-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignManager3.js
More file actions
110 lines (93 loc) · 3.38 KB
/
Copy pathsignManager3.js
File metadata and controls
110 lines (93 loc) · 3.38 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
100
101
102
103
104
105
106
107
108
109
110
/**
* SignManager3.js - Manager for ceiling sign entities in Circuit Sanctum Arcade
* Handles ceiling sign entity creation and placement
*/
import { SignEntity3 } from './signEntity3.js';
import assetLoader from './assetLoader.js';
import { debug } from './utils.js';
/**
* Manages ceiling sign creation and placement
*/
class SignManager3 {
/**
* Create a new ceiling sign manager
* @param {Game} game - Game reference
*/
constructor(game) {
this.game = game;
this.signs = [];
debug('SignManager3: Initialized');
}
/**
* Preload sign assets
*/
preloadSigns() {
debug('SignManager3: Preloading ceiling sign assets');
this.loadSign('sign3');
}
/**
* Load a specific sign asset
* @param {string} signKey - The sign asset key to load
*/
loadSign(signKey) {
debug(`SignManager3: Beginning dedicated sign loading for ${signKey}`);
// Load via asset loader
const assetPath = `assets/decor/Sign_3.png`;
debug(`SignManager3: Attempting to load via AssetLoader: ${assetPath}`);
return new Promise((resolve) => {
// Create a new image
const signImage = new Image();
signImage.onload = () => {
debug(`SignManager3: Sign image loaded successfully`);
assetLoader.assets[signKey] = signImage;
resolve(true);
};
signImage.onerror = () => {
console.error(`SignManager3: Failed to load sign image from ${assetPath}`);
// Resolve anyway to prevent blocking
resolve(false);
};
signImage.src = assetPath;
});
}
/**
* Add signs to the game at predetermined positions
*/
addSigns() {
console.log('Adding ceiling signs to scene...');
// Create ceiling signs at strategic positions
// Positioned in the center of various areas for visibility
const signPositions = [
{ x: 115, y: 8, key: 'sign3' } // Central position in the arcade
];
// Add each sign
signPositions.forEach(pos => {
this.addSign(pos.x, pos.y, pos.key);
});
console.log('Ceiling signs added successfully');
}
/**
* Add a sign to the game at the specified position
* @param {number} x - X position
* @param {number} y - Y position
* @param {string} signKey - The sign key
*/
addSign(x, y, signKey) {
debug(`SignManager3: Adding ceiling sign at (${x}, ${y}) with key ${signKey}`);
// Create sign entity with appropriate dimensions for ceiling sign
const sign = new SignEntity3(x, y, 4.0, 4.0, signKey);
// Add to game
if (this.game) {
this.game.addEntity(sign);
this.signs.push(sign);
debug('SignManager3: Ceiling sign added to game successfully');
// If the sign image is loaded, log its dimensions
if (sign.signImage) {
debug(`SignManager3: Successfully preloaded ${signKey} (${sign.signImage.width}x${sign.signImage.height})`);
}
} else {
console.error('SignManager3: Game instance not available');
}
}
}
export { SignManager3 };