diff --git a/DungeonShooting_Godot/prefab/ui/RoomMap.tscn b/DungeonShooting_Godot/prefab/ui/RoomMap.tscn index 8e35f8c..b9d07e0 100644 --- a/DungeonShooting_Godot/prefab/ui/RoomMap.tscn +++ b/DungeonShooting_Godot/prefab/ui/RoomMap.tscn @@ -42,7 +42,6 @@ patch_margin_bottom = 2 [node name="DrawContainer" type="TextureRect" parent="MapBar"] -clip_children = 1 layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -57,7 +56,6 @@ expand_mode = 1 [node name="Root" type="Node2D" parent="MapBar/DrawContainer"] -scale = Vector2(0.083, 0.083) [node name="Mark" type="Sprite2D" parent="MapBar/DrawContainer"] modulate = Color(0.219608, 1, 0, 1) diff --git a/DungeonShooting_Godot/scene/World.tscn b/DungeonShooting_Godot/scene/World.tscn index 76eca4e..bead9d8 100644 --- a/DungeonShooting_Godot/scene/World.tscn +++ b/DungeonShooting_Godot/scene/World.tscn @@ -27,28 +27,12 @@ layer_0/name = "Floor" layer_0/z_index = -10 layer_1/name = "Middle" -layer_1/enabled = true -layer_1/modulate = Color(1, 1, 1, 1) -layer_1/y_sort_enabled = false -layer_1/y_sort_origin = 0 -layer_1/z_index = 0 -layer_1/navigation_enabled = true layer_1/tile_data = PackedInt32Array() layer_2/name = "Top" -layer_2/enabled = true -layer_2/modulate = Color(1, 1, 1, 1) -layer_2/y_sort_enabled = false -layer_2/y_sort_origin = 0 layer_2/z_index = 10 -layer_2/navigation_enabled = true layer_2/tile_data = PackedInt32Array() layer_3/name = "AisleFloor" -layer_3/enabled = true -layer_3/modulate = Color(1, 1, 1, 1) -layer_3/y_sort_enabled = false -layer_3/y_sort_origin = 0 layer_3/z_index = -10 -layer_3/navigation_enabled = true layer_3/tile_data = PackedInt32Array() [node name="StaticSpriteRoot" type="Node2D" parent="."] diff --git a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs index cd1414f..4266864 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs @@ -74,12 +74,42 @@ } else { - //var rectSize = roomInfo.RoomSplit.RoomInfo.Size; var rectPos = roomInfo.RoomSplit.RoomInfo.Position.AsVector2I(); - //var offset = roomInfo.GetOffsetPosition() / GameConfig.TileCellSizeVector2I; - - //填充tile操作 var tileInfo = roomInfo.RoomSplit.TileInfo; + + //---------------------- 生成房间小地图预览 ---------------------- + //先计算范围 + var x = int.MaxValue; + var y = int.MaxValue; + var x2 = int.MinValue; + var y2 = int.MinValue; + for (var i = 0; i < tileInfo.Floor.Count; i += 5) + { + var posX = tileInfo.Floor[i]; + var posY = tileInfo.Floor[i + 1]; + x = Mathf.Min(x, posX); + x2 = Mathf.Max(x2, posX); + y = Mathf.Min(y, posY); + y2 = Mathf.Max(y2, posY); + } + //创建image, 这里留两个像素宽高用于描边 + var image = Image.Create(x2 - x + 2, y2 - y + 2, 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(0, 0, Colors.Blue); + //创建texture + var imageTexture = ImageTexture.CreateFromImage(image); + roomInfo.PreviewTexture = imageTexture; + roomInfo.PreviewOffset = new Vector2(-x, -y); + + //---------------------- 填充tile操作 ---------------------- //底层 for (var i = 0; i < tileInfo.Floor.Count; i += 5) { @@ -114,7 +144,7 @@ _tileRoot.SetCell(GameConfig.TopMapLayer, pos, sourceId, new Vector2I(atlasCoordsX, atlasCoordsY)); } - //随机选择预设 + //---------------------- 随机选择预设 ---------------------- RoomPreinstallInfo preinstallInfo; if (EditorPlayManager.IsPlay && roomInfo.RoomType == GameApplication.Instance.DungeonManager.CurrConfig.DesignatedType) //编辑器模式, 指定预设 { diff --git a/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs b/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs index 1266033..8da9070 100644 --- a/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs @@ -119,8 +119,19 @@ /// 用于标记攻击目标位置 /// public Dictionary MarkTargetPosition { get; private set; } = new Dictionary(); + + /// + /// 房间预览图, 用于小地图 + /// + public ImageTexture PreviewTexture { get; set; } + + /// + /// 预览图偏移, 单位: 格 + /// + public Vector2 PreviewOffset { get; set; } public bool IsDestroyed { get; private set; } + private bool _openDoorFlag = true; // private bool _beReady = false; @@ -369,6 +380,12 @@ { AffiliationArea.Destroy(); } + + //销毁预览图 + if (PreviewTexture != null) + { + PreviewTexture.Dispose(); + } MarkTargetPosition.Clear(); } diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index 944c3ed..e4caf19 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.2f, 0.2f); - //GameCamera.Main.Zoom = new Vector2(0.5f, 0.5f); + 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/room/World.cs b/DungeonShooting_Godot/src/game/room/World.cs index 35673f9..9ede9f2 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 265fac5..5f759e2 100644 --- a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs @@ -29,7 +29,8 @@ // World.Current.Pause = false; // } - 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.Position = S_DrawContainer.Instance.Size / 2 - Player.Current.Position / 12; } private void DrawRoom() @@ -37,40 +38,45 @@ var startRoom = GameApplication.Instance.DungeonManager.StartRoomInfo; startRoom.EachRoom(roomInfo => { - //房间区域 - var navigationPolygonData = roomInfo.RoomSplit.TileInfo.NavigationList[0]; - var points = navigationPolygonData.GetPoints(); - var newPoints = new Vector2[points.Length]; - for (var i = 0; i < points.Length; i++) - { - newPoints[i] = roomInfo.ToGlobalPosition(points[i]); - } - - var outline = new PolygonOutline(); - outline.SetPoints(newPoints); - S_Root.AddChild(outline); - - //过道 - if (roomInfo.Doors != null) - { - foreach (var doorInfo in roomInfo.Doors) - { - if (doorInfo.IsForward) - { - var aislePoints = doorInfo.AisleNavigation.GetPoints(); - // var newAislePoints = new Vector2[aislePoints.Length]; - // for (var i = 0; i < aislePoints.Length; i++) - // { - // newAislePoints[i] = roomInfo.ToGlobalPosition(aislePoints[i]); - // } - - var aisleOutline = new PolygonOutline(); - aisleOutline.SetPoints(aislePoints); - S_Root.AddChild(aisleOutline); - } - } - } - //roomInfo.Doors[0].Navigation.OpenNavigationData + var sprite = new Sprite2D(); + sprite.Texture = roomInfo.PreviewTexture; + sprite.Offset = roomInfo.PreviewOffset; + sprite.Position = roomInfo.Position; + S_Root.AddChild(sprite); + // //房间区域 + // var navigationPolygonData = roomInfo.RoomSplit.TileInfo.NavigationList[0]; + // var points = navigationPolygonData.GetPoints(); + // var newPoints = new Vector2[points.Length]; + // for (var i = 0; i < points.Length; i++) + // { + // newPoints[i] = roomInfo.ToGlobalPosition(points[i]); + // } + // + // var outline = new PolygonOutline(); + // outline.SetPoints(newPoints); + // S_Root.AddChild(outline); + // + // //过道 + // if (roomInfo.Doors != null) + // { + // foreach (var doorInfo in roomInfo.Doors) + // { + // if (doorInfo.IsForward) + // { + // var aislePoints = doorInfo.AisleNavigation.GetPoints(); + // // var newAislePoints = new Vector2[aislePoints.Length]; + // // for (var i = 0; i < aislePoints.Length; i++) + // // { + // // newAislePoints[i] = roomInfo.ToGlobalPosition(aislePoints[i]); + // // } + // + // var aisleOutline = new PolygonOutline(); + // aisleOutline.SetPoints(aislePoints); + // S_Root.AddChild(aisleOutline); + // } + // } + // } + // //roomInfo.Doors[0].Navigation.OpenNavigationData }); }