Exemplo n.º 1
0
        public void Invoke()
        {
            var grid     = m_gridReference.Value;
            var pos      = m_gridPos.Value.Vector3Int();
            var gridTile = m_setData.GetTileIdx(grid[pos.x, pos.y, pos.z]);

            if (gridTile != m_auto.TileIdx)
            {
                return;
            }

            var belowTile = m_wall.TileIdx;
            var hasBelow  = pos.y > 0;

            if (hasBelow)
            {
                belowTile = m_setData.GetTileIdx(m_gridReference.Value[pos.x, pos.y - 1, pos.z]);
            }

            if (belowTile == m_floor.TileIdx || belowTile == m_empty.TileIdx)
            {
                grid[pos.x, pos.y, pos.z] = m_setData.GetCombinedTile(gridTile, m_empty.TileIdx);
            }
            else if (belowTile == m_wall.TileIdx)
            {
                grid[pos.x, pos.y, pos.z] = m_setData.GetCombinedTile(gridTile, m_floor.TileIdx);
            }
        }
Exemplo n.º 2
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);
        }
Exemplo 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);
                }
            }
        }
Exemplo n.º 4
0
        public void Invoke()
        {
            var grid    = m_grid.Value;
            var pos     = m_currentPos.Value.Vector3Int();
            var tile    = grid[pos.x, pos.y, pos.z];
            var texType = m_texConfigSetData.GetTileIdx(tile);

            m_tilesSetFilter.SetValue(new TilesSetFilter()
            {
                Data      = m_texConfigSetData,
                FilterIdx = texType
            });
        }
Exemplo n.º 5
0
        public void Invoke()
        {
            var grid = m_grid.Value;
            var pos  = m_currentPos.Value.Vector3Int();
            var tile = grid[pos.x, pos.y, pos.z];

            var idx = m_setData.GetTileIdx(tile);

            //Debug.Log($"TileType Switch {pos} combined: {tile} idx: {idx}");
            if (m_actions.IsIndexInRange(idx))
            {
                m_actions[idx]?.Invoke();
            }
        }
Exemplo n.º 6
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();
            }
        }