summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Unit/Components
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-09-10 22:29:23 +0800
committerchai <chaifix@163.com>2021-09-10 22:29:23 +0800
commit63f4fd784f27e195913607e938a6d7282a9485d3 (patch)
tree5daf388cfa445890024ce7da9e7ff3dbb41957d1 /Assets/Scripts/Unit/Components
parent4e46f701027da081d60aa96e0814996c7acfa70a (diff)
*misc
Diffstat (limited to 'Assets/Scripts/Unit/Components')
-rw-r--r--Assets/Scripts/Unit/Components/UnitState/PCState_Event.cs11
-rw-r--r--Assets/Scripts/Unit/Components/UnitState/PCState_States.cs33
-rw-r--r--Assets/Scripts/Unit/Components/UnitState/UnitState.cs12
3 files changed, 42 insertions, 14 deletions
diff --git a/Assets/Scripts/Unit/Components/UnitState/PCState_Event.cs b/Assets/Scripts/Unit/Components/UnitState/PCState_Event.cs
index b5c0833f..73c65a0c 100644
--- a/Assets/Scripts/Unit/Components/UnitState/PCState_Event.cs
+++ b/Assets/Scripts/Unit/Components/UnitState/PCState_Event.cs
@@ -5,8 +5,19 @@ using UnityEngine;
public partial class PCState : UnitState
{
+
void OnTimeLineEvent(AnimationEventBase animEvent)
{
+ if(animEvent is EventUnit_SetPosition)
+ {
+ EventUnit_SetPosition setPos = animEvent as EventUnit_SetPosition;
+ Vector3 pos = owner.transform.position;
+ if(setPos.setY)
+ {
+ pos.y = setPos.y;
+ }
+ owner.transform.position = pos;
+ }
}
diff --git a/Assets/Scripts/Unit/Components/UnitState/PCState_States.cs b/Assets/Scripts/Unit/Components/UnitState/PCState_States.cs
index 2cfaf876..14d62c87 100644
--- a/Assets/Scripts/Unit/Components/UnitState/PCState_States.cs
+++ b/Assets/Scripts/Unit/Components/UnitState/PCState_States.cs
@@ -43,14 +43,9 @@ public partial class PCState : UnitState
IEnumerator Idle(IdleParam param)
{
- //if (m_Owner.isInAir) // 浮空切换到landing
- //{
- // ChangeState(EUnitState.Landing, new LandingParam());
- //}
- //else // idle
- //{
- m_Owner.SetYPosition(0);
m_Owner.pcAnimation.AnimIdle();
+ yield return new WaitForTransitionDone(owner.unitAnimation);
+ m_Owner.SetYPosition(0);
while (true)
{
if (Input.GetKeyDown("j"))
@@ -81,7 +76,6 @@ public partial class PCState : UnitState
}
yield return null;
}
- //}
}
void OnIdleExit(EUnitState nextState)
@@ -106,7 +100,11 @@ public partial class PCState : UnitState
//if (Input.GetKey(param.key))
m_Owner.pcAnimation.AnimMove();
while (Input.GetKey(param.key))
- {
+ {
+ if (Input.GetKeyDown("u"))
+ {
+ ChangeState(EUnitState.AttackToAir, new SkillParam());
+ }
yield return null;
}
ChangeState(EUnitState.Idle, new IdleParam());
@@ -188,7 +186,7 @@ public partial class PCState : UnitState
}
}
- if (isAnimationReachEnd)
+ if (isAnimationReachEnd || isAnimationReachEndPoint)
{
ChangeState(EUnitState.Landing, new LandingParam());
}
@@ -334,9 +332,13 @@ public partial class PCState : UnitState
while (true)
{
Vector3 pos = m_Owner.transform.position;
- vy += g * Time.deltaTime;
- pos.y += vy * Time.deltaTime;
- pos.y = Mathf.Max(0, pos.y);
+
+ if(!landingGround)
+ {
+ vy += g * Time.deltaTime;
+ pos.y += vy * Time.deltaTime;
+ pos.y = Mathf.Max(0, pos.y);
+ }
TryDash();
@@ -352,13 +354,16 @@ public partial class PCState : UnitState
TurnAround(true);
pos.x += vx * Time.deltaTime;
}
+
if (Input.GetKeyDown("j"))
{
ChangeState(EUnitState.AirAttack, new SkillParam());
}
+
m_Owner.transform.position = pos;
+
if (pos.y > 0 && pos.y <= 1 && !landingGround)
- {
+ {
landingGround = true;
m_Owner.pcAnimation.AnimLandingGround();
}
diff --git a/Assets/Scripts/Unit/Components/UnitState/UnitState.cs b/Assets/Scripts/Unit/Components/UnitState/UnitState.cs
index b94a98df..ff42c2be 100644
--- a/Assets/Scripts/Unit/Components/UnitState/UnitState.cs
+++ b/Assets/Scripts/Unit/Components/UnitState/UnitState.cs
@@ -17,6 +17,18 @@ public class UnitState : UnitComponent
}
}
+ // 如果设置了endpoint属性,检查是否到了endpoint
+ public virtual bool isAnimationReachEndPoint
+ {
+ get
+ {
+ var layer = owner.unitAnimation.baseLayer;
+ if (!layer.animationData.HasProperty(EAnimationProperty.Endpoint))
+ return false;
+ return layer.playbackNormalizedTime >= layer.animationData.GetProperty(EAnimationProperty.Endpoint);
+ }
+ }
+
public virtual bool isComboOpen
{
get