/// <summary> /// json 不能存方法 不能用构造函数 /// </summary> /// <param name="PosX">世界坐标x</param> /// <param name="PosY">世界左边y</param> /// <param name="colorType">颜色类型</param> /// <param name="mapIndex">地图索引 x</param> /// <param name="mapIndey">地图索引 y</param> /// <returns></returns> private static MapSingleInfo SetElemInfo(string PosX, string PosY, ColorType colorType, int mapIndex, int mapIndey, int isfill) { MapSingleInfo elem = new MapSingleInfo(); elem.PosX = PosX; elem.Posy = PosY; elem.colorType = colorType; elem.mapIndex = mapIndex; elem.mapIndey = mapIndey; elem.isFill = isfill; return(elem); }
/// <summary> /// 设置默认地图 全是空 /// </summary> private static List <List <MapSingleInfo> > SetDefaultMap() { if (_worldPos.Count == 0) { Debug.LogWarning("初始化地图位置失败 运行挂载Mapcontroller脚本的场景也许可以解决此问题"); return(null); } for (int i = 0; i < virticalCount; i++) { List <MapSingleInfo> horizontalMap = new List <MapSingleInfo>(); for (int j = 0; j < HorizontalCount; j++) { Debug.Log("save::" + _worldPos[i][j].x.ToString() + _worldPos[i][j].y.ToString()); MapSingleInfo elem = SetElemInfo(_worldPos[i][j].x.ToString(), _worldPos[i][j].y.ToString(), ColorType.ColorWood, i, j, 0); horizontalMap.Add(elem); } _mapInfo.Add(horizontalMap); } return(_mapInfo); }
/// <summary> /// 保存信息 /// </summary> /// <param name="mapInfo"></param> public static void SaveMap(List <List <int> > mapInfo) { GameInfoSaveManager.StartGetSaveInfo(); if (mapInfo.Count != virticalCount) { Debug.LogWarning("地图高度不正确"); return; } if (mapInfo[0].Count != HorizontalCount) { Debug.LogWarning("地图宽度不正确"); return; } if (_mapInfo.Count == 0) { GetMap(); //获取位置信息 x y 坐标 } List <List <MapSingleInfo> > InspectormapInfo = new List <List <MapSingleInfo> >(); for (int i = 0; i < mapInfo.Count; i++) { List <MapSingleInfo> temp = new List <MapSingleInfo>(); for (int j = 0; j < mapInfo[i].Count; j++) { MapSingleInfo elem = SetElemInfo(_mapInfo[i][j].PosX, _mapInfo[i][j].Posy.ToString(), ColorType.ColorWood, i, j, mapInfo[i][j]); temp.Add(elem); } InspectormapInfo.Add(temp); } Map map = new Map(); map._mapInfo = InspectormapInfo; _mapInfo = InspectormapInfo; string currentIndex = ShapManager.currentIndex.ToString(); GameInfoSaveManager.SaveAttributeInfo("currentIndex", currentIndex); GameInfoSaveManager.SaveClassInfo <Map>("BlockPuzzleMap", map); GameInfoSaveManager.EndSetSaveInfo(); }