void DrawGrid() { if (grid != null) { Destroy(grid); } grid = DrawingMap.DrawGrid(mapController.MapSizeX, mapController.MapSizeZ, mapController.CenterPosition, Quaternion.identity); }
public void LoadMap() { string path = MapSetting.MAP_DATA_FOLDER_NAME + MapFileName; MapData mapData = new MapData(path); MapObjectData mapObject = new MapObjectData(path + "_Object"); DrawingMap.DrawMap(mapData, mapObject, CenterPosition, Quaternion.identity); }
public GameObject CreatePatternGameObject() { if (mapData != null && mapObjectData != null) { GameObject o = new GameObject(); o.name = FileName; DrawingMap.DrawCells(mapObjectData.GetObjectEnumerator(), (int)assetSize.x, (int)assetSize.z, Vector3.zero, o); AssetCellData cellData = o.AddComponent <AssetCellData>(); cellData.Size = assetSize; cellData.Center = new Vector3(0, assetSize.y * 0.5f, 0); return(o); } return(null); }
public void DrawMap() { mapObjectParent = DrawingMap.DrawMap(MapDataCollection, MapObjectDataCollection, CenterPosition, Quaternion.identity); if (IsUsedByEditor) { AssetCellData[] assets = mapObjectParent.GetComponentsInChildren <AssetCellData>(); int len = assets.Length; for (int i = 0; i < len; i++) { int objectCount = assets[i].MapObj.ObjectDataList.Count; for (int j = 0; j < objectCount; j++) { onCreateMapObject(assets[i].MapObj.ObjectDataList[j].Go); } } } }
/// <summary> /// 更新cell資料 /// </summary> /// <param name="prefabName"></param> /// <param name="x"></param> /// <param name="z"></param> /// <param name="height"></param> /// <param name="assetSize"></param> /// <param name="rotation"></param> /// <param name="unitType"></param> public void UpdateCellData(string prefabName, int x, int z, float height, Vector3 assetSize, Quaternion rotation, UnitType unitType) { if (MapDataCollection.CanBuildOnTheMap(x, z, height, assetSize)) { int id = MapUtility.CoordinateToId(x, z, MapDataCollection.MapSizeX); MapObject mapObject = MapObjectDataCollection.GetMapObjectById(id); if (mapObject == null) { mapObject = MapObjectDataCollection.AddMapObject(id); } MapObject.ObjectData o = MapObjectDataCollection.AddObjectData(id); o.PrefabName = prefabName; o.Height = height; o.Rotation = rotation; MapDataCollection.WriteCellData(x, z, assetSize, unitType, height); GameObject obj = DrawingMap.DrawMapObjectData(mapObject, o, CenterPosition, MapSizeX, MapSizeZ, x, z, mapObjectParent.transform); onCreateMapObject(obj); MapObjectDataCollection.RaiseFinishAddObjectData(o); } }