diff --git a/DungeonShooting_Art/gun/Split/knife1.png b/DungeonShooting_Art/gun/Split/knife1.png index 2c98750..956a0a7 100644 --- a/DungeonShooting_Art/gun/Split/knife1.png +++ b/DungeonShooting_Art/gun/Split/knife1.png Binary files differ diff --git a/DungeonShooting_Godot/prefab/role/Enemy.tscn b/DungeonShooting_Godot/prefab/role/Enemy.tscn index c4fd32f..afc628f 100644 --- a/DungeonShooting_Godot/prefab/role/Enemy.tscn +++ b/DungeonShooting_Godot/prefab/role/Enemy.tscn @@ -23,7 +23,7 @@ [node name="AnimatedSprite" parent="." index="2"] material = SubResource( 2 ) -frame = 0 +frame = 3 [node name="ViewRay" type="RayCast2D" parent="." index="7"] position = Vector2( 0, -8 ) diff --git a/DungeonShooting_Godot/prefab/weapon/Knife.tscn b/DungeonShooting_Godot/prefab/weapon/Knife.tscn new file mode 100644 index 0000000..5e94459 --- /dev/null +++ b/DungeonShooting_Godot/prefab/weapon/Knife.tscn @@ -0,0 +1,25 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://prefab/weapon/Weapon.tscn" type="PackedScene" id=1] +[ext_resource path="res://resource/materlal/Blend.gdshader" type="Shader" id=3] + +[sub_resource type="ShaderMaterial" id=2] +resource_local_to_scene = true +shader = ExtResource( 3 ) +shader_param/shadowColor = Color( 0, 0, 0, 0.470588 ) +shader_param/schedule = 1.0 + +[sub_resource type="ShaderMaterial" id=3] +resource_local_to_scene = true +shader = ExtResource( 3 ) +shader_param/shadowColor = Color( 1, 1, 1, 1 ) +shader_param/schedule = 0.0 + +[node name="Knife" instance=ExtResource( 1 )] + +[node name="ShadowSprite" parent="." index="0"] +material = SubResource( 2 ) + +[node name="AnimatedSprite" parent="." index="1"] +material = SubResource( 3 ) +position = Vector2( 0, 0 ) diff --git a/DungeonShooting_Godot/resource/sprite/gun/knife1.png b/DungeonShooting_Godot/resource/sprite/gun/knife1.png new file mode 100644 index 0000000..a75464a --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/gun/knife1.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/gun/knife1.png.import b/DungeonShooting_Godot/resource/sprite/gun/knife1.png.import new file mode 100644 index 0000000..e26778f --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/gun/knife1.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/knife1.png-dd5849c94377d47ed0b17223d5f25d6a.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/gun/knife1.png" +dest_files=[ "res://.import/knife1.png-dd5849c94377d47ed0b17223d5f25d6a.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/game/item/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs index 8f43ae9..320789b 100644 --- a/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs +++ b/DungeonShooting_Godot/src/game/item/weapon/Weapon.cs @@ -337,11 +337,11 @@ Position = Position.MoveToward(Vector2.Zero, 35 * delta); if (fireInterval == 0) { - RotationDegrees = 0; + RotationDegrees = Attribute.DefaultAngle; } else { - RotationDegrees = Mathf.Lerp(0, fireAngle, attackTimer / fireInterval); + RotationDegrees = Mathf.Lerp(Attribute.DefaultAngle, fireAngle, attackTimer / fireInterval); } } } diff --git a/DungeonShooting_Godot/src/game/item/weapon/WeaponAttribute.cs b/DungeonShooting_Godot/src/game/item/weapon/WeaponAttribute.cs index 4adc29e..e6584c7 100644 --- a/DungeonShooting_Godot/src/game/item/weapon/WeaponAttribute.cs +++ b/DungeonShooting_Godot/src/game/item/weapon/WeaponAttribute.cs @@ -146,6 +146,10 @@ /// public float UpliftAngle = 30; /// + /// 武器默认角度 + /// + public float DefaultAngle = 0; + /// /// 开火后武器口角度恢复速度倍数 /// public float UpliftAngleRestore = 1; diff --git a/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs b/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs index dd91ad0..66d57d0 100644 --- a/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs +++ b/DungeonShooting_Godot/src/game/item/weapon/gun/Gun.cs @@ -13,7 +13,7 @@ public RifleAttribute() { Name = "步枪"; - Sprite = "res://resource/sprite/gun/gun4.png"; + Sprite = ResourcePath.resource_sprite_gun_gun4_png; Weight = 40; CenterPosition = new Vector2(0.4f, -2.6f); StartFiringSpeed = 480; @@ -51,7 +51,7 @@ public PistolAttribute() { Name = "手枪"; - Sprite = "res://resource/sprite/gun/gun3.png"; + Sprite = ResourcePath.resource_sprite_gun_gun3_png; Weight = 20; CenterPosition = new Vector2(0.4f, -2.6f); WeightType = WeaponWeightType.DeputyWeapon; diff --git a/DungeonShooting_Godot/src/game/item/weapon/knife/Knife.cs b/DungeonShooting_Godot/src/game/item/weapon/knife/Knife.cs new file mode 100644 index 0000000..a3efd81 --- /dev/null +++ b/DungeonShooting_Godot/src/game/item/weapon/knife/Knife.cs @@ -0,0 +1,40 @@ + +using Godot; + +[RegisterWeapon("1004", typeof(KnifeAttribute))] +public class Knife : Weapon +{ + + private class KnifeAttribute : WeaponAttribute + { + public KnifeAttribute() + { + Sprite = ResourcePath.resource_sprite_gun_knife1_png; + WeaponPrefab = ResourcePath.prefab_weapon_Knife_tscn; + //握把位置 + HoldPosition = new Vector2(10, 0); + //关闭后坐力 + MaxBacklash = 0; + MinBacklash = 0; + UpliftAngleRestore = 3; + UpliftAngle = -80; + DefaultAngle = 0; + } + } + + public Knife(string id, WeaponAttribute attribute) : base(id, attribute) + { + + + } + + protected override void OnFire() + { + + } + + protected override void OnShoot(float fireRotation) + { + + } +} diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs index 9a32662..ad18b1b 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -21,6 +21,7 @@ public const string prefab_ui_RoomUI_tscn = "res://prefab/ui/RoomUI.tscn"; public const string prefab_ui_bar_InteractiveTipBar_tscn = "res://prefab/ui/bar/InteractiveTipBar.tscn"; public const string prefab_ui_bar_ReloadBar_tscn = "res://prefab/ui/bar/ReloadBar.tscn"; + public const string prefab_weapon_Knife_tscn = "res://prefab/weapon/Knife.tscn"; 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"; @@ -74,6 +75,7 @@ public const string resource_sprite_gun_gun6_png = "res://resource/sprite/gun/gun6.png"; public const string resource_sprite_gun_gun7_png = "res://resource/sprite/gun/gun7.png"; public const string resource_sprite_gun_gun8_png = "res://resource/sprite/gun/gun8.png"; + public const string resource_sprite_gun_knife1_png = "res://resource/sprite/gun/knife1.png"; public const string resource_sprite_gun_out_default_png = "res://resource/sprite/gun/out/default.png"; public const string resource_sprite_role_role1_png = "res://resource/sprite/role/role1.png"; public const string resource_sprite_role_role10_png = "res://resource/sprite/role/role10.png"; diff --git a/DungeonShooting_Godot/src/game/room/RoomManager.cs b/DungeonShooting_Godot/src/game/room/RoomManager.cs index 0179066..a3c9331 100644 --- a/DungeonShooting_Godot/src/game/room/RoomManager.cs +++ b/DungeonShooting_Godot/src/game/room/RoomManager.cs @@ -49,6 +49,8 @@ WeaponManager.GetGun("1003").PutDown(new Vector2(180, 80)); WeaponManager.GetGun("1003").PutDown(new Vector2(180, 180)); WeaponManager.GetGun("1002").PutDown(new Vector2(180, 120)); + + WeaponManager.GetGun("1004").PutDown(new Vector2(220, 120)); } public override void _Process(float delta)