diff --git a/DungeonShooting_Godot/prefab/weapon/bullet/Bullet.tscn b/DungeonShooting_Godot/prefab/weapon/bullet/Bullet.tscn
index 7b14bc0..5b9b099 100644
--- a/DungeonShooting_Godot/prefab/weapon/bullet/Bullet.tscn
+++ b/DungeonShooting_Godot/prefab/weapon/bullet/Bullet.tscn
@@ -22,6 +22,7 @@
material = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
+modulate = Color( 1.5, 1.5, 1.5, 1 )
position = Vector2( 2.38419e-07, 0 )
frames = SubResource( 1 )
diff --git a/DungeonShooting_Godot/project.godot b/DungeonShooting_Godot/project.godot
index cc08f5e..e1ec7c8 100644
--- a/DungeonShooting_Godot/project.godot
+++ b/DungeonShooting_Godot/project.godot
@@ -27,7 +27,6 @@
window/size/width=1920
window/size/height=1080
window/size/resizable=false
-window/size/always_on_top=true
window/dpi/allow_hidpi=true
window/vsync/use_vsync=false
window/stretch/mode="2d"
diff --git a/DungeonShooting_Godot/scene/Room.tscn b/DungeonShooting_Godot/scene/Room.tscn
index 43c2477..a9137ae 100644
--- a/DungeonShooting_Godot/scene/Room.tscn
+++ b/DungeonShooting_Godot/scene/Room.tscn
@@ -1,12 +1,19 @@
-[gd_scene load_steps=4 format=2]
+[gd_scene load_steps=5 format=2]
[ext_resource path="res://resource/map/dungeon_test.tmx" type="PackedScene" id=2]
[ext_resource path="res://src/game/room/RoomManager.cs" type="Script" id=3]
[ext_resource path="res://src/game/camera/GameCamera.cs" type="Script" id=5]
+[sub_resource type="Environment" id=1]
+background_mode = 4
+glow_enabled = true
+
[node name="Room" type="Node2D"]
script = ExtResource( 3 )
+[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
+environment = SubResource( 1 )
+
[node name="MapRoot" type="Node2D" parent="."]
z_index = -10
diff --git a/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs b/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs
index 5dd8c0a..5e40c91 100644
--- a/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs
+++ b/DungeonShooting_Godot/src/game/item/weapon/bullet/Bullet.cs
@@ -26,7 +26,7 @@
private float MaxDistance;
// 子弹飞行速度
- private float FlySpeed = 600;
+ private float FlySpeed = 450;
//当前子弹已经飞行的距离
private float CurrFlyDistance = 0;
diff --git a/DungeonShooting_Godot/src/game/role/Enemy.cs b/DungeonShooting_Godot/src/game/role/Enemy.cs
index ed60cb4..796f4c3 100644
--- a/DungeonShooting_Godot/src/game/role/Enemy.cs
+++ b/DungeonShooting_Godot/src/game/role/Enemy.cs
@@ -5,6 +5,8 @@
{
AttackLayer = PhysicsLayer.Wall | PhysicsLayer.Props | PhysicsLayer.Player;
Camp = CampEnum.Camp2;
+
+ MoveSpeed = 20;
}
public override void _Process(float delta)
@@ -12,4 +14,21 @@
base._Process(delta);
Attack();
}
+
+ public override void _PhysicsProcess(float delta)
+ {
+ base._PhysicsProcess(delta);
+
+ Move(delta);
+
+ }
+
+ public void Move(float delta)
+ {
+ var player = GameApplication.Instance.Room.Player;
+ var dir = (player.GlobalPosition - GlobalPosition).Normalized() * MoveSpeed;
+
+ MoveAndSlide(dir);
+
+ }
}
diff --git a/DungeonShooting_Godot/src/game/role/Player.cs b/DungeonShooting_Godot/src/game/role/Player.cs
index d1dadc4..4e79e98 100644
--- a/DungeonShooting_Godot/src/game/role/Player.cs
+++ b/DungeonShooting_Godot/src/game/role/Player.cs
@@ -3,20 +3,6 @@
public class Player : Role
{
///
- /// 移动加速度
- ///
- public float Acceleration = 1500f;
-
- ///
- /// 移动摩擦力
- ///
- public float Friction = 800f;
- ///
- /// 移动速度
- ///
- public Vector2 Velocity = Vector2.Zero;
-
- ///
/// 当前护盾值
///
public int Shield
@@ -46,8 +32,6 @@
}
private int _maxShield = 0;
- [Export] public PackedScene GunPrefab;
-
public Player(): base(ResourcePath.prefab_role_Player_tscn)
{
AttackLayer = PhysicsLayer.Wall | PhysicsLayer.Props | PhysicsLayer.Enemy;
@@ -142,8 +126,6 @@
Move(delta);
//播放动画
PlayAnim();
- //GlobalPosition = GlobalPosition.Round();
- //AnimatedSprite.Playing = false;
}
protected override void OnChangeHp(int hp)
@@ -218,11 +200,23 @@
Vector2 dir = Input.GetVector("move_left", "move_right", "move_up", "move_down");
// 移动. 如果移动的数值接近0(是用 摇杆可能出现 方向 可能会出现浮点),就fricition的值 插值 到 0
// 如果 有输入 就以当前速度,用acceleration 插值到 对应方向 * 最大速度
- if (Mathf.IsZeroApprox(dir.x)) Velocity.x = Mathf.MoveToward(Velocity.x, 0, Friction * delta);
- else Velocity.x = Mathf.MoveToward(Velocity.x, dir.x * MoveSpeed, Acceleration * delta);
+ if (Mathf.IsZeroApprox(dir.x))
+ {
+ Velocity = new Vector2(Mathf.MoveToward(Velocity.x, 0, Friction * delta), Velocity.y);
+ }
+ else
+ {
+ Velocity = new Vector2(Mathf.MoveToward(Velocity.x, dir.x * MoveSpeed, Acceleration * delta), Velocity.y);
+ }
- if (Mathf.IsZeroApprox(dir.y)) Velocity.y = Mathf.MoveToward(Velocity.y, 0, Friction * delta);
- else Velocity.y = Mathf.MoveToward(Velocity.y, dir.y * MoveSpeed, Acceleration * delta);
+ if (Mathf.IsZeroApprox(dir.y))
+ {
+ Velocity = new Vector2(Velocity.x, Mathf.MoveToward(Velocity.y, 0, Friction * delta));
+ }
+ else
+ {
+ Velocity = new Vector2(Velocity.x, Mathf.MoveToward(Velocity.y, dir.y * MoveSpeed, Acceleration * delta));
+ }
Velocity = MoveAndSlide(Velocity);
}
diff --git a/DungeonShooting_Godot/src/game/role/Role.cs b/DungeonShooting_Godot/src/game/role/Role.cs
index 51e9377..7494934 100644
--- a/DungeonShooting_Godot/src/game/role/Role.cs
+++ b/DungeonShooting_Godot/src/game/role/Role.cs
@@ -69,6 +69,22 @@
private FaceDirection _face;
///
+ /// 移动加速度
+ ///
+ public float Acceleration { get; set; } = 1500f;
+
+ ///
+ /// 移动摩擦力
+ ///
+ public float Friction { get; set; } = 800f;
+ ///
+ /// 移动速度
+ ///
+ public Vector2 Velocity { get; set; } = Vector2.Zero;
+
+ public Vector2 TargetVelocity { get; set; } = Vector2.Zero;
+
+ ///
/// 血量
///
public int Hp