import WorldMapItem from "./WorldMapItem";
import Stage from "../Stage";
import ViewObject from "../../../../main/ViewObject";

const {ccclass, property} = cc._decorator;

@ccclass
export default class WorldMap extends ViewObject {

    @property(cc.Prefab)
    mItem: cc.Prefab = null;

    @property(cc.Node)
    mContent: cc.Node = null;

    public stage:Stage;
   
    onLoad () {
        let manage = this.main.sManage;
        let scenes = manage.getScene();

        for (let i = 0; i < scenes.length; i++) {
            const element = scenes[i];
            let node = cc.instantiate(this.mItem);
            node.parent = this.mContent;
            let wmItem:WorldMapItem = node.getComponent(WorldMapItem);
            wmItem.setScene(element);
            wmItem.setCallback((item:WorldMapItem)=>{
                this.onclickScene(item);
            });
        }
    }
    public onclickScene(item:WorldMapItem){
        this.exitDistroy();
        this.stage.loadMiniMap(item.sceneData,(result:number)=>{
            
        });
    }


   
}
