pinball/assets/_Game/Scripts/Manager/GameManager.ts

37 lines
1008 B
TypeScript

import { _decorator, Component, Prefab } from 'cc';
import ObjectPool from '../Pool/ObjectPool';
import Utilities from '../Utilities/Utilities';
const { ccclass, property } = _decorator;
@ccclass('GameManager')
export class GameManager extends Component {
//singleton
private static _instance: GameManager = null;
public static get instance(): GameManager {
return GameManager._instance;
}
@property({ type: Prefab, visible: true })
private _ballPrefab: Prefab;
private _ballPool: ObjectPool;
public highestStreak: number;
public score = 0;
protected onLoad(): void {
this._ballPool = new ObjectPool(this._ballPrefab, 10, false);
}
protected async start() {
while (true) {
const ball = this._ballPool.get(this.node);
ball.setWorldPosition(this.node.worldPosition);
await Utilities.delay(1000);
}
}
public onRevive() {
throw new Error('Method not implemented.');
}
}