diff --git a/DungeonShooting_Art/effect/debug_arrows.aseprite b/DungeonShooting_Art/effect/debug_arrows.aseprite
new file mode 100644
index 0000000..7746f4d
--- /dev/null
+++ b/DungeonShooting_Art/effect/debug_arrows.aseprite
Binary files differ
diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs
index d85d71e..8ef405b 100644
--- a/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs
+++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/ActivityObjectTemplate.cs
@@ -14,6 +14,11 @@
[Export] public bool UseYSort;
///
+ /// 物体初始缩放
+ ///
+ [Export] public Vector2 Scale = Vector2.One;
+
+ ///
/// 当前物体所属物理层
///
[Export(PropertyHint.Layers2dPhysics)] public uint CollisionLayer;
diff --git a/DungeonShooting_Godot/resource/effects/debug_arrows.png b/DungeonShooting_Godot/resource/effects/debug_arrows.png
new file mode 100644
index 0000000..a92ff48
--- /dev/null
+++ b/DungeonShooting_Godot/resource/effects/debug_arrows.png
Binary files differ
diff --git a/DungeonShooting_Godot/resource/effects/debug_arrows.png.import b/DungeonShooting_Godot/resource/effects/debug_arrows.png.import
new file mode 100644
index 0000000..88148fd
--- /dev/null
+++ b/DungeonShooting_Godot/resource/effects/debug_arrows.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/debug_arrows.png-de39def0e104ff1cb28ee09cfa7420c8.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://resource/effects/debug_arrows.png"
+dest_files=[ "res://.import/debug_arrows.png-de39def0e104ff1cb28ee09cfa7420c8.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=false
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+process/invert_color=false
+process/normal_map_invert_y=false
+stream=false
+size_limit=0
+detect_3d=false
+svg/scale=1.0
diff --git a/DungeonShooting_Godot/src/framework/ActivityObject.cs b/DungeonShooting_Godot/src/framework/ActivityObject.cs
index 8bfbfa7..089ca37 100644
--- a/DungeonShooting_Godot/src/framework/ActivityObject.cs
+++ b/DungeonShooting_Godot/src/framework/ActivityObject.cs
@@ -78,6 +78,7 @@
CollisionLayer = tempNode.CollisionLayer;
CollisionMask = tempNode.CollisionMask;
UseYSort = tempNode.UseYSort;
+ Scale = tempNode.Scale;
//移动子节点
var count = tempNode.GetChildCount();
diff --git a/DungeonShooting_Godot/src/game/item/weapon/knife/Knife.cs b/DungeonShooting_Godot/src/game/item/weapon/knife/Knife.cs
index 02f5df5..60a3427 100644
--- a/DungeonShooting_Godot/src/game/item/weapon/knife/Knife.cs
+++ b/DungeonShooting_Godot/src/game/item/weapon/knife/Knife.cs
@@ -85,7 +85,7 @@
//播放挥刀特效
SpecialEffectManager.Play(
ResourcePath.resource_effects_KnifeHit1_tres, "default",
- Master.MountPoint.GlobalPosition, GlobalRotation + Mathf.Pi * 0.5f, new Vector2((int)Master.Face, 1),
+ Master.MountPoint.GlobalPosition, GlobalRotation + Mathf.Pi * 0.5f, new Vector2((int)Master.Face, 1) * AnimatedSprite.Scale,
new Vector2(17, 4), 1
);
}
diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs
index fc19176..51d66af 100644
--- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs
+++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs
@@ -25,6 +25,7 @@
public const string prefab_weapon_Weapon_tscn = "res://prefab/weapon/Weapon.tscn";
public const string prefab_weapon_bullet_Bullet_tscn = "res://prefab/weapon/bullet/Bullet.tscn";
public const string prefab_weapon_shell_ShellCase_tscn = "res://prefab/weapon/shell/ShellCase.tscn";
+ public const string resource_effects_debug_arrows_png = "res://resource/effects/debug_arrows.png";
public const string resource_effects_Hit_tres = "res://resource/effects/Hit.tres";
public const string resource_effects_KnifeHit1_tres = "res://resource/effects/KnifeHit1.tres";
public const string resource_font_cn_font_12_tres = "res://resource/font/cn_font_12.tres";
diff --git a/DungeonShooting_Godot/src/game/role/MountRotation.cs b/DungeonShooting_Godot/src/game/role/MountRotation.cs
index 8cd9054..cd8835b 100644
--- a/DungeonShooting_Godot/src/game/role/MountRotation.cs
+++ b/DungeonShooting_Godot/src/game/role/MountRotation.cs
@@ -51,12 +51,11 @@
{
angle = -angle;
}
-
GlobalRotationDegrees = AdsorptionAngle(angle);
}
private float AdsorptionAngle(float angle)
{
- return ((int)angle / _adsorption) * _adsorption;
+ return Mathf.Round(angle / _adsorption) * _adsorption;
}
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/role/PathSign.cs b/DungeonShooting_Godot/src/game/role/PathSign.cs
new file mode 100644
index 0000000..0b7f03e
--- /dev/null
+++ b/DungeonShooting_Godot/src/game/role/PathSign.cs
@@ -0,0 +1,32 @@
+
+using Godot;
+
+///
+/// 寻路标记, 记录下Role移动过的位置, 用于Ai寻路
+///
+public class PathSign : Node2D
+{
+ ///
+ /// 是否启用
+ ///
+ public bool Enable { get; set; }
+
+ ///
+ /// 创建标记
+ ///
+ /// 坐标
+ /// 用于debug, 显示箭头
+ public PathSign(Vector2 pos, bool debug = false)
+ {
+ GameApplication.Instance.Room.GetRoot(false).AddChild(this);
+ GlobalPosition = pos;
+
+ if (debug)
+ {
+ var sprite = new Sprite();
+ sprite.Texture = ResourceManager.Load(ResourcePath.resource_effects_debug_arrows_png);
+ sprite.Position = new Vector2(0, -sprite.Texture.GetHeight() * 0.5f);
+ AddChild(sprite);
+ }
+ }
+}
diff --git a/DungeonShooting_Godot/src/game/role/Player.cs b/DungeonShooting_Godot/src/game/role/Player.cs
index 8103e7f..5e0d434 100644
--- a/DungeonShooting_Godot/src/game/role/Player.cs
+++ b/DungeonShooting_Godot/src/game/role/Player.cs
@@ -1,3 +1,4 @@
+using System.Collections.Generic;
using Godot;
public class Player : Role
@@ -13,6 +14,15 @@
///
public float Friction { get; set; } = 800f;
+ //----------------------- 寻路相关 ----------------------------
+
+ //路径标记点总个数
+ private int _signLength = 15;
+ //存放所有路径点
+ private readonly List _pathSignList = new List();
+
+ //-------------------------------------------------------------
+
public Player(): base(ResourcePath.prefab_role_Player_tscn)
{
AttackLayer = PhysicsLayer.Wall | PhysicsLayer.Props | PhysicsLayer.Enemy;
diff --git a/DungeonShooting_Godot/src/game/role/Role.cs b/DungeonShooting_Godot/src/game/role/Role.cs
index 9336219..7720549 100644
--- a/DungeonShooting_Godot/src/game/role/Role.cs
+++ b/DungeonShooting_Godot/src/game/role/Role.cs
@@ -142,12 +142,7 @@
/// 当前角色所看向的对象, 也就是枪口指向的对象
///
public ActivityObject LookTarget { get; set; }
-
- ///
- /// 角色身上的状态机
- ///
- public StateController StateController { get; }
-
+
//初始缩放
private Vector2 _startScale;
//所有角色碰撞的道具
@@ -218,8 +213,6 @@
public Role(string scenePath) : base(scenePath)
{
Holster = new Holster(this);
- StateController = new StateController();
- AddComponent(StateController);
}
public override void _Ready()
diff --git a/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs
index 060f075..e293d65 100644
--- a/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs
+++ b/DungeonShooting_Godot/src/game/role/enemy/Enemy.cs
@@ -20,6 +20,11 @@
{
///
+ /// 敌人身上的状态机控制器
+ ///
+ public StateController StateController { get; }
+
+ ///
/// 视野半径, 单位像素
///
public float ViewRange { get; set; } = 200;
@@ -36,6 +41,9 @@
public Enemy() : base(ResourcePath.prefab_role_Enemy_tscn)
{
+ StateController = new StateController();
+ AddComponent(StateController);
+
AttackLayer = PhysicsLayer.Wall | PhysicsLayer.Props | PhysicsLayer.Player;
Camp = CampEnum.Camp2;
diff --git a/DungeonShooting_Godot/src/game/role/enemy/state/AIIdleState.cs b/DungeonShooting_Godot/src/game/role/enemy/state/AIIdleState.cs
index 601d820..06d64eb 100644
--- a/DungeonShooting_Godot/src/game/role/enemy/state/AIIdleState.cs
+++ b/DungeonShooting_Godot/src/game/role/enemy/state/AIIdleState.cs
@@ -2,11 +2,11 @@
///
/// AI 静止行为
///
-public class AIIdleState : IState
+public class AIIdleState : IState
{
public StateEnum StateType { get; } = StateEnum.Idle;
- public Role Master { get; set; }
- public StateController StateController { get; set; }
+ public Enemy Master { get; set; }
+ public StateController StateController { get; set; }
public void Enter(StateEnum prev, params object[] args)
{
diff --git a/DungeonShooting_Godot/src/game/role/enemy/state/AIRunState.cs b/DungeonShooting_Godot/src/game/role/enemy/state/AIRunState.cs
index 2105c2f..be7cee5 100644
--- a/DungeonShooting_Godot/src/game/role/enemy/state/AIRunState.cs
+++ b/DungeonShooting_Godot/src/game/role/enemy/state/AIRunState.cs
@@ -2,11 +2,11 @@
///
/// AI 奔跑行为
///
-public class AIRunState : IState
+public class AIRunState : IState
{
public StateEnum StateType { get; } = StateEnum.Run;
- public Role Master { get; set; }
- public StateController StateController { get; set; }
+ public Enemy Master { get; set; }
+ public StateController StateController { get; set; }
public void Enter(StateEnum prev, params object[] args)
{