1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import { _decorator, Component, director, Node } from 'cc';
- import get_new_delay from '../../core/util_class/Delay';
- import get_new_fms from '../../core/util_class/FMS';
- import get_new_job from '../../core/util_class/TimeJobCenter';
- import get_new_random from '../../core/util_class/Random';
- import get_new_prefab_pool from '../../core/util_class/PrefabPool';
- import DirectorUtil from '../../core/util/DirectorUtil';
- /**
- * 游戏模块
- *
- const { ccclass, property } = _decorator;
- @ccclass('GameStar')
- export class GameStar extends Game<GameStar> {
- public cc:number=99;
- public tcc():void{
- console.log("goaodfjadsofjosadjfo"+this.cc);
- }
- onLoad(): void {
- super.onLoad();
- }
- update(deltaTime: number) {
- super.update(deltaTime);
- }
- async start() {
- console.log("111111111111111111111111111")
- await this.delay.start(3);
- console.log("3333333333333333333333333")
- GameStar.getInst().tcc();
- }
- }
- */
- export class Game<T extends Game<T>> extends Component {
- private static instance: Game<any>;
- public static getInst<T extends Game<T>>(this: new () => T): T {
- const _class = this as any;
- return _class.instance as T;
- }
- protected onLoad(): void {
- Game.instance = this;
- }
- /**游戏流程状态*/
- public FMS = get_new_fms();
- /**时间任务管理 暂停后不运行*/
- public job = get_new_job();
- /**延时管理*/
- public delay = get_new_delay();
- /**可设置种子的随机数*/
- public ranodm = get_new_random((new Date).getTime());
- /**预制体对象池*/
- public prefabPool = get_new_prefab_pool();
- private _paused: boolean = false;
- get is_paused(): boolean { return this._paused; }
- //
- public pause(): void {
- this._paused = true;
- DirectorUtil.pause();
- }
- //
- public resume(): void {
- this._paused = false;
- DirectorUtil.resume();
- }
- update(deltaTime: number) {
- this.delay.update(deltaTime);
- if (this._paused) return;
- this.job.Run(deltaTime);
- }
- }
|