diff options
author | chai <chaifix@163.com> | 2022-04-23 21:08:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2022-04-23 21:08:04 +0800 |
commit | c53a09367b8eb79610c0ff9bd25fe2a171183514 (patch) | |
tree | 0796f8b5d8874c855d4ee66f08078cca219b13b0 | |
parent | 6c55e184d2c94765d23fa2c4e26b8679fea7acdb (diff) |
* auto fire
-rw-r--r-- | SurvivalTest/Assets/Scripts/Managers/PlayerManager_Equips.cs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Equips.cs b/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Equips.cs index a0a595a..05ca6df 100644 --- a/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Equips.cs +++ b/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Equips.cs @@ -13,7 +13,9 @@ public partial class PlayerManager : Singleton<PlayerManager> public bool isFire { get; private set; } private bool m_AutoFire; - private float m_AutoFireDuration = 1f; + private float m_AutoFireDuration = 1f; + + private float m_LastAxisValue = 0; void InitEquips() { @@ -21,6 +23,8 @@ public partial class PlayerManager : Singleton<PlayerManager> m_Equips.Add(new Equip_GrenadeLauncher()); m_AutoFire = false; + + m_LastAxisValue = Input.GetAxisRaw("GunTrigger"); } /// <summary> @@ -39,7 +43,9 @@ public partial class PlayerManager : Singleton<PlayerManager> /// </summary> void CheckInput() { - if (Input.GetButtonDown("Fire1") || (Input.GetAxisRaw("GunTrigger") == 1)) + float axis = Input.GetAxisRaw("GunTrigger"); + + if (Input.GetButtonDown("Fire1") || (axis == 1 && m_LastAxisValue != 1)) { if(m_AutoFire) { @@ -55,7 +61,8 @@ public partial class PlayerManager : Singleton<PlayerManager> m_CoFire = GameApp.Instance.StartCoroutine(coFire()); } } - if (!m_AutoFire && !Input.GetButton("Fire1") && (Input.GetAxisRaw("GunTrigger") == 0)) + + if (!m_AutoFire && !Input.GetButton("Fire1") && (axis == 0 && m_LastAxisValue != 0)) { TinyCountDown.Instance.Set("ReleaseFire", m_AutoFireDuration); isFire = false; @@ -65,6 +72,8 @@ public partial class PlayerManager : Singleton<PlayerManager> m_CoFire = null; } } + + m_LastAxisValue = axis; } /// <summary> |