diff --git a/prefab/projectile/curseOfTheUndead.tscn b/prefab/projectile/curseOfTheUndead.tscn
index 059d6e8..8f16dfa 100644
--- a/prefab/projectile/curseOfTheUndead.tscn
+++ b/prefab/projectile/curseOfTheUndead.tscn
@@ -14,10 +14,10 @@ _durability = 1.0
_maxDamage = 10
_minDamage = 1
_damageType = 2
-_knockBackForce = Vector2(0, 1)
Speed = 500.0
_enableTracking = true
_targetDiesDestroyProjectile = true
+_repelStrength = 2.5
[node name="CurseOfTheUndead" type="Sprite2D" parent="."]
texture = ExtResource("1_k8el6")
diff --git a/prefab/roomTemplates/dungeon/horizontalCorridor.tscn b/prefab/roomTemplates/dungeon/horizontalCorridor.tscn
index 40c2b67..d977bee 100644
--- a/prefab/roomTemplates/dungeon/horizontalCorridor.tscn
+++ b/prefab/roomTemplates/dungeon/horizontalCorridor.tscn
@@ -16,8 +16,8 @@ size = Vector2(20, 46)
size = Vector2(53, 24)
[sub_resource type="NavigationPolygon" id="NavigationPolygon_rh1gx"]
-vertices = PackedVector2Array(501, 150, 9, 151, 11, 107, 43, 107, 170, 41, 169, 11, 217, 11, 219, 42, 42, 44, 470, 107, 499, 106, 469, 43)
-polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Array(4, 5, 6, 7), PackedInt32Array(0, 3, 8, 4, 7, 9), PackedInt32Array(9, 10, 0), PackedInt32Array(9, 7, 11)])
+vertices = PackedVector2Array(499.469, 106.328, 501.523, 150.039, 9.3125, 151.953, 470.156, 107.352, 10.7031, 107, 43.1562, 107, 170.328, 40.6797, 169.344, 11, 216.617, 11, 218.617, 41.9297, 469.148, 43.9219, 42.1484, 44.6875)
+polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Array(3, 2, 4, 5), PackedInt32Array(6, 7, 8, 9), PackedInt32Array(10, 3, 5, 9), PackedInt32Array(6, 9, 5, 11)])
outlines = Array[PackedVector2Array]([PackedVector2Array(479, 34, 228, 32, 226, 1, 159, 1, 160, 31, 32, 35, 33, 97, 1, 97, -1, 162, 512, 160, 509, 96, 480, 97)])
source_geometry_group_name = &"navigation_polygon_source_group"
diff --git a/prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn b/prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn
index 8d6a180..9f26957 100644
--- a/prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn
+++ b/prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn
@@ -16,8 +16,8 @@ size = Vector2(46, 20)
size = Vector2(20, 54)
[sub_resource type="NavigationPolygon" id="NavigationPolygon_db40i"]
-vertices = PackedVector2Array(499, 108, 501, 150, 246, 149, 471, 108, 12, 149, 11, 107, 41, 107, 203, 149, 245, 180, 203, 178, 43, 43, 470, 44)
-polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Array(4, 5, 6, 7), PackedInt32Array(2, 8, 9, 7), PackedInt32Array(10, 11, 3, 2, 7, 6)])
+vertices = PackedVector2Array(499.461, 108, 501.5, 150.906, 246.312, 148.922, 471.156, 108, 245.312, 180.508, 203, 178.469, 203, 149, 11.8438, 149, 11.1562, 107.656, 40.5625, 106.688, 43.5391, 43.0391, 470.148, 44.9531)
+polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Array(2, 4, 5, 6), PackedInt32Array(7, 8, 9, 6), PackedInt32Array(10, 11, 3, 2, 6, 9)])
outlines = Array[PackedVector2Array]([PackedVector2Array(34, 33, 31, 97, 1, 98, 2, 159, 193, 159, 193, 188, 255, 191, 256, 159, 512, 161, 509, 98, 481, 98, 480, 35)])
source_geometry_group_name = &"navigation_polygon_source_group"
diff --git a/prefab/roomTemplates/dungeon/initialRoom.tscn b/prefab/roomTemplates/dungeon/initialRoom.tscn
index c2ee845..5683f83 100644
--- a/prefab/roomTemplates/dungeon/initialRoom.tscn
+++ b/prefab/roomTemplates/dungeon/initialRoom.tscn
@@ -11,9 +11,9 @@ size = Vector2(450, 191)
size = Vector2(18, 57.75)
[sub_resource type="NavigationPolygon" id="NavigationPolygon_064c7"]
-vertices = PackedVector2Array(468, 174, 500, 174, 499, 214, 41, 214, 45, 45, 468, 45)
+vertices = PackedVector2Array(467.773, 174, 499.828, 174, 499.156, 214.969, 40.9375, 214.023, 40.0469, 41.0625, 470.758, 43.9297)
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Array(0, 3, 4, 5)])
-outlines = Array[PackedVector2Array]([PackedVector2Array(35, 35, 31, 224, 509, 225, 510, 164, 478, 164, 478, 35)])
+outlines = Array[PackedVector2Array]([PackedVector2Array(30, 31, 31, 224, 509, 225, 510, 164, 478, 164, 481, 34)])
source_geometry_group_name = &"navigation_polygon_source_group"
[node name="InitialRoom" type="Node2D"]
diff --git a/prefab/roomTemplates/dungeon/utilityRoom.tscn b/prefab/roomTemplates/dungeon/utilityRoom.tscn
index e80166b..79f37fa 100644
--- a/prefab/roomTemplates/dungeon/utilityRoom.tscn
+++ b/prefab/roomTemplates/dungeon/utilityRoom.tscn
@@ -3,7 +3,7 @@
[ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="1_rn2om"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"]
-size = Vector2(669, 442)
+size = Vector2(664, 435)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_o85u0"]
size = Vector2(20, 48)
@@ -15,7 +15,7 @@ size = Vector2(22, 46)
size = Vector2(11.875, 51)
[sub_resource type="NavigationPolygon" id="NavigationPolygon_1qloc"]
-vertices = PackedVector2Array(696, 425, 720, 425, 722, 467, 12, 470, 10, 426, 46, 424, 691, 84, 45, 48, 721, 44, 723, 80)
+vertices = PackedVector2Array(696.148, 425, 719.617, 425, 722.328, 467.047, 12.5391, 470.938, 10.4531, 426.43, 46.0312, 424.461, 690.859, 84.1562, 45.0234, 48.9219, 721.523, 44.0625, 723.5, 80.1875)
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3, 4), PackedInt32Array(0, 4, 5), PackedInt32Array(6, 0, 5, 7), PackedInt32Array(6, 7, 8, 9)])
outlines = Array[PackedVector2Array]([PackedVector2Array(35, 39, 36, 415, 0, 417, 3, 481, 733, 477, 729, 415, 706, 415, 701, 93, 734, 89, 731, 34)])
source_geometry_group_name = &"navigation_polygon_source_group"
@@ -26,7 +26,7 @@ source_geometry_group_name = &"navigation_polygon_source_group"
collision_mask = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomArea"]
-position = Vector2(367.5, 256)
+position = Vector2(370, 259.5)
shape = SubResource("RectangleShape2D_kiih8")
[node name="RoomSlotList" type="Node2D" parent="."]
diff --git a/scripts/inventory/ItemSlotNode.cs b/scripts/inventory/ItemSlotNode.cs
index 025a33b..fcb3562 100644
--- a/scripts/inventory/ItemSlotNode.cs
+++ b/scripts/inventory/ItemSlotNode.cs
@@ -2,7 +2,6 @@ using System;
using ColdMint.scripts.debug;
using ColdMint.scripts.pickable;
using ColdMint.scripts.utils;
-using ColdMint.scripts.weapon;
using Godot;
namespace ColdMint.scripts.inventory;
diff --git a/scripts/projectile/Projectile.cs b/scripts/projectile/Projectile.cs
index d7516b0..4603709 100644
--- a/scripts/projectile/Projectile.cs
+++ b/scripts/projectile/Projectile.cs
@@ -38,16 +38,6 @@ public partial class Projectile : CharacterBody2D
///
private DateTime? _destructionTime;
- ///
- /// knockBack
- /// 击退
- ///
- ///
- ///How much force does it have when hitting the character? Unit: Number of cells,The X direction of the force is inferred automatically.
- ///当击中角色时带有多大的力?单位:格数,力的X方向是自动推断的。
- ///
- [Export] private Vector2 _knockBackForce;
-
[Export] public float Speed;
///
@@ -88,6 +78,16 @@ public partial class Projectile : CharacterBody2D
///
private RayCast2D? _wallRayCast;
+ ///
+ /// Repel strength
+ /// 击退强度
+ ///
+ ///
+ ///Must be greater than 0, the unit is in format.
+ ///必须大于0,单位为格式。
+ ///
+ [Export] private float _repelStrength;
+
///
/// The master of the weapon
/// 武器的主人
@@ -117,6 +117,7 @@ public partial class Projectile : CharacterBody2D
SetCollisionMaskValue(Config.LayerNumber.Floor, !_ignoreWall);
SetCollisionMaskValue(Config.LayerNumber.Player, true);
SetCollisionMaskValue(Config.LayerNumber.Mob, true);
+ SetCollisionMaskValue(Config.LayerNumber.PickAbleItem, true);
//Platform collision layer is not allowed to collide
//平台碰撞层不可碰撞
SetCollisionMaskValue(Config.LayerNumber.Platform, false);
@@ -239,42 +240,24 @@ public partial class Projectile : CharacterBody2D
InvokeDecorators(decorator => { decorator.OnKillCharacter(owner, characterTemplate); });
}
- if (_knockBackForce != Vector2.Zero)
+ if (_repelStrength > 0)
{
//If we set the attack force, then apply the force to the object
//如果我们设置了攻退力,那么将力应用到对象上
- var force = new Vector2();
- var forceX = Math.Abs(_knockBackForce.X);
- if (Velocity.X < 0)
- {
- //Beat back to port
- //向左击退
- forceX = -forceX;
- }
-
- force.X = forceX * Config.CellSize;
- force.Y = _knockBackForce.Y * Config.CellSize;
- characterTemplate.AddForce(force);
+ var normalized = Velocity.Normalized();
+ characterTemplate.AddForce(new Vector2(normalized.X * _repelStrength * Config.CellSize,
+ normalized.Y * _repelStrength * Config.CellSize));
}
}
else if (target is PickAbleTemplate pickAbleTemplate)
{
- if (_knockBackForce != Vector2.Zero)
+ if (_repelStrength > 0)
{
//If we set the attack force, then apply the force to the object
//如果我们设置了攻退力,那么将力应用到对象上
- var force = new Vector2();
- var forceX = Math.Abs(_knockBackForce.X);
- if (Velocity.X < 0)
- {
- //Beat back to port
- //向左击退
- forceX = -forceX;
- }
-
- force.X = forceX * Config.CellSize;
- force.Y = _knockBackForce.Y * Config.CellSize;
- pickAbleTemplate.ApplyImpulse(force);
+ var normalized = Velocity.Normalized();
+ pickAbleTemplate.ApplyImpulse(new Vector2(normalized.X * _repelStrength * Config.CellSize,
+ normalized.Y * _repelStrength * Config.CellSize));
}
}
}