Esempio n. 1
0
    //private void CreateCell(int x,int y, float positionx,float positiony, float positionz, hexcell.MAP_TYPE type, hexcell[,] cell) {
    //    Vector3 position;



    //}//指定位置创建地图板块
    private void CreateTileMap(TiledMapInfo mapinfo, hexcell[,] Initcells)
    {
        for (int i = 0; i < mapinfo.baselayertiled.Count; i++)
        {
            Vector3          position;
            int              x         = mapinfo.baselayertiled[i].x;
            int              y         = mapinfo.baselayertiled[i].y;
            float            positionx = mapinfo.baselayertiled[i].positionX;
            float            positiony = mapinfo.baselayertiled[i].positionY;
            float            positionz = mapinfo.baselayertiled[i].positionZ;
            hexcell.MAP_TYPE type      = (hexcell.MAP_TYPE)mapinfo.baselayertiled[i].type;
            position.x = positionx;
            position.y = positiony;
            position.z = positionz;

            hexcell hex_cell = InstantiateItem(position, type).GetComponent <hexcell>();
            hex_cell.transform.SetParent(this.transform, false);
            Initcells[x, y] = hex_cell;
            if (mapinfo.baselayertiled[i].iscity == true)
            {
                Initcells[x, y].city_id = mapinfo.baselayertiled[i].id;
                Initcells[x, y].obj_id  = mapinfo.baselayertiled[i].obj_id;
                //Debug.Log("mapid=[" + mapinfo.baselayertiled[i].id + "] obj_id=["+mapinfo.baselayertiled[i].obj_id+"]");
            }
            //CreateCell(x, y, positionx, positiony, positionz, type, Initcells);
        }
    }//指定位置创建地图板块
Esempio n. 2
0
    // Use this for initialization
    void Awake()
    {
        InitMapTile();
        tiledmapinfo = Singleton <TiledMapInfo> .Instance;
        width        = tiledmapinfo.width;
        heigth       = tiledmapinfo.height;

        cells = new hexcell[width, heigth];

        //创建基础层板块
        CreateTileMap(tiledmapinfo, cells);
    }