|
|
@@ -8,7 +8,9 @@ public enum AssassinState
|
|
|
FindPlayer = 1, //寻找主角位置
|
|
|
ReadyToDash = 2, //准备攻击主角
|
|
|
Dash = 3, //向主角方向冲刺
|
|
|
- Down = 4, //落地斩
|
|
|
+ ReadyToDown = 4, //准备落地斩
|
|
|
+ Down = 5, //落地斩
|
|
|
+ Finish = 6, //结束冲刺
|
|
|
}
|
|
|
public class ESpirits_Assassin : MonoBehaviour
|
|
|
{
|
|
|
@@ -28,6 +30,9 @@ public class ESpirits_Assassin : MonoBehaviour
|
|
|
[HideInInspector]
|
|
|
public Vector3 targetDir;
|
|
|
public float dashTime;
|
|
|
+ public float downTime;
|
|
|
+ public float finishTime;
|
|
|
+ public GameObject body;
|
|
|
private void Update()
|
|
|
{
|
|
|
|
|
|
@@ -51,14 +56,13 @@ public class ESpirits_Assassin : MonoBehaviour
|
|
|
break;
|
|
|
case AssassinState.FindPlayer:
|
|
|
ChosePlayer();
|
|
|
- if (distance <= hateDistance)
|
|
|
+ if (distance < hateDistance)
|
|
|
{
|
|
|
- state = AssassinState.ReadyToDash;
|
|
|
+
|
|
|
enemy.ChangeState(CharacterState.Rush);
|
|
|
rb.velocity = Vector3.zero;
|
|
|
enemy.ani.Play("hitted", 0, 0);
|
|
|
- enemy.aniCollider.Play("Hurt", 0, 0);
|
|
|
-
|
|
|
+ state = AssassinState.ReadyToDash;
|
|
|
}
|
|
|
break;
|
|
|
case AssassinState.ReadyToDash:
|
|
|
@@ -84,22 +88,53 @@ public class ESpirits_Assassin : MonoBehaviour
|
|
|
if (enemy.foot.TrigGround)
|
|
|
{
|
|
|
|
|
|
- dashEffect.isDashAttack = false;
|
|
|
- state = AssassinState.Normal;
|
|
|
- enemy.isSpiritsAttack = false;
|
|
|
- enemy.searchState = SearchState.NoTarget;
|
|
|
- enemy.ChangeState(CharacterState.Idle);
|
|
|
+ enemy.ani.Play("idle", 0, 0);
|
|
|
+ state = AssassinState.Finish;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- state = AssassinState.Down;
|
|
|
+ rb.constraints = RigidbodyConstraints.FreezeAll;
|
|
|
+ enemy.ani.Play("hitted", 0, 0);
|
|
|
+ state = AssassinState.ReadyToDown;
|
|
|
}
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case AssassinState.ReadyToDown:
|
|
|
+ time += Time.deltaTime;
|
|
|
+ rb.velocity = Vector3.zero;
|
|
|
+ if(time >= downTime)
|
|
|
+ {
|
|
|
+ time = 0;
|
|
|
+ rb.constraints =
|
|
|
+ RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
|
|
|
+ targetDir = Vector3.down;
|
|
|
+ enemy.ani.Play("attack_summon", 0, 0);
|
|
|
+ state = AssassinState.Down;
|
|
|
}
|
|
|
break;
|
|
|
case AssassinState.Down:
|
|
|
-
|
|
|
+ Dash();
|
|
|
+ if (enemy.foot.TrigGround)
|
|
|
+ {
|
|
|
+ body.transform.rotation = Quaternion.Euler(Vector3.zero);
|
|
|
+
|
|
|
+
|
|
|
+ enemy.ani.Play("idle", 0, 0);
|
|
|
+ state = AssassinState.Finish;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case AssassinState.Finish:
|
|
|
+ time += Time.deltaTime;
|
|
|
+ if(time > finishTime)
|
|
|
+ {
|
|
|
+ dashEffect.isDashAttack = false;
|
|
|
+ enemy.isSpiritsAttack = false;
|
|
|
+ enemy.searchState = SearchState.NoTarget;
|
|
|
+ enemy.ChangeState(CharacterState.Idle);
|
|
|
+ state = AssassinState.Normal;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -131,14 +166,21 @@ public class ESpirits_Assassin : MonoBehaviour
|
|
|
}
|
|
|
private void Dash()
|
|
|
{
|
|
|
+ float k = Mathf.Atan2(targetDir.y, targetDir.x)*Mathf.Rad2Deg;
|
|
|
if (targetDir.x < 0)
|
|
|
{
|
|
|
dashEffect.offset = offset;
|
|
|
+ body.transform.localScale = new Vector3(1, 1, 1);
|
|
|
+ body.transform.rotation = Quaternion.Euler(new Vector3(0, 0, k-180));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dashEffect.offset = -offset;
|
|
|
+ body.transform.localScale = new Vector3(-1, 1, 1);
|
|
|
+ body.transform.rotation = Quaternion.Euler(new Vector3(0, 0, k));
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
rb.velocity = targetDir * moveSpeed;
|
|
|
}
|
|
|
}
|