
cc.Class({
    extends: cc.Component,

    properties: {

        HighwayBuilding: {
            default: null,
            type: cc.Prefab,
        },

        SpawnPoint: {
            default: null,
            type: cc.Node,
        },


        HighwayBuildingNode: {
            default: null,
            type: cc.Node,
        },
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    // start() {


    // },

    //创建一个公路建筑预制
    onCreateHighwayBuilding() {
        let highwayTemp = cc.instantiate(this.HighwayBuilding);

        let tempPos = this.SpawnPoint.convertToNodeSpace(GlobalD.game.MainCamera.node);

        let CanvasPos = GlobalD.game.Canvas.position;

        highwayTemp.setPosition(tempPos.x + CanvasPos.x, tempPos.y + CanvasPos.y);
        highwayTemp.parent = this.SpawnPoint;

        //收起菜单
        GlobalD.game._ManageUIScript.onButtonEvent_Building_Close();

    },

    onShowHighwayBuilding() {

        let tempPos = this.HighwayBuildingNode.parent.convertToNodeSpace(GlobalD.game.MainCamera.node);
        let CanvasPos = GlobalD.game.Canvas.position;

        this.HighwayBuildingNode.setPosition(tempPos.x + CanvasPos.x, tempPos.y + CanvasPos.y);
        this.HighwayBuildingNode.active = true;

        GlobalD.game.onSetCurrentBuildingTarget(this.HighwayBuildingNode);
        //收起菜单
        GlobalD.game._ManageUIScript.onHideMenu();
    },
    // update (dt) {},

});
