import { _decorator, Component, director, instantiate, Node, Prefab } from 'cc';
import { app, TD } from './App';
import { JNGame } from '../../extensions/ngame/assets/ngame/JNGame';
import { JNSyncAction } from '../../extensions/ngame/assets/ngame/sync/JNSyncAction';
import { GOnHookPets } from '../../extensions/ngame/assets/ngame/message/proto';
import { Env, EnvCurrent } from './Env';
import { GAction } from './consts/GAction';
import { view } from 'cc';
const { ccclass, property } = _decorator;

//正式项目肯定不是这样写 我临时这样写用来Server跳过登录
window['GUser'] = "100000";
window['GPassworld'] = "123456";

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

    @property(Prefab)
    UIPrefab: Prefab = null;

    @property(Prefab)
    WorldPrefab: Prefab = null;

    async onLoad(){

        console.log("EnvCurrent",EnvCurrent)

        // 创建UI
        director.getScene().addChild(instantiate(this.UIPrefab));

        //加载 APP
        await JNGame.Init(app);

        console.log("TD",TD.TbGRoleEquip.getDataList())

        // 发送帧同步开始
        // app.socket.Send(JNSyncAction.NSyncFrameStart);

        // 创建世界
        director.getScene().addChild(instantiate(this.WorldPrefab));

        if(EnvCurrent == Env.Server){
            //发送就绪
            app.socket.Send(GAction.CR_REFEREE_READY);
        }

    }

}


