|
|
@@ -1,5 +1,3 @@
|
|
|
-using System.Collections;
|
|
|
-using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
|
@@ -12,16 +10,40 @@ public class ESpirits_Assassin : Enemy
|
|
|
FindPlayer, //寻找主角位置
|
|
|
Ready, //冲刺预警
|
|
|
Rushing, //向主角方向冲刺中
|
|
|
+ ReadyToDown, //准备落地斩
|
|
|
+ Down, //落地斩
|
|
|
+ DownEnd,
|
|
|
}
|
|
|
[FoldoutGroup("组件")] public GameObject aimPrefab;
|
|
|
+ [FoldoutGroup("组件")] public AttackTrigger dashTrigger;
|
|
|
[FoldoutGroup("角色信息")][DisplayOnly] public ESpiritsState eSpiritsState;
|
|
|
|
|
|
[Space(30)]
|
|
|
[Title("ESpirits_Assassin属性")]
|
|
|
- public float time;
|
|
|
+ [DisplayOnly] public float time;
|
|
|
public float attackCD;
|
|
|
- [FoldoutGroup("冲刺")] [LabelText("冲刺预警距离")]public float readyDistance;
|
|
|
+ [FoldoutGroup("冲刺")] [LabelText("预警距离")] public float readyDistance;
|
|
|
[FoldoutGroup("冲刺")] [LabelText("冲刺距离")] public float rushDistance;
|
|
|
+ [FoldoutGroup("冲刺")] [LabelText("瞄准时间")] public float readyTime;
|
|
|
+ [FoldoutGroup("冲刺")] [LabelText("冲刺速度")] public float rushSpeed;
|
|
|
+ private Vector3 directionToTarget;
|
|
|
+ private float angleToTarget;
|
|
|
+ private Vector3 startRushPos;
|
|
|
+ private float endTime;
|
|
|
+ public AnimationClip fall_endAnimationClip;
|
|
|
+ public override void Awake()
|
|
|
+ {
|
|
|
+ base.Awake();
|
|
|
+ endTime = fall_endAnimationClip.length;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void Start()
|
|
|
+ {
|
|
|
+ base.Start();
|
|
|
+ len = 1;
|
|
|
+ dashTrigger.attackInfo.damage = attackController.attackMethod[1].attackInfo.damage;
|
|
|
+ }
|
|
|
+
|
|
|
public override void Init()
|
|
|
{
|
|
|
base.Init();
|
|
|
@@ -40,7 +62,6 @@ public class ESpirits_Assassin : Enemy
|
|
|
time += Time.deltaTime;
|
|
|
if (time > attackCD)
|
|
|
{
|
|
|
- time = 0;
|
|
|
eSpiritsState = ESpiritsState.FindPlayer;
|
|
|
}
|
|
|
break;
|
|
|
@@ -54,12 +75,15 @@ public class ESpirits_Assassin : Enemy
|
|
|
rb.velocity = Vector3.zero;
|
|
|
hitFeedbackSystem.canFreeze = false;
|
|
|
attributeStatus.resistances.controlOrder = 1;
|
|
|
+ bodyCollider.SetActive(false);
|
|
|
+ rb.useGravity = false;
|
|
|
ani.Play("charge", 0, 0);
|
|
|
- aimPrefab.transform.localScale = new Vector3(bodyTrans.localScale.x>0? -rushDistance:rushDistance, 1, 1);
|
|
|
- Vector3 directionToTarget = playerController.transform.position - aimPrefab.transform.position;
|
|
|
- float angle = Mathf.Atan2(directionToTarget.y, directionToTarget.x) * Mathf.Rad2Deg;
|
|
|
- aimPrefab.transform.rotation = Quaternion.Euler(0, 0, angle);
|
|
|
+ aimPrefab.transform.localScale = new Vector3(rushDistance / 1.5f, 1, 1);
|
|
|
+ directionToTarget = (playerController.transform.position + Vector3.up - aimPrefab.transform.position).normalized;
|
|
|
+ angleToTarget = Mathf.Atan2(directionToTarget.y, directionToTarget.x) * Mathf.Rad2Deg;
|
|
|
+ aimPrefab.transform.rotation = Quaternion.Euler(0, 0, angleToTarget);
|
|
|
aimPrefab.SetActive(true);
|
|
|
+ time = 0;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
@@ -69,11 +93,109 @@ public class ESpirits_Assassin : Enemy
|
|
|
switch (eSpiritsState)
|
|
|
{
|
|
|
case ESpiritsState.Ready:
|
|
|
- Vector3 directionToTarget = playerController.transform.position - aimPrefab.transform.position;
|
|
|
- float angle = Mathf.Atan2(directionToTarget.y, directionToTarget.x) * Mathf.Rad2Deg;
|
|
|
- aimPrefab.transform.rotation = Quaternion.Euler(0, 0, angle);
|
|
|
+ directionToTarget =
|
|
|
+ (playerController.transform.position + Vector3.up - aimPrefab.transform.position).normalized;
|
|
|
+ angleToTarget = Mathf.Atan2(directionToTarget.y, directionToTarget.x) * Mathf.Rad2Deg;
|
|
|
+ aimPrefab.transform.rotation = Quaternion.Euler(0, 0, angleToTarget);
|
|
|
+ time += Time.deltaTime;
|
|
|
+ if(directionToTarget.x > 0 && bodyTrans.localScale.x > 0
|
|
|
+ || directionToTarget.x <0 && bodyTrans.localScale.x < 0)
|
|
|
+ {
|
|
|
+ Turn();
|
|
|
+ }
|
|
|
+ if(time > readyTime)
|
|
|
+ {
|
|
|
+ time = 0;
|
|
|
+ aimPrefab.SetActive(false);
|
|
|
+ ani.Play("attack_summon", 0, 0);
|
|
|
+ //dashTrigger.SetActive(true);
|
|
|
+ eSpiritsState = ESpiritsState.Rushing;
|
|
|
+ transform.rotation = Quaternion.Euler(0, 0,
|
|
|
+ bodyTrans.localScale.x > 0 ?
|
|
|
+ angleToTarget - 180
|
|
|
+ : angleToTarget);
|
|
|
+ startRushPos = transform.position;
|
|
|
+ attackController.ChooseAttack(0);
|
|
|
+ dashTrigger.gameObject.SetActive(true);
|
|
|
+ }
|
|
|
break;
|
|
|
case ESpiritsState.Rushing:
|
|
|
+ rb.velocity = directionToTarget * rushSpeed;
|
|
|
+ if(Vector3.Distance(startRushPos,transform.position) > rushDistance)
|
|
|
+ {
|
|
|
+ dashTrigger.gameObject.SetActive(false);
|
|
|
+ rb.velocity = Vector3.zero;
|
|
|
+ Quaternion targetQt = Quaternion.Euler(Vector3.zero);
|
|
|
+ if (foot.TrigGround)
|
|
|
+ {
|
|
|
+ bodyCollider.SetActive(true);
|
|
|
+ eSpiritsState = ESpiritsState.DownEnd;
|
|
|
+ ani.Play("fall_end", 0, 0);
|
|
|
+ rb.useGravity = true;
|
|
|
+ if (!foot.haveGravity)
|
|
|
+ {
|
|
|
+ transform.position = new Vector3(transform.position.x, platformPosY, transform.position.z);
|
|
|
+ targetQt = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, platformRotZ);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ eSpiritsState = ESpiritsState.ReadyToDown;
|
|
|
+ ani.Play("charge", 0, 0);
|
|
|
+ directionToTarget = Vector3.down;
|
|
|
+ angleToTarget = 270;
|
|
|
+ }
|
|
|
+ transform.rotation = targetQt;
|
|
|
+ time = 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ESpiritsState.ReadyToDown:
|
|
|
+ time += Time.deltaTime;
|
|
|
+ if (time > readyTime)
|
|
|
+ {
|
|
|
+ ani.Play("attack_summon", 0, 0);
|
|
|
+ transform.rotation = Quaternion.Euler(0, 0,
|
|
|
+ bodyTrans.localScale.x > 0 ?
|
|
|
+ angleToTarget - 180
|
|
|
+ : angleToTarget);
|
|
|
+ //dashTrigger.SetActive(true);
|
|
|
+ eSpiritsState = ESpiritsState.Down;
|
|
|
+ startRushPos = transform.position;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ESpiritsState.Down:
|
|
|
+ rb.velocity = directionToTarget * rushSpeed;
|
|
|
+ if (foot.TrigGround)
|
|
|
+ {
|
|
|
+ bodyCollider.SetActive(true);
|
|
|
+ eSpiritsState = ESpiritsState.DownEnd;
|
|
|
+ rb.velocity = Vector3.zero;
|
|
|
+ ani.Play("fall_end", 0, 0);
|
|
|
+ rb.useGravity = true;
|
|
|
+ Quaternion targetQt = Quaternion.Euler(Vector3.zero);
|
|
|
+ if (!foot.haveGravity)
|
|
|
+ {
|
|
|
+ transform.position = new Vector3(transform.position.x, platformPosY, transform.position.z);
|
|
|
+ targetQt = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, platformRotZ);
|
|
|
+ }
|
|
|
+ transform.rotation = targetQt;
|
|
|
+ time = 0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ESpiritsState.DownEnd:
|
|
|
+ time += Time.deltaTime;
|
|
|
+ if(time > endTime)
|
|
|
+ {
|
|
|
+ eSpiritsState = ESpiritsState.Normal;
|
|
|
+ ani.Play("idle", 0, 0);
|
|
|
+ time = 0;
|
|
|
+ hitFeedbackSystem.canFreeze = true;
|
|
|
+ attributeStatus.resistances.controlOrder = 0;
|
|
|
+ state = CharacterState.Idle;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ base.OnState();
|
|
|
break;
|
|
|
}
|
|
|
return;
|