diff --git a/DungeonShooting_Godot/DungeonShooting.csproj b/DungeonShooting_Godot/DungeonShooting.csproj index 0ec0eeb..d4bfee3 100644 --- a/DungeonShooting_Godot/DungeonShooting.csproj +++ b/DungeonShooting_Godot/DungeonShooting.csproj @@ -1,4 +1,4 @@ - + net7.0 true diff --git a/DungeonShooting_Godot/prefab/ui/RoomMap.tscn b/DungeonShooting_Godot/prefab/ui/RoomMap.tscn index b9d07e0..d2f68b0 100644 --- a/DungeonShooting_Godot/prefab/ui/RoomMap.tscn +++ b/DungeonShooting_Godot/prefab/ui/RoomMap.tscn @@ -42,6 +42,7 @@ patch_margin_bottom = 2 [node name="DrawContainer" type="TextureRect" parent="MapBar"] +clip_children = 1 layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -56,6 +57,7 @@ expand_mode = 1 [node name="Root" type="Node2D" parent="MapBar/DrawContainer"] +scale = Vector2(1.5, 1.5) [node name="Mark" type="Sprite2D" parent="MapBar/DrawContainer"] modulate = Color(0.219608, 1, 0, 1) diff --git a/DungeonShooting_Godot/resource/material/Outline.tres b/DungeonShooting_Godot/resource/material/Outline.tres new file mode 100644 index 0000000..c789b00 --- /dev/null +++ b/DungeonShooting_Godot/resource/material/Outline.tres @@ -0,0 +1,8 @@ +[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://j8t31iuumvhr"] + +[ext_resource type="Shader" path="res://resource/material/Outline.gdshader" id="1_neih8"] + +[resource] +resource_local_to_scene = true +shader = ExtResource("1_neih8") +shader_parameter/outline_color = Color(0, 0, 0, 1) diff --git a/DungeonShooting_Godot/resource/material/Outline2.gdshader b/DungeonShooting_Godot/resource/material/Outline2.gdshader new file mode 100644 index 0000000..2f6d088 --- /dev/null +++ b/DungeonShooting_Godot/resource/material/Outline2.gdshader @@ -0,0 +1,30 @@ +shader_type canvas_item; + +//轮廓颜色 +uniform vec4 outline_color : source_color = vec4(0.0, 0.0, 0.0, 1.0); +//轮廓缩放 +uniform float scale : hint_range(0.0, 2.0, 0.01) = 1.0; + +void fragment() { + float a = COLOR.a; + //显示轮廓 + if (a == 0.0) { + vec2 size = TEXTURE_PIXEL_SIZE * 0.5; + float outline; + outline = texture(TEXTURE, UV + vec2(-size.x, 0)).a; + outline += texture(TEXTURE, UV + vec2(0, size.y)).a; + outline += texture(TEXTURE, UV + vec2(size.x, 0)).a; + outline += texture(TEXTURE, UV + vec2(0, -size.y)).a; + + outline += texture(TEXTURE, UV + vec2(-size.x, -size.y)).a; + outline += texture(TEXTURE, UV + vec2(size.x, size.y)).a; + outline += texture(TEXTURE, UV + vec2(size.x, -size.y)).a; + outline += texture(TEXTURE, UV + vec2(-size.x, size.y)).a; + + outline = min(outline, 1.0); + if (outline > 0.0) { + COLOR = mix(COLOR, outline_color , 1); + COLOR.a = outline_color.a; + } + } +} diff --git a/DungeonShooting_Godot/resource/material/Outline2.tres b/DungeonShooting_Godot/resource/material/Outline2.tres new file mode 100644 index 0000000..dd8cdb5 --- /dev/null +++ b/DungeonShooting_Godot/resource/material/Outline2.tres @@ -0,0 +1,9 @@ +[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://jywcy17le5fd"] + +[ext_resource type="Shader" path="res://resource/material/Outline2.gdshader" id="1_skooq"] + +[resource] +resource_local_to_scene = true +shader = ExtResource("1_skooq") +shader_parameter/outline_color = Color(0, 0, 0, 1) +shader_parameter/scale = 1.0 diff --git a/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs b/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs index 7047dfa..fb2a11c 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs @@ -63,8 +63,8 @@ //区域限制 private bool _enableLimitRange = true; - private int _rangeX = 200; - private int _rangeY = 200; + private int _rangeX = 150; + private int _rangeY = 150; //找房间失败次数, 过大则会关闭区域限制 private int _maxFailCount = 10; @@ -273,8 +273,11 @@ Debug.Log("超出区域失败次数: " + _failCount); if (_failCount >= _maxFailCount) { - _enableLimitRange = false; - Debug.Log("生成房间失败次数过多, 关闭区域限制!"); + //_enableLimitRange = false; + _failCount = 0; + _rangeX += 50; + _rangeY += 50; + Debug.Log("生成房间失败次数过多, 增大区域"); } } } diff --git a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs index 4266864..f61a230 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs @@ -93,21 +93,18 @@ y2 = Mathf.Max(y2, posY); } //创建image, 这里留两个像素宽高用于描边 - var image = Image.Create(x2 - x + 2, y2 - y + 2, false, Image.Format.Rgba8); - image.Fill(Colors.Green); + var image = Image.Create(x2 - x + 3, y2 - y + 3, false, Image.Format.Rgba8); + //image.Fill(Colors.Green); //填充像素点 for (var i = 0; i < tileInfo.Floor.Count; i += 5) { var posX = tileInfo.Floor[i] - x + 1; var posY = tileInfo.Floor[i + 1] - y + 1; - image.SetPixel(posX, posY, new Color(1, 0, 0, 0.5882353F)); - //image.SetPixel(posX, posY, new Color(0, 0, 0, 0.5882353F)); + image.SetPixel(posX, posY, new Color(0, 0, 0, 0.5882353F)); } - image.SetPixel(0, 0, Colors.Blue); //创建texture var imageTexture = ImageTexture.CreateFromImage(image); roomInfo.PreviewTexture = imageTexture; - roomInfo.PreviewOffset = new Vector2(-x, -y); //---------------------- 填充tile操作 ---------------------- //底层 diff --git a/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs b/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs index 8da9070..698bccc 100644 --- a/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs @@ -124,12 +124,7 @@ /// 房间预览图, 用于小地图 /// public ImageTexture PreviewTexture { get; set; } - - /// - /// 预览图偏移, 单位: 格 - /// - public Vector2 PreviewOffset { get; set; } - + public bool IsDestroyed { get; private set; } private bool _openDoorFlag = true; diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index e4caf19..9bae83c 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs @@ -61,13 +61,13 @@ WeaponPack.SetCapacity(4); // debug用 - RoleState.Acceleration = 3000; - RoleState.Friction = 3000; - RoleState.MoveSpeed = 500; - CollisionLayer = 0; - CollisionMask = 0; + // RoleState.Acceleration = 3000; + // RoleState.Friction = 3000; + // RoleState.MoveSpeed = 500; + // CollisionLayer = 0; + // CollisionMask = 0; + // GameCamera.Main.Zoom = new Vector2(0.5f, 0.5f); //GameCamera.Main.Zoom = new Vector2(0.2f, 0.2f); - GameCamera.Main.Zoom = new Vector2(0.5f, 0.5f); // this.CallDelay(0.5f, () => // { // var weapon = Create(Ids.Id_weapon0009); diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs index 167ca03..fd73c61 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -113,6 +113,10 @@ public const string resource_material_Blend_tres = "res://resource/material/Blend.tres"; public const string resource_material_Mask_gdshader = "res://resource/material/Mask.gdshader"; public const string resource_material_OffsetVertex_gdshader = "res://resource/material/OffsetVertex.gdshader"; + public const string resource_material_Outline_gdshader = "res://resource/material/Outline.gdshader"; + public const string resource_material_Outline_tres = "res://resource/material/Outline.tres"; + public const string resource_material_Outline2_gdshader = "res://resource/material/Outline2.gdshader"; + public const string resource_material_Outline2_tres = "res://resource/material/Outline2.tres"; public const string resource_material_Sawtooth_gdshader = "res://resource/material/Sawtooth.gdshader"; public const string resource_material_Sawtooth_tres = "res://resource/material/Sawtooth.tres"; public const string resource_material_SmokeParticleMaterial_tres = "res://resource/material/SmokeParticleMaterial.tres"; @@ -272,6 +276,7 @@ public const string resource_sprite_ui_commonIcon_Add_png = "res://resource/sprite/ui/commonIcon/Add.png"; public const string resource_sprite_ui_commonIcon_AreaTool_png = "res://resource/sprite/ui/commonIcon/AreaTool.png"; public const string resource_sprite_ui_commonIcon_Back_png = "res://resource/sprite/ui/commonIcon/Back.png"; + public const string resource_sprite_ui_commonIcon_Block_png = "res://resource/sprite/ui/commonIcon/Block.png"; public const string resource_sprite_ui_commonIcon_CenterTool_png = "res://resource/sprite/ui/commonIcon/CenterTool.png"; public const string resource_sprite_ui_commonIcon_Delete_png = "res://resource/sprite/ui/commonIcon/Delete.png"; public const string resource_sprite_ui_commonIcon_DoorTool_png = "res://resource/sprite/ui/commonIcon/DoorTool.png"; @@ -295,7 +300,6 @@ public const string resource_sprite_ui_commonIcon_Visible_png = "res://resource/sprite/ui/commonIcon/Visible.png"; public const string resource_sprite_ui_commonIcon_WaveCell_png = "res://resource/sprite/ui/commonIcon/WaveCell.png"; public const string resource_sprite_ui_keyboard_e_png = "res://resource/sprite/ui/keyboard/e.png"; - public const string resource_sprite_ui_mapEditor_ErrorCell_png = "res://resource/sprite/ui/mapEditor/ErrorCell.png"; public const string resource_sprite_ui_mapEditorProject_CellBg_png = "res://resource/sprite/ui/mapEditorProject/CellBg.png"; public const string resource_sprite_ui_mapEditorTools_DoorDragButton_png = "res://resource/sprite/ui/mapEditorTools/DoorDragButton.png"; public const string resource_sprite_ui_mapEditorTools_DoorDragButton_down_png = "res://resource/sprite/ui/mapEditorTools/DoorDragButton_down.png"; diff --git a/DungeonShooting_Godot/src/game/room/World.cs b/DungeonShooting_Godot/src/game/room/World.cs index 9ede9f2..35673f9 100644 --- a/DungeonShooting_Godot/src/game/room/World.cs +++ b/DungeonShooting_Godot/src/game/room/World.cs @@ -69,7 +69,7 @@ public override void _Ready() { - //Color = Colors.Black; + Color = Colors.Black; //临时处理, 加载TileSet var tileSet = ResourceManager.Load(ResourcePath.resource_map_tileSet_map1_TileSet1_tres); diff --git a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs index 5f759e2..587ae83 100644 --- a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs @@ -29,8 +29,7 @@ // World.Current.Pause = false; // } - S_Root.Instance.Position = S_DrawContainer.Instance.Size / 2 - Player.Current.Position / 16; - //S_Root.Instance.Position = S_DrawContainer.Instance.Size / 2 - Player.Current.Position / 12; + S_Root.Instance.Position = S_DrawContainer.Instance.Size / 2 - Player.Current.Position / 16 * S_Root.Instance.Scale; } private void DrawRoom() @@ -39,9 +38,13 @@ startRoom.EachRoom(roomInfo => { var sprite = new Sprite2D(); + sprite.Centered = false; sprite.Texture = roomInfo.PreviewTexture; - sprite.Offset = roomInfo.PreviewOffset; sprite.Position = roomInfo.Position; + var material = ResourceManager.Load(ResourcePath.resource_material_Outline2_tres); + material.SetShaderParameter("outline_color", new Color(1, 1, 1, 0.9f)); + material.SetShaderParameter("scale", 0.5f); + sprite.Material = material; S_Root.AddChild(sprite); // //房间区域 // var navigationPolygonData = roomInfo.RoomSplit.TileInfo.NavigationList[0];