|
|
@@ -15,7 +15,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
public enum SpecialState
|
|
|
{
|
|
|
Null = -1,
|
|
|
- Float = 0,
|
|
|
+ FloatState = 0,
|
|
|
ShotDown = 1,
|
|
|
BlownUp = 2,
|
|
|
Stun = 3,
|
|
|
@@ -24,16 +24,14 @@ public class AttributeStatus : MonoBehaviour
|
|
|
public List<SpecialState> curSpecialStates = new List<SpecialState> {SpecialState.Null}; //[0]存放控制类状态,没有则为SpecialState.Null,[1:]存放其他状态
|
|
|
|
|
|
[Header("各状态时间")]
|
|
|
- [DisplayOnly] public float strikeStunTime;
|
|
|
-
|
|
|
- [Header("被击飞阻力")]
|
|
|
- public float decelerationRatioX = 2f;
|
|
|
- public float decelerationRatioY = 15f;
|
|
|
+ [DisplayOnly] public float attributeTime;
|
|
|
|
|
|
//抗性
|
|
|
[Serializable]
|
|
|
public struct Resistances
|
|
|
{
|
|
|
+ [Range(0, 1)]
|
|
|
+ public float Float;
|
|
|
[Range(0,1)]
|
|
|
public float BlowUp;
|
|
|
[Range(0,1)]
|
|
|
@@ -41,10 +39,25 @@ public class AttributeStatus : MonoBehaviour
|
|
|
[Range(0,1)]
|
|
|
public float Stun;
|
|
|
}
|
|
|
-
|
|
|
[Header("抗性")]
|
|
|
public Resistances resistances;
|
|
|
|
|
|
+ [Header("被击飞阻力")]
|
|
|
+ public float decelerationRatioX = 2f;
|
|
|
+ public float decelerationRatioY = 15f;
|
|
|
+
|
|
|
+ //漂浮
|
|
|
+ public int floatingState; //0:不漂浮;1:漂浮中;2:飘着;3:掉下去
|
|
|
+ private Vector3 origPos; //初始位置
|
|
|
+ private float curHeight; //当前所在高度
|
|
|
+ private float riseTime; //上升时间
|
|
|
+ private float backSpeed; //返回速度
|
|
|
+ private float rotateSpeed; //旋转速度
|
|
|
+ private float rotateDir; //旋转方向
|
|
|
+ private float height; //漂浮高度
|
|
|
+ private float rise = 1;
|
|
|
+ private float normalFallSpeed = 15f;
|
|
|
+
|
|
|
private void Awake()
|
|
|
{
|
|
|
character = GetComponent<MoveCharacter>();
|
|
|
@@ -57,6 +70,60 @@ public class AttributeStatus : MonoBehaviour
|
|
|
{
|
|
|
switch (curSpecialStates[0])
|
|
|
{
|
|
|
+ //漂浮
|
|
|
+ case SpecialState.FloatState:
|
|
|
+ switch (floatingState)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ transform.localEulerAngles += new Vector3(0, 0, 1) * rotateDir * rotateSpeed * Time.deltaTime;
|
|
|
+ curHeight = Mathf.SmoothDamp(curHeight, height, ref rise, riseTime);
|
|
|
+ transform.position = new Vector3(origPos.x, curHeight, origPos.z);
|
|
|
+ if (curHeight >= height - 0.02f)
|
|
|
+ {
|
|
|
+ floatingState = 2;
|
|
|
+ height = transform.position.y;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ transform.localEulerAngles += new Vector3(0, 0, 1) * rotateDir * rotateSpeed * Time.deltaTime;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ if (transform.position.y >= origPos.y + 0.05f)
|
|
|
+ {
|
|
|
+ curHeight -= normalFallSpeed * Time.deltaTime;
|
|
|
+ transform.position = new Vector3(origPos.x, curHeight, origPos.z);
|
|
|
+ }
|
|
|
+ else if (foot.TrigGround || curHeight <= origPos.y + 0.05f)
|
|
|
+ {
|
|
|
+ floatingState = 0;
|
|
|
+ character.ChangeState(CharacterState.Idle);
|
|
|
+ curSpecialStates[0] = SpecialState.Null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ PlayerController playerController = GetComponent<PlayerController>();
|
|
|
+ if (playerController != null)
|
|
|
+ {
|
|
|
+ if (playerController.mp > 0)
|
|
|
+ {
|
|
|
+ playerController.lostMp += playerController.mpReplySpeed * Time.deltaTime;
|
|
|
+ playerController.mp -= playerController.mpReplySpeed * Time.deltaTime;
|
|
|
+ }
|
|
|
+ if (playerController.lostMp >= playerController.addMp)
|
|
|
+ {
|
|
|
+ Instantiate(playerController.soul, transform.position, new Quaternion(0, 0, 0, 0), null);
|
|
|
+ playerController.lostMp = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ attributeTime -= Time.deltaTime;
|
|
|
+ if (attributeTime <= 0)
|
|
|
+ {
|
|
|
+ transform.localEulerAngles = Vector3.zero;
|
|
|
+ floatingState = 3;
|
|
|
+ rb.useGravity = true;
|
|
|
+ }
|
|
|
+ break;
|
|
|
//击飞
|
|
|
case SpecialState.BlownUp:
|
|
|
if (rb.velocity.magnitude > 0)
|
|
|
@@ -77,7 +144,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
else
|
|
|
{
|
|
|
//眩晕状态
|
|
|
- if (strikeStunTime <= 0)
|
|
|
+ if (attributeTime <= 0)
|
|
|
{
|
|
|
curSpecialStates[0] = SpecialState.Null;
|
|
|
character.ChangeState(CharacterState.Idle);
|
|
|
@@ -85,7 +152,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
else
|
|
|
{
|
|
|
rb.velocity = Vector3.zero;
|
|
|
- strikeStunTime -= Time.deltaTime;
|
|
|
+ attributeTime -= Time.deltaTime;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
@@ -109,7 +176,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
else
|
|
|
{
|
|
|
//眩晕状态
|
|
|
- if (strikeStunTime <= 0)
|
|
|
+ if (attributeTime <= 0)
|
|
|
{
|
|
|
//被击晕后上升
|
|
|
rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionY;
|
|
|
@@ -123,13 +190,13 @@ public class AttributeStatus : MonoBehaviour
|
|
|
else
|
|
|
{
|
|
|
rb.velocity = Vector3.zero;
|
|
|
- strikeStunTime -= Time.deltaTime;
|
|
|
+ attributeTime -= Time.deltaTime;
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
//眩晕
|
|
|
case SpecialState.Stun:
|
|
|
- if (strikeStunTime <= 0)
|
|
|
+ if (attributeTime <= 0)
|
|
|
{
|
|
|
curSpecialStates[0] = SpecialState.Null;
|
|
|
character.ChangeState(CharacterState.Idle);
|
|
|
@@ -137,7 +204,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
else
|
|
|
{
|
|
|
rb.velocity = Vector3.zero;
|
|
|
- strikeStunTime -= Time.deltaTime;
|
|
|
+ attributeTime -= Time.deltaTime;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
@@ -146,7 +213,29 @@ public class AttributeStatus : MonoBehaviour
|
|
|
//受到漂浮
|
|
|
public void AddFloat(AttackInfo.FloatState floatState)
|
|
|
{
|
|
|
+ if (curSpecialStates[0] != SpecialState.Null && curSpecialStates[0] < SpecialState.FloatState)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ rb.useGravity = false;
|
|
|
+ floatingState = 1;
|
|
|
+ origPos = transform.position;
|
|
|
+ curHeight = origPos.y;
|
|
|
+ riseTime = UnityEngine.Random.Range(floatState.upTime.x, floatState.upTime.y);
|
|
|
+ backSpeed = UnityEngine.Random.Range(floatState.backSpeed.x, floatState.backSpeed.y);
|
|
|
+ if (gameObject.tag == "Enemy" || gameObject.tag == "Player")
|
|
|
+ {
|
|
|
+ backSpeed = -backSpeed;
|
|
|
+ }
|
|
|
+ rotateSpeed = UnityEngine.Random.Range(floatState.rotateSpeed.x, floatState.rotateSpeed.y);
|
|
|
+ rotateDir = (1.5f - UnityEngine.Random.Range(1, 3)) * 2;
|
|
|
+ height = UnityEngine.Random.Range(floatState.height.x, floatState.height.y);
|
|
|
+ attributeTime = floatState.time * (1 - resistances.Float);
|
|
|
+
|
|
|
+ curSpecialStates[0] = SpecialState.FloatState;
|
|
|
+ character.ChangeState(CharacterState.SpecialStatus);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -159,7 +248,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- strikeStunTime = blowUp.time * (1 - resistances.BlowUp);
|
|
|
+ attributeTime = blowUp.time * (1 - resistances.BlowUp);
|
|
|
Vector3 vec3 = blowUp.dir.normalized;
|
|
|
if(dir < 0)
|
|
|
{
|
|
|
@@ -180,7 +269,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- strikeStunTime = shotDown.time * (1 - resistances.ShotDown);
|
|
|
+ attributeTime = shotDown.time * (1 - resistances.ShotDown);
|
|
|
Vector3 vec3 = shotDown.dir.normalized;
|
|
|
if (dir < 0)
|
|
|
{
|
|
|
@@ -201,7 +290,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- strikeStunTime = stun.time * (1 - resistances.Stun);
|
|
|
+ attributeTime = stun.time * (1 - resistances.Stun);
|
|
|
curSpecialStates[0] = SpecialState.Stun;
|
|
|
character.ChangeState(CharacterState.SpecialStatus);
|
|
|
}
|