//创建地图 public void CreateMap(int width, int height, int[,] configMap, int[,] configItemMap, int[,] configGroundMap) { if (Server.instance.whichGame == 1) { GameMap gameMap = MapController.instance.Create(width, height); ItemMap itemMap = MapController.instance.CreateItemMap(width, height); GroundMap groundMap = MapController.instance.CreateGroundMap(width, height); mapDic.TryAdd(gameMap.mapId, gameMap); itemMapDic.TryAdd(itemMap.mapId, itemMap); groundMapDic.TryAdd(groundMap.mapId, groundMap); } else if (Server.instance.whichGame == 3) { mapDic[0].gameMap = new int[width, height]; mapDic[0].width = width; mapDic[0].height = height; itemMapDic[0].itemMap = new int[width, height]; itemMapDic[0].width = width; itemMapDic[0].height = height; groundMapDic[0].groundMap = new int[width, height]; groundMapDic[0].width = width; groundMapDic[0].height = height; } MapController.instance.Init(mapDic[0], width, height, configMap); MapController.instance.InitItemMap(itemMapDic[0], width, height, configItemMap); MapController.instance.InitGroundMap(groundMapDic[0], width, height, configGroundMap); ConsoleLog.instance.Info(string.Format("创建地图,地图Id: {0}", 0)); }
//初始化道具地图 public void InitItemMap(ItemMap itemMap, int width, int height, int[,] map) { for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { itemMap.itemMap[i, j] = map[i, j]; } } }
//创建道具地图 public ItemMap CreateItemMap(int width, int height) { ItemMap itemMap = new ItemMap(); itemMap.mapId = itemMapGuid; itemMap.width = width; itemMap.height = height; itemMapGuid++; itemMap.itemMap = new int[width, height]; return(itemMap); }