Update SpawnObjectManager.ts

main
tiendat3699 2024-03-13 11:54:27 +07:00
parent d1a218f16b
commit 790c0e7a59
1 changed files with 4 additions and 5 deletions

View File

@ -56,11 +56,6 @@ export class SpawnObjectManager extends Component {
const prefab = this._objects[i].prefab; const prefab = this._objects[i].prefab;
this._pools[i] = new ObjectPool(prefab, 10, true, ScoreObject); this._pools[i] = new ObjectPool(prefab, 10, true, ScoreObject);
} }
this._weights = this._objects.map((obj) => {
obj.currentWeight = obj.weight;
return obj.currentWeight;
});
} }
protected update(dt: number): void { protected update(dt: number): void {
@ -112,6 +107,10 @@ export class SpawnObjectManager extends Component {
for (let i = 0; i < randomRangeInt(5, 10); i++) { for (let i = 0; i < randomRangeInt(5, 10); i++) {
this.spawn(); this.spawn();
} }
this._weights = this._objects.map((obj) => {
obj.currentWeight = obj.weight;
return obj.currentWeight;
});
break; break;
case GameState.GameOver: case GameState.GameOver:
this._playing = false; this._playing = false;