Exemple #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);
        }
    }//指定位置创建地图板块
Exemple #2
0
    }//指定位置创建地图板块

    private GameObject InstantiateItem(Vector3 position, hexcell.MAP_TYPE type) //根据坐标和类型复制预制体
    {
        List <GameObject> CondList = Tiledlist.FindAll(delegate(GameObject temp) { return(temp.GetComponent <hexcell>().type == type); });
        int        index           = Random.Range(0, CondList.Count);
        GameObject obj             = Instantiate <GameObject>(CondList[index], position, Quaternion.identity);

        return(obj);
    } //根据坐标和类型复制预制体