import { _decorator, Component, Node, Prefab } from 'cc';
import { Camera } from 'cc';
import GBattleModeManager from './battle/GBattleModeManager';
import { GData } from './consts/GData';
const { ccclass, property } = _decorator;

@ccclass('WorldCanvas')
export class WorldCanvas extends Component {

    @property(Node)
    root:Node = null;
    @property(Camera)
    camera:Camera = null;
    
    @property([Prefab])
    modes:Prefab[] = [];

    index:number = 1;

    async onLoad(){

        GData.WorldCanvas = this;

        //重置相机位置
        this.camera.node.setWorldPosition(0,0,1000);

        //初始化游戏模式管理器
        GBattleModeManager.getIns().onInit({
            modes:this.modes,   //模式
            camera:this.camera, //相机
            root:this.root,     //场景
        });

    }

    update(deltaTime: number) {
        GBattleModeManager.getIns().onUpdate(deltaTime);
    }

}


