private void DrawAllGirdObjectType(LJMapObjLayerData mapObjLayerData, LJMapObject currentGirdObject, List <Vector3Int> allLocations, ref bool isChanged) { int mainType = EditorGUILayout.IntPopup("组类型 : ", currentGirdObject.MainType, MAIN_NAMES, MAIN_INDEXS); if (currentGirdObject.MainType != mainType) //改变主类型 { isChanged = true; EnsureCreateAllGirdObject(mapObjLayerData, allLocations); for (int i = 0, imax = allLocations.Count; i < imax; i++) { Vector3Int location = allLocations[i]; SerVector2Int serVector2Int = new SerVector2Int(location.x, location.y); LJMapObject gridObject = mapObjLayerData.GetPositionProperty(serVector2Int); gridObject.MainType = mainType; switch (mainType) { case LJMapConst.MAP_OBJ_MAIN_TYPE.UNDEFINE: gridObject.SubType = LJMapConst.MAP_OBJ_SUB_TYPE.UNDEFINE; break; case LJMapConst.MAP_OBJ_MAIN_TYPE.WONDER: case LJMapConst.MAP_OBJ_MAIN_TYPE.CITY: case LJMapConst.MAP_OBJ_MAIN_TYPE.GATE: if (gridObject.SubType == LJMapConst.MAP_OBJ_SUB_TYPE.UNDEFINE) { gridObject.SubType = LJMapConst.MAP_OBJ_SUB_TYPE.WONDER_PART_OUTSIDE; } else if (gridObject.SubType == LJMapConst.MAP_OBJ_SUB_TYPE.PART) { gridObject.SubType = LJMapConst.MAP_OBJ_SUB_TYPE.WONDER_PART_OUTSIDE; } break; case LJMapConst.MAP_OBJ_MAIN_TYPE.TOWN: case LJMapConst.MAP_OBJ_MAIN_TYPE.RESOURCE: case LJMapConst.MAP_OBJ_MAIN_TYPE.TREASURE: gridObject.SubType = LJMapConst.MAP_OBJ_SUB_TYPE.PART; break; } } } switch (mainType) { case LJMapConst.MAP_OBJ_MAIN_TYPE.UNDEFINE: EditorGUILayout.LabelField("请先定义地块类型!"); break; case LJMapConst.MAP_OBJ_MAIN_TYPE.WONDER: case LJMapConst.MAP_OBJ_MAIN_TYPE.CITY: case LJMapConst.MAP_OBJ_MAIN_TYPE.GATE: int subType = EditorGUILayout.IntPopup("二级类型 : ", currentGirdObject.SubType, SUB_NAMES, SUB_INDEXS); if (currentGirdObject.SubType != subType) { //改变主类型 EnsureCreateAllGirdObject(mapObjLayerData, allLocations); for (int i = 0, imax = allLocations.Count; i < imax; i++) { Vector3Int location = allLocations[i]; SerVector2Int serVector2Int = new SerVector2Int(location.x, location.y); LJMapObject gridObject = mapObjLayerData.GetPositionProperty(serVector2Int); gridObject.SubType = subType; gridObject.MainType = mainType; } } break; case LJMapConst.MAP_OBJ_MAIN_TYPE.TOWN: case LJMapConst.MAP_OBJ_MAIN_TYPE.RESOURCE: case LJMapConst.MAP_OBJ_MAIN_TYPE.TREASURE: break; } }
public override void OnPaintInspectorGUI() { base.OnPaintInspectorGUI(); bool isChanged = false; EditorGUILayout.LabelField("蓝鲸图块编辑"); List <Vector3Int> allLocations = new List <Vector3Int>(); Vector3Int lastCellposition = lastBoundsInt.position; allLocations.Add(lastCellposition); foreach (Vector3Int location in lastBoundsInt.allPositionsWithin) { if (lastCellposition.Equals(location)) { continue; } allLocations.Add(location); } DrawInspectorAllLocation(allLocations); LJMapObjLayerHolder mapObjLayerHolder = prefabBrush.LJMapObjLayerHolder; if (mapObjLayerHolder == null) { EditorGUILayout.LabelField("未绑定 LJ Map Obj Layer Holder!"); return; } LJMapObjLayerData mapObjLayerData = mapObjLayerHolder.mapObjLayerData; if (mapObjLayerData == null) { EditorGUILayout.LabelField("未加载地图!"); return; } SerVector2Int lastCellVectPosition = new SerVector2Int(allLocations[0].x, allLocations[0].y); //SerVector3Int lastCellVectPosition = MapUtil.ConvertVec3Int2SerVec3Int(allLocations[0]); LJMapObject currentGirdObject = mapObjLayerData.GetPositionProperty(lastCellVectPosition); int drawSt = DrawInspectorEnableGirdObject(mapObjLayerData, currentGirdObject, allLocations); switch (drawSt) { case 1: //有修改 已关闭 SaveLJMapObjLayerData(mapObjLayerData); return; case 2: //有修改 已开启 currentGirdObject = mapObjLayerData.GetPositionProperty(lastCellVectPosition); isChanged = true; break; case 3: // 无修改 关闭 return; case 4: // 无修改 开启 break; } DrawAllGirdObjectType(mapObjLayerData, currentGirdObject, allLocations, ref isChanged); //switch (currentGirdObject.MainType) //{ // case LJMapConst.MAP_OBJ_MAIN_TYPE.UNDEFINE: // break; // case LJMapConst.MAP_OBJ_MAIN_TYPE.WONDER: // case LJMapConst.MAP_OBJ_MAIN_TYPE.CITY: // case LJMapConst.MAP_OBJ_MAIN_TYPE.GATE: // case LJMapConst.MAP_OBJ_MAIN_TYPE.TOWN: // case LJMapConst.MAP_OBJ_MAIN_TYPE.RESOURCE: // case LJMapConst.MAP_OBJ_MAIN_TYPE.TREASURE: // //DrawAllGirdObjectMainId(gridMapData, currentGirdObject, allLocations,ref isChanged); // break; //} //switch (currentGirdObject.MainType) //{ // case LJMapConst.MAP_OBJ_MAIN_TYPE.UNDEFINE: // break; // case LJMapConst.MAP_OBJ_MAIN_TYPE.WONDER: // case LJMapConst.MAP_OBJ_MAIN_TYPE.CITY: // case LJMapConst.MAP_OBJ_MAIN_TYPE.GATE: // DrawAllGirdObjectSubId(gridMapData, currentGirdObject, allLocations,ref isChanged); // break; // case LJMapConst.MAP_OBJ_MAIN_TYPE.TOWN: // case LJMapConst.MAP_OBJ_MAIN_TYPE.RESOURCE: // case LJMapConst.MAP_OBJ_MAIN_TYPE.TREASURE: // break; //} //EditorGUILayout.BeginHorizontal(); //EditorGUILayout.PrefixLabel("扩展信息 : "); //ljGridObject.ExtendMsg = EditorGUILayout.DelayedTextField(ljGridObject.ExtendMsg); //EditorGUILayout.EndHorizontal(); //EditorGUILayout.BeginHorizontal(); //EditorGUILayout.PrefixLabel("名字 : "); //ljGridObject.Name = EditorGUILayout.DelayedTextField(ljGridObject.Name); //EditorGUILayout.EndHorizontal(); //EditorGUILayout.BeginHorizontal(); //EditorGUILayout.PrefixLabel("备注 : "); //ljGridObject.Info = EditorGUILayout.DelayedTextField(ljGridObject.Info); //EditorGUILayout.EndHorizontal(); if (isChanged) { SaveLJMapObjLayerData(mapObjLayerData); } }