diff --git a/DungeonShooting_Godot/prefab/weapon/Weapon.tscn b/DungeonShooting_Godot/prefab/weapon/Weapon.tscn
index bb56e3c..18e8050 100644
--- a/DungeonShooting_Godot/prefab/weapon/Weapon.tscn
+++ b/DungeonShooting_Godot/prefab/weapon/Weapon.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=8 format=2]
-[ext_resource path="res://src/weapon/gun/OrdinaryGun.cs" type="Script" id=1]
+[ext_resource path="res://src/weapon/gun/Gun.cs" type="Script" id=1]
[ext_resource path="res://resource/materlal/Shadow.gdshader" type="Shader" id=2]
[sub_resource type="ShaderMaterial" id=9]
diff --git a/DungeonShooting_Godot/prefab/weapon/gun/Shotgun.tscn b/DungeonShooting_Godot/prefab/weapon/gun/Shotgun.tscn
new file mode 100644
index 0000000..c1c65dc
--- /dev/null
+++ b/DungeonShooting_Godot/prefab/weapon/gun/Shotgun.tscn
@@ -0,0 +1,7 @@
+[gd_scene load_steps=3 format=2]
+
+[ext_resource path="res://prefab/weapon/Weapon.tscn" type="PackedScene" id=1]
+[ext_resource path="res://src/weapon/gun/Shotgun.cs" type="Script" id=2]
+
+[node name="Shotgun" instance=ExtResource( 1 )]
+script = ExtResource( 2 )
diff --git a/DungeonShooting_Godot/src/weapon/Weapon.cs b/DungeonShooting_Godot/src/weapon/Weapon.cs
index 31ff532..43f1ca5 100644
--- a/DungeonShooting_Godot/src/weapon/Weapon.cs
+++ b/DungeonShooting_Godot/src/weapon/Weapon.cs
@@ -335,7 +335,7 @@
if (Reloading)
{
//换弹中
-
+
}
else if (CurrAmmo <= 0)
{
@@ -479,7 +479,43 @@
{
if (Attribute.AloneReload) //单独装填
{
-
+ if (ResidueAmmo >= Attribute.AloneReloadCount) //剩余子弹充足
+ {
+ if (ResidueAmmo + CurrAmmo <= Attribute.AmmoCapacity)
+ {
+ ResidueAmmo -= Attribute.AloneReloadCount;
+ CurrAmmo += Attribute.AloneReloadCount;
+ }
+ else //子弹满了
+ {
+ var num = Attribute.AmmoCapacity - CurrAmmo;
+ CurrAmmo = Attribute.AmmoCapacity;
+ ResidueAmmo -= num;
+ }
+ }
+ else if (ResidueAmmo != 0) //剩余子弹不足
+ {
+ if (ResidueAmmo + CurrAmmo <= Attribute.AmmoCapacity)
+ {
+ CurrAmmo += ResidueAmmo;
+ ResidueAmmo = 0;
+ }
+ else //子弹满了
+ {
+ var num = Attribute.AmmoCapacity - CurrAmmo;
+ CurrAmmo = Attribute.AmmoCapacity;
+ ResidueAmmo -= num;
+ }
+ }
+ if (ResidueAmmo == 0 || CurrAmmo == Attribute.AmmoCapacity) //换弹结束
+ {
+ Reloading = false;
+ }
+ else
+ {
+ ReloadTimer = Attribute.ReloadTime;
+ OnReload();
+ }
}
else //换弹结束
{
diff --git a/DungeonShooting_Godot/src/weapon/WeaponAttribute.cs b/DungeonShooting_Godot/src/weapon/WeaponAttribute.cs
index 7480d56..95804cc 100644
--- a/DungeonShooting_Godot/src/weapon/WeaponAttribute.cs
+++ b/DungeonShooting_Godot/src/weapon/WeaponAttribute.cs
@@ -50,6 +50,10 @@
///
public bool AloneReload = false;
///
+ /// 单独装填时每次装填子弹数量, 必须要将 'AloneReload' 属性设置为 true
+ ///
+ public int AloneReloadCount = 1;
+ ///
/// 单独装填的子弹时可以立即射击, 必须要将 'AloneReload' 属性设置为 true
///
public bool AloneReloadCanShoot = false;
diff --git a/DungeonShooting_Godot/src/weapon/WeaponManager.cs b/DungeonShooting_Godot/src/weapon/WeaponManager.cs
index 013f73a..10e40fa 100644
--- a/DungeonShooting_Godot/src/weapon/WeaponManager.cs
+++ b/DungeonShooting_Godot/src/weapon/WeaponManager.cs
@@ -108,30 +108,32 @@
public static Weapon GetGun3()
{
//加载枪的 prefab
- var gun = ResourceManager.LoadWeaponAndInstance("res://prefab/weapon/Weapon.tscn");
+ var gun = ResourceManager.LoadWeaponAndInstance("res://prefab/weapon/gun/Shotgun.tscn");
//设置基础属性
var attr = new WeaponAttribute();
attr.Id = "3";
attr.Name = "Gun3";
attr.Weight = 30;
attr.CenterPosition = new Vector2(0.4f, -2.6f);
- attr.StartFiringSpeed = 480;
+ attr.StartFiringSpeed = 180;
attr.StartScatteringRange = 30;
attr.FinalScatteringRange = 90;
attr.ScatteringRangeAddValue = 2f;
attr.ScatteringRangeBackSpeed = 40;
//连发
attr.ContinuousShoot = false;
+ //单独装弹
+ attr.AloneReload = true;
//扳机检测间隔
attr.TriggerInterval = 0f;
//连发数量
- attr.MinContinuousCount = 3;
- attr.MaxContinuousCount = 3;
+ attr.MinContinuousCount = 1;
+ attr.MaxContinuousCount = 1;
//开火前延时
attr.DelayedTime = 0f;
//攻击距离
- attr.MinDistance = 500;
- attr.MaxDistance = 600;
+ attr.MinDistance = 150;
+ attr.MaxDistance = 200;
//发射子弹数量
attr.MinFireBulletCount = 1;
attr.MaxFireBulletCount = 1;
diff --git a/DungeonShooting_Godot/src/weapon/gun/Gun.cs b/DungeonShooting_Godot/src/weapon/gun/Gun.cs
new file mode 100644
index 0000000..094a07b
--- /dev/null
+++ b/DungeonShooting_Godot/src/weapon/gun/Gun.cs
@@ -0,0 +1,61 @@
+using System;
+using Godot;
+
+
+///
+/// 普通的枪
+///
+public class Gun : Weapon
+{
+ protected override void Init()
+ {
+
+ }
+
+ protected override void OnFire()
+ {
+ //创建一个弹壳
+ var startPos = GlobalPosition + new Vector2(0, 5);
+ var startHeight = 6;
+ var direction = GlobalRotationDegrees + MathUtils.RandRangeInt(-30, 30) + 180;
+ var xf = MathUtils.RandRangeInt(20, 60);
+ var yf = MathUtils.RandRangeInt(60, 120);
+ var rotate = MathUtils.RandRangeInt(-720, 720);
+ var sprite = Attribute.ShellPack.Instance();
+ sprite.StartThrow(new Vector2(5, 10), startPos, startHeight, direction, xf, yf, rotate, sprite);
+ //创建抖动
+ MainCamera.Main.ProssesDirectionalShake(Vector2.Right.Rotated(GlobalRotation) * 1.5f);
+ }
+
+ protected override void OnShootBullet()
+ {
+ //创建子弹
+ CreateBullet(Attribute.BulletPack, FirePoint.GlobalPosition, (FirePoint.GlobalPosition - OriginPoint.GlobalPosition).Angle());
+ }
+
+ protected override void OnReload()
+ {
+
+ }
+
+ protected override void OnPickUp(Role master)
+ {
+
+ }
+
+ protected override void OnThrowOut()
+ {
+
+ }
+
+ protected override void OnActive()
+ {
+
+ }
+
+ protected override void OnConceal()
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/weapon/gun/OrdinaryGun.cs b/DungeonShooting_Godot/src/weapon/gun/OrdinaryGun.cs
deleted file mode 100644
index 30e8c05..0000000
--- a/DungeonShooting_Godot/src/weapon/gun/OrdinaryGun.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using System;
-using Godot;
-
-
-///
-/// 普通的枪
-///
-public class OrdinaryGun : Weapon
-{
- protected override void Init()
- {
-
- }
-
- protected override void OnFire()
- {
- //创建一个弹壳
- var startPos = GlobalPosition + new Vector2(0, 5);
- var startHeight = 6;
- var direction = GlobalRotationDegrees + MathUtils.RandRangeInt(-30, 30) + 180;
- var xf = MathUtils.RandRangeInt(20, 60);
- var yf = MathUtils.RandRangeInt(60, 120);
- var rotate = MathUtils.RandRangeInt(-720, 720);
- var sprite = Attribute.ShellPack.Instance();
- sprite.StartThrow(new Vector2(5, 10), startPos, startHeight, direction, xf, yf, rotate, sprite);
- //创建抖动
- MainCamera.Main.ProssesDirectionalShake(Vector2.Right.Rotated(GlobalRotation) * 1.5f);
- }
-
- protected override void OnShootBullet()
- {
- //创建子弹
- CreateBullet(Attribute.BulletPack, FirePoint.GlobalPosition, (FirePoint.GlobalPosition - OriginPoint.GlobalPosition).Angle());
- }
-
- protected override void OnReload()
- {
-
- }
-
- protected override void OnPickUp(Role master)
- {
-
- }
-
- protected override void OnThrowOut()
- {
-
- }
-
- protected override void OnActive()
- {
-
- }
-
- protected override void OnConceal()
- {
-
- }
-
-}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/weapon/gun/Shotgun.cs b/DungeonShooting_Godot/src/weapon/gun/Shotgun.cs
new file mode 100644
index 0000000..5b8f442
--- /dev/null
+++ b/DungeonShooting_Godot/src/weapon/gun/Shotgun.cs
@@ -0,0 +1,58 @@
+using Godot;
+
+public class Shotgun : Weapon
+{
+ protected override void Init()
+ {
+
+ }
+
+ protected override void OnFire()
+ {
+ //创建一个弹壳
+ var startPos = GlobalPosition + new Vector2(0, 5);
+ var startHeight = 6;
+ var direction = GlobalRotationDegrees + MathUtils.RandRangeInt(-30, 30) + 180;
+ var xf = MathUtils.RandRangeInt(20, 60);
+ var yf = MathUtils.RandRangeInt(60, 120);
+ var rotate = MathUtils.RandRangeInt(-720, 720);
+ var sprite = Attribute.ShellPack.Instance();
+ sprite.StartThrow(new Vector2(5, 10), startPos, startHeight, direction, xf, yf, rotate, sprite);
+ //创建抖动
+ MainCamera.Main.ProssesDirectionalShake(Vector2.Right.Rotated(GlobalRotation) * 1.5f);
+ }
+
+ protected override void OnShootBullet()
+ {
+ for (int i = 0; i < 5; i++)
+ {
+ //创建子弹
+ CreateBullet(Attribute.BulletPack, FirePoint.GlobalPosition, (FirePoint.GlobalPosition - OriginPoint.GlobalPosition).Angle() + MathUtils.RandRange(-20 / 180f * Mathf.Pi, 20 / 180f * Mathf.Pi));
+ }
+ }
+
+ protected override void OnReload()
+ {
+
+ }
+
+ protected override void OnPickUp(Role master)
+ {
+
+ }
+
+ protected override void OnThrowOut()
+ {
+
+ }
+
+ protected override void OnActive()
+ {
+
+ }
+
+ protected override void OnConceal()
+ {
+
+ }
+}