From cce2815f3bcfeec2f4c13386d073d20778724656 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Apr 2022 16:57:40 +0800 Subject: *EventCenter --- .../Scripts/Managers/PlayerManager_Weapons.cs | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'SurvivalTest/Assets/Scripts/Managers/PlayerManager_Weapons.cs') diff --git a/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Weapons.cs b/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Weapons.cs index 9a0f9db..16f9396 100644 --- a/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Weapons.cs +++ b/SurvivalTest/Assets/Scripts/Managers/PlayerManager_Weapons.cs @@ -12,9 +12,20 @@ public partial class PlayerManager : Singleton public bool isFire { get; private set; } - public bool autoFire {get{return m_AutoFire;}} private bool m_AutoFire; - private float m_AutoFireDuration = 0.8f; + public bool autoFire + { + get + { + return m_AutoFire; + } + set + { + m_AutoFire = value; + EventCenter.Instance.Publish(EventMsgType.ToggleAutoFire, null); + } + } + private float autoFireDuration = 0.8f; public bool lockAim { get; set; } @@ -29,7 +40,7 @@ public partial class PlayerManager : Singleton m_Weapons.Add(new Weapon_TeslaCoil()); m_Weapons.Add(new Weapon_MightyGlove()); - m_AutoFire = false; + autoFire = false; m_LastAxisValue = Input.GetAxisRaw("GunTrigger"); } @@ -54,26 +65,26 @@ public partial class PlayerManager : Singleton if (Input.GetButtonDown("Fire1") || (axis == 1 && m_LastAxisValue != 1)) { - if(m_AutoFire) + if(autoFire) { - m_AutoFire = false; + autoFire = false; } isFire = true; RunFireCoroutine(true); } - if (!m_AutoFire && !Input.GetButton("Fire1") && (axis == 0 && m_LastAxisValue != 0)) + if (!autoFire && !Input.GetButton("Fire1") && (axis == 0 && m_LastAxisValue != 0)) { if (TinyCountDown.Instance.Get("ReleaseFire") > 0) { - m_AutoFire = true; + autoFire = true; isFire = true; RunFireCoroutine(true); } else { - TinyCountDown.Instance.Set("ReleaseFire", m_AutoFireDuration); + TinyCountDown.Instance.Set("ReleaseFire", autoFireDuration); isFire = false; RunFireCoroutine(false); } -- cgit v1.1-26-g67d0