import { _decorator } from "cc";
import GBaseMode from "../../GBaseMode";
import { GMapLoop } from "../../base/common/map/GMapLoop";
import { TD, app } from "../../../App";
import { TB } from "../../../config/data/schema";
const { ccclass, property } = _decorator;

export default class GDefaultMode<T,DT> extends GBaseMode<T,DT>{

    //场景地图
    @property(GMapLoop)
    map1:GMapLoop;
    @property(GMapLoop)
    map2:GMapLoop;
    @property(GMapLoop)
    map3:GMapLoop;
    
    //地图信息
    mapInfo:TB.TbGMap;

    //设置世界地图
    setWorldMap(mapId:number = 60001){
        
        //初始化地图
        this.mapInfo = TD.TbGMap.get(mapId);

        let scale = this.mapInfo.scale;
        this.map1.init(app.battleRes.getMap(mapId)[0],1,app.battleRes.getMap(mapId)[0].width * scale,app.battleRes.getMap(mapId)[0].height * scale);
        this.map2.init(app.battleRes.getMap(mapId)[1],1,app.battleRes.getMap(mapId)[1].width * scale,app.battleRes.getMap(mapId)[1].height * scale);
        this.map3.init(app.battleRes.getMap(mapId)[2],1,app.battleRes.getMap(mapId)[1].width * scale,1280 * scale);

        //更新地图
        this.onUpdateMap(0);

    }

    //更新地图
    onUpdateMap(dt){
        let cameraX = this.camera.node.worldPosition.x;
        this.map1.UpdateMap(cameraX,0,this.mapInfo.map1OffsetY);
        this.map2.UpdateMap(cameraX,cameraX / 10,this.mapInfo.map2OffsetY);
        this.map3.UpdateMap(cameraX,0,this.mapInfo.map3OffsetY);
    }

}