From 781ad1b41d10e1ff828eb8e4ca60648fdd224cd0 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 9 Sep 2021 16:19:47 +0800 Subject: =?UTF-8?q?*=E8=B0=83=E6=95=B4=E5=87=A0=E4=B8=AA=E5=8A=A8=E4=BD=9C?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Input/InputManager.cs | 59 +++++++++++++--------- Assets/Scripts/Unit/AnimationData.cs | 1 + Assets/Scripts/Unit/Collider/ColliderBox_Hitbox.cs | 4 +- .../Scripts/Unit/Components/UnitState/PCState.cs | 13 +++-- Assets/Scripts/Unit/Controller/PCController.cs | 2 + 5 files changed, 51 insertions(+), 28 deletions(-) (limited to 'Assets/Scripts') diff --git a/Assets/Scripts/Input/InputManager.cs b/Assets/Scripts/Input/InputManager.cs index 4ad6ec02..6b200462 100644 --- a/Assets/Scripts/Input/InputManager.cs +++ b/Assets/Scripts/Input/InputManager.cs @@ -59,30 +59,41 @@ public class InputManager : SingletonMB public bool TryCommand(float interval = 0.5f, params KeyCode[] keys) { - if (keys.Length > m_CommandQueue.Count) - return false; - if (!Input.GetKey(keys[keys.Length - 1])) + return TryCommand(interval, true, keys); + + } + + public bool TryCommand(float interval = 0.5f, bool checkInput = false, params KeyCode[] keys) + { + if (keys.Length > m_CommandQueue.Count) return false; - int count = m_CommandQueue.Count; - float preTime = m_CommandQueue[count - keys.Length].time; - for (int i = 0; i < keys.Length; ++i) - { - if(keys[i] == m_CommandQueue[i + count - keys.Length].key) - { - if(m_CommandQueue[i + count - keys.Length].time - preTime > interval) - { - return false; - } - preTime = m_CommandQueue[i + count - keys.Length].time; - } - else - { - return false; - } - } - //m_CommandQueue.RemoveRange(count - keys.Length, keys.Length); - m_CommandQueue.Clear(); - return true; - } + if (checkInput && !Input.GetKey(keys[keys.Length - 1])) + return false; + int count = m_CommandQueue.Count; + float preTime = m_CommandQueue[count - keys.Length].time; + for (int i = 0; i < keys.Length; ++i) + { + if (keys[i] == m_CommandQueue[i + count - keys.Length].key) + { + if (m_CommandQueue[i + count - keys.Length].time - preTime > interval) + { + return false; + } + preTime = m_CommandQueue[i + count - keys.Length].time; + } + else + { + return false; + } + } + //m_CommandQueue.RemoveRange(count - keys.Length, keys.Length); + m_CommandQueue.Clear(); // 清理 + return true; + } + + public void ClearCommand() + { + m_CommandQueue.Clear(); + } } diff --git a/Assets/Scripts/Unit/AnimationData.cs b/Assets/Scripts/Unit/AnimationData.cs index ead0f16d..b4907239 100644 --- a/Assets/Scripts/Unit/AnimationData.cs +++ b/Assets/Scripts/Unit/AnimationData.cs @@ -81,6 +81,7 @@ public enum EAnimationProperty ComboTimeOffset = 1, IgnoreY = 2, TransitionInDuration = 3, + } [Serializable] diff --git a/Assets/Scripts/Unit/Collider/ColliderBox_Hitbox.cs b/Assets/Scripts/Unit/Collider/ColliderBox_Hitbox.cs index b765265c..9f1d629a 100644 --- a/Assets/Scripts/Unit/Collider/ColliderBox_Hitbox.cs +++ b/Assets/Scripts/Unit/Collider/ColliderBox_Hitbox.cs @@ -62,7 +62,9 @@ public partial class ColliderBox [Comment("[ 击中效果 ]", TextAnchor.MiddleCenter)] - [Foldout("时间效果", 2)] + [Foldout("时间效果", 3)] + [Tooltip("全局顿帧")] + public float freezeGlobal; [Tooltip("自身顿帧")] public float freezeFramesSelf; //[WhenNot("freezeFramesSelf", 0)] diff --git a/Assets/Scripts/Unit/Components/UnitState/PCState.cs b/Assets/Scripts/Unit/Components/UnitState/PCState.cs index b8512d64..c332dcda 100644 --- a/Assets/Scripts/Unit/Components/UnitState/PCState.cs +++ b/Assets/Scripts/Unit/Components/UnitState/PCState.cs @@ -278,12 +278,14 @@ public class PCState : UnitState { m_Owner.pcAnimation.AnimAttackToAir(param.offset); yield return null; + InputManager.Instance.ClearCommand(); while (true) { bool canCombo = m_Owner.pcAnimation.baseLayer.IsToggleOpen(EAnimationToogle.Combo); if(canCombo) { - if(Input.GetKeyDown("j")) + //if(Input.GetKeyDown("j")) + if(InputManager.Instance.TryCommand(0.5f, false, KeyCode.J)) { ChangeState(EUnitState.AirAttack, new SkillParam()); } @@ -308,10 +310,11 @@ public class PCState : UnitState IEnumerator AirAttack(SkillParam param) { - int total = 5; + int total = 5; int id = 0; m_Owner.pcAnimation.AnimAirAttack(id++); yield return null; // 等待animator更新 + InputManager.Instance.ClearCommand(); while (true) { bool canCombo = m_Owner.pcAnimation.baseLayer.IsToggleOpen(EAnimationToogle.Combo); @@ -328,7 +331,7 @@ public class PCState : UnitState ChangeState(EUnitState.AirDash, new AirDashParam()); } - if (Input.GetKeyDown("j")) + if (InputManager.Instance.TryCommand(0.3f, false, KeyCode.J)) { if (Input.GetKey("a")) { @@ -477,6 +480,10 @@ public class PCState : UnitState TurnAround(true); pos.x += vz * Time.deltaTime; } + if(Input.GetKeyDown("j")) + { + ChangeState(EUnitState.AirAttack, new SkillParam()); + } m_Owner.transform.position = pos; if (pos.y > 0 && pos.y <= 1 && !landingGround) { diff --git a/Assets/Scripts/Unit/Controller/PCController.cs b/Assets/Scripts/Unit/Controller/PCController.cs index 851fb80a..2294ae62 100644 --- a/Assets/Scripts/Unit/Controller/PCController.cs +++ b/Assets/Scripts/Unit/Controller/PCController.cs @@ -39,6 +39,8 @@ public class PCController : UnitController public override void OnHit(CollisionInfo info) { + ColliderBox hitbox = info.collider.colliderInfo.collider; + Debug.Assert(hitbox.type == ColliderBox.EColliderType.HitBox); } public override void OnGetHit(CollisionInfo info) -- cgit v1.1-26-g67d0