import { UIList } from "../Script/Core/Ui/UIDef";
import { UILayerNames } from "../Script/Core/Ui/UILayers";
import { UIMgr } from "../Script/Core/Ui/UIMgr";
import { EConfigConst } from "../Script/game/cfg/ConfigDef";
import { BulletItem } from "../Script/game/cfg/bulletItem";
import { ConfigMgr } from "../Script/game/cfg/configMgr";
import { Utils } from "../Script/game/common/utils";
import { Barrage } from "../Script/game/nest/barrage";

const {ccclass, property} = cc._decorator;

@ccclass
export default class test extends cc.Component {

    /*===========================自动绑定组件开始===========================*/
	/*自动生成*/
    @property({type:cc.Node, displayName:""})
    private $layer_node:cc.Node = null;

    /*自动生成*/
    @property({type:cc.Node, displayName:""})
    private $ui_node:cc.Node = null;
    
	/*===========================自动绑定组件结束===========================*/

    /*===========================自动生成按钮事件开始==========================*/

	/*===========================自动生成按钮事件结束==========================*/

    protected async onLoad() {
        await this.testCfg();
        UIMgr.inst.setup(this.$ui_node, UILayerNames.length, UILayerNames);
        UIMgr.inst.showUI(UIList.debug);

        let bulletItem = ConfigMgr.inst.getCfgClassById(EConfigConst.bullet, '4001', BulletItem);
        Barrage.inst.layer = this.$layer_node;
        Barrage.inst.createMonsterBullet({
            worldPos: this.node.convertToWorldSpaceAR(cc.v2(0,0)),
            dirction: cc.v2(0,1),
            atk:1,
        }, bulletItem);
    }
    
    async testCfg(){
        await ConfigMgr.inst.init();
    }
}