Ejemplo n.º 1
0
        public ushort NextType(TilesSetData iterationSet, TilesSetFilter[] filters,
                               ref int startNode, ref ushort[] texTypeDone, ref int texTypesDoneIdx)
        {
            var grid = m_grid.Value;
            var pos  = m_currentPos.Value.Vector3Int();

            for (; startNode < IterationOffset.Length; ++startNode)
            {
                var off  = IterationOffset[startNode];
                var tile = grid[pos.x + off.x, pos.y + off.y, pos.z + off.z];

                var ignoreTile = filters.Any(filter => !filter.IsTileActive(tile));
                if (ignoreTile)
                {
                    continue;
                }

                var type = iterationSet.GetTileIdx(tile);

                if (texTypeDone.Any(t => t == tile))
                {
                    continue;
                }
                texTypeDone[texTypesDoneIdx] = tile;
                texTypesDoneIdx++;

                return(type);
            }
            return(ushort.MaxValue);
        }
Ejemplo n.º 2
0
        static void DrawTile(TilesSetData tilesSetData, DebugDrawSettings settings, float rx, Vector3 pos, float rz, ushort tile)
        {
            var center = new Vector3(rx,
                                     pos.y * settings.YMult.y + rz * settings.ZMult.y,
                                     rz * settings.ZMult.z + pos.y * settings.YMult.z);

            GetDebugDrawVertices(settings, center, out var v1, out var v2, out var v3, out var v4);
            GetDebugDrawColor(settings, tilesSetData, tile, out var faceCol, out var outlineCol);

            var previewTex = tilesSetData[tile].PreviewTex;

            if (settings.DrawDebugTiles)
            {
                Handles.DrawSolidRectangleWithOutline(new[] { v1, v2, v3, v4 }, faceCol, outlineCol);
            }

            var label = settings.DrawLabel ? tilesSetData[tile].TileName : "";
            var image = settings.DrawDots ? previewTex : null;

            if (settings.DrawDots || settings.DrawLabel)
            {
                Handles.Label(center, new GUIContent()
                {
                    text = label, image = image
                });
            }
        }
Ejemplo n.º 3
0
        public static void DrawGeometryType(IPlatformLayer layer,
                                            TilesSetData tilesSetData, DebugDrawSettings settings)
        {
            var posOffset = layer.PositionOffset;
            var gridSize  = layer.GridSize;

            for (var x = 0; x < layer.TileDim.x; ++x)
            {
                for (var z = 0; z < layer.TileDim.y; ++z)
                {
                    var pos = new Vector3(posOffset.x + layer.Position.x, posOffset.y, posOffset.z + layer.Position.y);
                    var rx  = gridSize * x + pos.x;
                    var rz  = gridSize * z + pos.z;

                    var tile = tilesSetData.GetTileIdx(GetTile(layer, layer, x, z));

                    if (tile >= tilesSetData.Count)
                    {
                        return;
                    }

                    DrawTile(tilesSetData, settings, rx, pos, rz, tile);
                }
            }
        }
Ejemplo n.º 4
0
 public SelectTextureTypeFromTileAction(
     TilesSetData setData,
     GridReference grid,
     Vector3Reference currentPos,
     TilesSetFilterReference tsf)
 {
     m_grid             = grid;
     m_currentPos       = currentPos;
     m_tilesSetFilter   = tsf;
     m_texConfigSetData = setData;
 }
Ejemplo n.º 5
0
        public TileTypeSwitchAction(TilesSetListConfig sourceConfig,
                                    ITileConfig config,
                                    GridReference grid,
                                    Vector3Reference currentPos,
                                    IDefaultAction[] actions)
        {
            m_setData = sourceConfig.GetSet(config);

            m_grid       = grid;
            m_currentPos = currentPos;

            m_actions = actions;
        }
Ejemplo n.º 6
0
 public UpdateAutoTileAction(GridReference gr, Vector3Reference gridPos,
                             TilesSetData setData,
                             TileTypeIdentifier auto, TileTypeIdentifier floor,
                             TileTypeIdentifier wall, TileTypeIdentifier empty)
 {
     m_gridReference = gr;
     m_gridPos       = gridPos;
     m_setData       = setData;
     m_auto          = auto;
     m_floor         = floor;
     m_wall          = wall;
     m_empty         = empty;
 }
