Example #1
0
        void OnDrawSceneGUI(SceneView sceneView)
        {
            LJMapObjLayerHolder mapObjLayerHolder = prefabBrush.LJMapObjLayerHolder;

            if (mapObjLayerHolder == null)
            {
                return;
            }
            Grid grid = mapObjLayerHolder.GetComponent <Grid>();

            if (grid == null)
            {
                return;
            }

            LJMapObjLayerData mapObjLayerData = mapObjLayerHolder.mapObjLayerData;

            if (mapObjLayerData == null)
            {
                return;
            }

            if (!prefabBrush.showObjLayerBorder && !prefabBrush.showObjLayerInfo)
            {
                return;
            }

            Vector3 cellSize = grid.cellSize;
            //Debug.Log("we got cellSize : "+ cellSize);
            LJMapObjDict  dict          = mapObjLayerData.PositionProperties;
            StringBuilder stringBuilder = new StringBuilder();

            foreach (KeyValuePair <SerVector2Int, LJMapObject> kvp in dict)
            {
                SerVector2Int serCellPosInt = kvp.Key;
                Vector2Int    cellPosInt    = MapUtil.ConvertSerVec2Int2Vec2Int(serCellPosInt);
                LJMapObject   ljGridObject  = kvp.Value;
                Vector3[]     cellCorners   = MapUtil.GetMapWorldCorners(new Vector3Int(cellPosInt.x, cellPosInt.y, 0), grid);
                Handles.color = Color.cyan;
                if (prefabBrush.showObjLayerBorder)
                {
                    Handles.DrawLines(new Vector3[] { cellCorners[0], cellCorners[2], cellCorners[2], cellCorners[1], cellCorners[1], cellCorners[3], cellCorners[3], cellCorners[0], });
                }
                //switch (ljGridObject.d)
                if (ljGridObject == null)
                {
                    continue;
                }

                if (!prefabBrush.showObjLayerInfo)
                {
                    continue;
                }

                stringBuilder.Remove(0, stringBuilder.Length);

                switch (ljGridObject.MainType)
                {
                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.UNDEFINE:
                    stringBuilder.Append("未定义");
                    break;

                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.WONDER:
                    stringBuilder.Append("域都");
                    break;

                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.CITY:
                    stringBuilder.Append("卫都");

                    break;

                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.GATE:
                    stringBuilder.Append("关隘");

                    break;

                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.TOWN:
                    stringBuilder.Append("城镇");
                    break;

                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.RESOURCE:
                    stringBuilder.Append("资源区");
                    break;

                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.TREASURE:
                    stringBuilder.Append("讨伐区");
                    break;
                }

                switch (ljGridObject.MainType)
                {
                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.UNDEFINE:
                    break;

                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.WONDER:
                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.CITY:
                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.GATE:
                    switch (ljGridObject.SubType)
                    {
                    case LJMapConst.MAP_OBJ_SUB_TYPE.UNDEFINE:
                        stringBuilder.Append(" 未定义 ");

                        break;

                    case LJMapConst.MAP_OBJ_SUB_TYPE.WONDER_PART_OUTSIDE:
                        stringBuilder.Append(" 外层 ");
                        break;

                    case LJMapConst.MAP_OBJ_SUB_TYPE.WONDER_PART_INNER:
                        stringBuilder.Append(" 内层 ");
                        break;

                    case LJMapConst.MAP_OBJ_SUB_TYPE.WONDER_PART_KERNEL:
                        stringBuilder.Append(" 核心 ");
                        break;

                    case LJMapConst.MAP_OBJ_SUB_TYPE.WONDER_PART_UNUSERD:
                        stringBuilder.Append(" 阻塞 ");
                        break;

                    case LJMapConst.MAP_OBJ_SUB_TYPE.PART:

                        break;
                    }

                    break;

                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.TOWN:
                    //stringBuilder.AppendFormat("id : {0}", ljGridObject.GetGridObjectId());
                    break;

                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.RESOURCE:
                    //stringBuilder.AppendFormat("id : {0}", ljGridObject.MainId);
                    break;

                case LJTilemaps.LJMapConst.MAP_OBJ_MAIN_TYPE.TREASURE:
                    //stringBuilder.AppendFormat("id : {0}", ljGridObject.MainId);
                    break;
                }
                stringBuilder.AppendFormat("id : {0}", ljGridObject.GetGridObjectId());
                Handles.color = Color.green;
                Handles.Label(cellCorners[4], stringBuilder.ToString(), GUI.skin.customStyles[4]);
            }
        }