diff --git a/DungeonShooting_Godot/project.godot b/DungeonShooting_Godot/project.godot
index c5ef034..2cdff19 100644
--- a/DungeonShooting_Godot/project.godot
+++ b/DungeonShooting_Godot/project.godot
@@ -11,7 +11,7 @@
[application]
config/name="DungeonShooting"
-run/main_scene="res://scene/Main.tscn"
+run/main_scene="res://scene/test/TestNavigation2.tscn"
config/icon="res://icon.png"
[autoload]
diff --git a/DungeonShooting_Godot/scene/test/TestNavigation2.tscn b/DungeonShooting_Godot/scene/test/TestNavigation2.tscn
new file mode 100644
index 0000000..d1577f4
--- /dev/null
+++ b/DungeonShooting_Godot/scene/test/TestNavigation2.tscn
@@ -0,0 +1,29 @@
+[gd_scene load_steps=4 format=2]
+
+[ext_resource path="res://src/test/TestNavigation2.cs" type="Script" id=1]
+[ext_resource path="res://icon.png" type="Texture" id=2]
+
+[sub_resource type="NavigationPolygon" id=1]
+vertices = PoolVector2Array( 1650, 237, 1789, 81, 1795, 986, 1635, 828, 1627, 721, 1215, 660, 1070, 733, 62, 978, 975, 834, 888, 830, 806, 831, 1123, 576, 1033, 218, 1563, 162, 950, 211, 883, 208, 288, 833, 286, 610, 807, 609, 208, 836, 79, 73, 212, 202, 796, 205, 795, 525, 300, 527, 292, 192 )
+polygons = [ PoolIntArray( 0, 1, 2, 3, 4 ), PoolIntArray( 5, 0, 4 ), PoolIntArray( 5, 4, 6 ), PoolIntArray( 3, 2, 7, 8 ), PoolIntArray( 9, 8, 7, 10 ), PoolIntArray( 11, 5, 6 ), PoolIntArray( 11, 6, 12 ), PoolIntArray( 13, 11, 12 ), PoolIntArray( 14, 8, 9, 15 ), PoolIntArray( 16, 17, 18, 10 ), PoolIntArray( 16, 10, 7, 19 ), PoolIntArray( 19, 7, 20, 21 ), PoolIntArray( 22, 23, 24, 25 ), PoolIntArray( 1, 0, 13 ), PoolIntArray( 20, 1, 13, 12, 14 ), PoolIntArray( 20, 14, 15 ), PoolIntArray( 20, 15, 22 ), PoolIntArray( 20, 22, 25 ), PoolIntArray( 20, 25, 21 ) ]
+outlines = [ PoolVector2Array( 79, 73, 62, 978, 1795, 986, 1789, 81 ), PoolVector2Array( 212, 202, 208, 836, 288, 833, 286, 610, 807, 609, 806, 831, 888, 830, 883, 208, 796, 205, 795, 525, 300, 527, 292, 192 ), PoolVector2Array( 950, 211, 975, 834, 1635, 828, 1627, 721, 1070, 733, 1033, 218 ), PoolVector2Array( 1123, 576, 1215, 660, 1650, 237, 1563, 162 ) ]
+
+[node name="TestNavigation2" type="Node2D"]
+script = ExtResource( 1 )
+
+[node name="Navigation2D" type="Navigation2D" parent="."]
+
+[node name="NavigationPolygonInstance" type="NavigationPolygonInstance" parent="Navigation2D"]
+navpoly = SubResource( 1 )
+
+[node name="Enemy" type="Sprite" parent="Navigation2D"]
+position = Vector2( 129, 118 )
+texture = ExtResource( 2 )
+
+[node name="NavigationAgent2D" type="NavigationAgent2D" parent="Navigation2D/Enemy"]
+
+[node name="Timer" type="Timer" parent="Navigation2D/Enemy"]
+process_mode = 0
+autostart = true
+
+[connection signal="timeout" from="Navigation2D/Enemy/Timer" to="." method="_on_Timer_timeout"]
diff --git a/DungeonShooting_Godot/src/game/role/PathSign.cs b/DungeonShooting_Godot/src/game/role/PathSign.cs
index a3487ed..078c3e4 100644
--- a/DungeonShooting_Godot/src/game/role/PathSign.cs
+++ b/DungeonShooting_Godot/src/game/role/PathSign.cs
@@ -177,6 +177,19 @@
RayCast.ForceRaycastUpdate();
var flag = RayCast.IsColliding();
+ // if (flag)
+ // {
+ // var collider = RayCast.GetCollider();
+ // if (collider is TileMap tileMap)
+ // {
+ // var tilesIds = tileMap.TileSet.GetTilesIds();
+ // var collPos = RayCast.GetCollisionPoint();
+ // // tileMap.TileSet.TileGetShape()
+ // // var colliderShape = RayCast.GetColliderShape();
+ // //GD.Print(fullName + ", " + colliderShape);
+ // }
+ //
+ // }
RayCast.Enabled = false;
return flag;
}
diff --git a/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs
index 7eb9c12..5ed7de4 100644
--- a/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs
+++ b/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs
@@ -88,8 +88,10 @@
public void OnObjectEnter(RID id, Node node, int shapeIndex, int localShapeIndex)
{
+ GD.Print($"id: {id}, node: {node}, shapeIndex: {shapeIndex}, localShapeIndex: {localShapeIndex}.");
if (node is TileMap tileMap)
{
+ //tileMap.TileSet.id
// var tileGetShape = tileMap.TileSet.TileGetShapeTransform(shapeIndex, localShapeIndex).;
// GD.Print("enter: ", tileGetShape.GetType().FullName);
}
diff --git a/DungeonShooting_Godot/src/test/TestNavigation.cs b/DungeonShooting_Godot/src/test/TestNavigation.cs
index 4c55343..7d1447f 100644
--- a/DungeonShooting_Godot/src/test/TestNavigation.cs
+++ b/DungeonShooting_Godot/src/test/TestNavigation.cs
@@ -1,6 +1,8 @@
using Godot;
-//测试导航
+///
+/// 该demo是以3.4为基础做的导航demo, 后面3.5出了新的导航系统, 游戏中已采用新的导航方案
+///
public class TestNavigation : Node2D
{
diff --git a/DungeonShooting_Godot/src/test/TestNavigation2.cs b/DungeonShooting_Godot/src/test/TestNavigation2.cs
new file mode 100644
index 0000000..0fb004c
--- /dev/null
+++ b/DungeonShooting_Godot/src/test/TestNavigation2.cs
@@ -0,0 +1,57 @@
+using Godot;
+
+public class TestNavigation2 : Node2D
+{
+ private Navigation2D _navigation2D;
+
+
+ private Sprite _enemy;
+ private NavigationAgent2D _navigationAgent2D;
+
+ public override void _Ready()
+ {
+ _navigation2D = GetNode("Navigation2D");
+ _enemy = _navigation2D.GetNode("Enemy");
+ _navigationAgent2D = _enemy.GetNode("NavigationAgent2D");
+
+ _navigationAgent2D.SetTargetLocation(GetGlobalMousePosition());
+
+ }
+
+ public override void _PhysicsProcess(float delta)
+ {
+ if (_navigationAgent2D.IsNavigationFinished())
+ {
+ return;
+ }
+
+ var pos = _navigationAgent2D.GetNextLocation();
+ _enemy.GlobalPosition = _enemy.GlobalPosition.MoveToward(pos, 100 * delta);
+
+ }
+
+ public override void _Process(float delta)
+ {
+ Update();
+ }
+
+ public override void _Draw()
+ {
+ var points = _navigationAgent2D.GetNavPath();
+ if (points != null && points.Length >= 2)
+ {
+ DrawPolyline(points, Colors.Red);
+ DrawMultiline(points, Colors.Red);
+ }
+ }
+
+ private void _on_Timer_timeout()
+ {
+ var target = GetGlobalMousePosition();
+ if (_navigationAgent2D.GetTargetLocation() != target)
+ {
+ GD.Print("更新目标位置...");
+ _navigationAgent2D.SetTargetLocation(target);
+ }
+ }
+}
\ No newline at end of file