Ejemplo n.º 7
0
        public static bool TileTypesActiveGUI(ref TileDrawingOpData opDat, TilesSetData tileSetData)
        {
            var active = (opDat.TileTypesMask & tileSetData.Mask) != 0;

            if (GUILayout.Toggle(active, tileSetData.TileConfig.Result?.Name, "Button", GUILayout.Width(150f)) == active)
            {
                return(active);
            }

            active = !active;
            if (active)
            {
                opDat.TileTypesMask |= tileSetData.Mask;
            }
            else
            {
                opDat.TileTypesMask &= (ushort)~tileSetData.Mask;
            }

            return(active);
            //Debug.Log($"opDat-mask {opDat.TileTypesMask} tileSet-mask: {tileSetData.Mask} active: {active}");
        }
        public AddDefaultCustomFlagsAction(TilesSetListConfig config,
                                           TileTypeIdentifier floorNode, TileTypeIdentifier wallNode,
                                           LevelTextureConfig texTypeConfig,

                                           Vector3Reference pos,
                                           GridReference sourceGrid,
                                           GridReference targetGrid,
                                           TilesSetData hardEdgeSet,
                                           TilesSetData floorTexTypesSet,
                                           TilesSetData activeFloorNodesSet)
        {
            m_tilesSetListConfig = config;
            m_floorNode          = floorNode;
            m_wallNode           = wallNode;
            m_texTypeConfig      = texTypeConfig;

            m_pos        = pos;
            m_sourceGrid = sourceGrid;
            m_targetGrid = targetGrid;

            m_hardEdgeSet         = hardEdgeSet;
            m_floorTexTypesSet    = floorTexTypesSet;
            m_activeFloorNodesSet = activeFloorNodesSet;
        }
Ejemplo n.º 9
0
 static void GetDebugDrawColor(DebugDrawSettings settings, TilesSetData tilesSetData, ushort tile, out Color faceCol, out Color outlineCol)
 {
     faceCol    = tilesSetData[tile].TileColor;
     faceCol.a *= settings.ColorAlpha;
     outlineCol = tilesSetData[tile].TileColor;
 }
Ejemplo n.º 10
0
        public static void TileSelectionGUI(ref TileDrawingOpData opDat, TilesSetData tileSetData)
        {
            //GUILayout.Label("Texture: ", GUILayout.Width(100));
            //if (ActivityButton2(_PaintTexLeft == -1, _PaintTexRight == -1, "None", GUILayout.Width(100)))
            //{
            //    if (Event.current.button == 1)
            //        _PaintTexRight = -1;
            //    else _PaintTexLeft = -1;
            //}

            ushort tIdx = 0;

            for (; tIdx < tileSetData.Count; ++tIdx)
            {
                var current = tileSetData.TileConfig?.Result[tIdx];
                if (current == null)
                {
                    continue;
                }

                if (tIdx % 5 == 0)
                {
                    EditorGUILayout.BeginHorizontal();
                }
                var toolName = current.TileName;

                //Texture2D previewTex = null;
                //var floorVar = current.FloorVariations;
                var lIdx = tileSetData.GetTileIdx(opDat.PaintTileTypeLeft);
                var rIdx = tileSetData.GetTileIdx(opDat.PaintTileTypeRight);

                if (CustomGUI.ActivityButton2(lIdx == tIdx, rIdx == tIdx, toolName,
                                              current.PreviewTex, GUILayout.Width(100)))
                {
                    //var prevLeft = _PaintTexLeft;
                    //var prevRight = _PaintTexRight;
                    if (Event.current.button == 1)
                    {
                        opDat.PaintTileTypeRight = tileSetData.GetCombinedTile(opDat.PaintTileTypeRight, tIdx);
                    }
                    else
                    {
                        opDat.PaintTileTypeLeft = tileSetData.GetCombinedTile(opDat.PaintTileTypeLeft, tIdx);
                    }

                    //if (_PaintTexLeft == _PaintTexRight && _PaintTileTypeLeft!= -1)
                    //{
                    //    if (Event.current.button == 1)
                    //        _PaintTexLeft = prevRight;
                    //    else _PaintTexRight = prevLeft;
                    //}
                }

                if (tIdx % 5 == 4)
                {
                    EditorGUILayout.EndHorizontal();
                }
            }

            if (tIdx % 5 != 0)
            {
                EditorGUILayout.EndHorizontal();
            }
        }