// Use this for initialization void Start() { mapManager = new MapContraller(); roomManager = GetComponent <RoomContraller> (); //在场景中搜索房间起点 mapSpawnPoint = GameObject.Find("MapSpawnPoint").GetComponent <Transform> (); //生成好的地图数据<房间坐标xy,门的信息> Dictionary <int[], int[]> map = mapManager.genMap(roomLevel, roomAmount); //根据地图数据,生成新房间 foreach (int[] key in map.Keys) { //新房间在地图中的坐标 int[] rXYZ = new int[] { key[0], key[1], key[2] }; //产生新房间 unitMap = roomManager.genRoom(rXYZ, map [key]); //预备给新房间的坐标 Vector3 newMap = mapSpawnPoint.position; //根据房间的宽度,水平偏移 newMap.x = key [0] * horizonDis; //根据房间的高度,竖直偏移 newMap.y = key [1] * vertiDis; //根据房间的楼层,设定z坐标值 newMap.z = key[2]; //设置新房间在屏幕上的坐标 unitMap.transform.position = newMap; } }
// Use this for initialization void Start() { mapManager = new MapContraller(); roomManager = GetComponent <RoomContraller> (); //在场景中搜索房间起点 mapSpawnPoint = GameObject.Find("MapSpawnPoint").GetComponent <Transform> (); //生成好的地图数据<房间坐标xy,门的信息> Dictionary <int[], int[]> map = mapManager.genMap(roomLevel, roomAmount); foreach (int[] key in map.Keys) { //预备给新房间的坐标 Vector3 newMap = mapSpawnPoint.position; //根据房间的宽度,水平偏移 if (key [0] != 0) { newMap.x = key [0] * horizonDis; } //根据房间的高度,竖直偏移 if (key [1] != 0) { newMap.y = key [1] * vertiDis; } //z值为0 newMap.z = key[2]; int[] rXYZ = { key[0], key[1], key[2] }; //房间生成器返回新生成的房间 unitMap = roomManager.genRoom(rXYZ, map [key]); //设置新房间的坐标 unitMap.transform.position = newMap; } }
private void genDownMap() { // Debug.Log("init map begin"); mapManager = new MapContraller(); roomManager = GetComponent <RoomContraller>(); //在场景中搜索房间起点 mapSpawnDownPoint = GameObject.Find("MapSpawnDownPoint").GetComponent <Transform>(); //生成好的地图数据<房间坐标xy,门的信息> if (neworLoad) { this.mapDown = mapManager.genMap(RoomConstant.ROOM_Z_DOWN, roomAmount); } else { this.mapDown = genMap(Application.persistentDataPath + "/Save/SaveData3.sav"); } // Debug.Log("map count: " + map.Count); //根据地图数据,生成新房间 foreach (int[] key in mapDown.Keys) { //新房间在地图中的坐标 int[] rXYZ = new int[] { key[0], key[1], key[2] }; //产生新房间 // Debug.Log(rXYZ[0] +","+ rXYZ[1] + "," + rXYZ[2]); unitMap = roomManager.genRoom(rXYZ, mapDown[key]); //预备给新房间的坐标 Vector3 newMap = mapSpawnDownPoint.position; //根据房间的宽度,水平偏移 newMap.x = key[0] * horizonDis; //根据房间的高度,竖直偏移 newMap.y = RoomConstant.ROOM_Y_DOWN + key[1] * vertiDis - 0.85f; //根据房间的楼层,设定z坐标值 newMap.z = key[2]; //设置新房间在屏幕上的坐标 unitMap.transform.position = newMap; } genMinMap(mapDown, RoomConstant.ROOM_Z_DOWN); }