|
|
@@ -1,9 +1,24 @@
|
|
|
-using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
using System;
|
|
|
+using Sirenix.OdinInspector;
|
|
|
|
|
|
|
|
|
+//各个状态
|
|
|
+public enum SpecialState
|
|
|
+{
|
|
|
+ Null = -1,
|
|
|
+
|
|
|
+ //控制
|
|
|
+ FloatState = 0,
|
|
|
+ ShotDown = 1,
|
|
|
+ BlownUp = 2,
|
|
|
+ Stun = 3,
|
|
|
+
|
|
|
+ //非控制
|
|
|
+ armor,
|
|
|
+}
|
|
|
+
|
|
|
public class AttributeStatus : MonoBehaviour
|
|
|
{
|
|
|
//组件
|
|
|
@@ -11,16 +26,6 @@ public class AttributeStatus : MonoBehaviour
|
|
|
private Rigidbody rb;
|
|
|
private Foot foot;
|
|
|
|
|
|
- //各个状态
|
|
|
- public enum SpecialState
|
|
|
- {
|
|
|
- Null = -1,
|
|
|
- FloatState = 0,
|
|
|
- ShotDown = 1,
|
|
|
- BlownUp = 2,
|
|
|
- Stun = 3,
|
|
|
- Coma = 4,
|
|
|
- }
|
|
|
public List<SpecialState> curSpecialStates = new List<SpecialState> {SpecialState.Null}; //[0]存放控制类状态,没有则为SpecialState.Null,[1:]存放其他状态
|
|
|
|
|
|
[Header("各状态时间")]
|
|
|
@@ -30,24 +35,29 @@ public class AttributeStatus : MonoBehaviour
|
|
|
[Serializable]
|
|
|
public struct Resistances
|
|
|
{
|
|
|
- [Range(0, 1)]
|
|
|
+ //控制效果抗性
|
|
|
+ [Range(0, 1)][LabelText("漂浮抗性")]
|
|
|
public float Float;
|
|
|
- [Range(0,1)]
|
|
|
+ [Range(0, 1)][LabelText("击飞抗性")]
|
|
|
public float BlowUp;
|
|
|
- [Range(0,1)]
|
|
|
+ [Range(0, 1)][LabelText("击落抗性")]
|
|
|
public float ShotDown;
|
|
|
- [Range(0,1)]
|
|
|
+ [Range(0, 1)][LabelText("击晕抗性")]
|
|
|
public float Stun;
|
|
|
+
|
|
|
+ [Space]
|
|
|
+ //非控制效果抗性
|
|
|
+ [LabelText("护甲值")]public int armor;
|
|
|
}
|
|
|
- [Header("抗性")]
|
|
|
- public Resistances resistances;
|
|
|
+ [LabelText("抗性")]public Resistances resistances;
|
|
|
|
|
|
[Header("被击飞阻力")]
|
|
|
public float decelerationRatioX = 2f;
|
|
|
public float decelerationRatioY = 15f;
|
|
|
|
|
|
//漂浮
|
|
|
- public int floatingState; //0:不漂浮;1:漂浮中;2:飘着;3:掉下去
|
|
|
+ [FoldoutGroup("漂浮")]
|
|
|
+ [DisplayOnly]public int floatingState; //0:不漂浮;1:漂浮中;2:飘着;3:掉下去
|
|
|
private Vector3 origPos; //初始位置
|
|
|
private float curHeight; //当前所在高度
|
|
|
private float riseTime; //上升时间
|
|
|
@@ -66,9 +76,9 @@ public class AttributeStatus : MonoBehaviour
|
|
|
}
|
|
|
|
|
|
//CharacterState为SpecialStatus时调用此函数
|
|
|
- public void SpecialStateEffect()
|
|
|
+ public void SpecialStateEffect(SpecialState specialState)
|
|
|
{
|
|
|
- switch (curSpecialStates[0])
|
|
|
+ switch (specialState)
|
|
|
{
|
|
|
//漂浮
|
|
|
case SpecialState.FloatState:
|
|
|
@@ -210,14 +220,23 @@ public class AttributeStatus : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //判断优先级,ture为优先级高于当前控制
|
|
|
+ public bool PriorityOrder(SpecialState specialState)
|
|
|
+ {
|
|
|
+ if (curSpecialStates[0] != SpecialState.Null && curSpecialStates[0] < specialState)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
//受到漂浮
|
|
|
public void AddFloat(AttackInfo.FloatState floatState)
|
|
|
{
|
|
|
- if (curSpecialStates[0] != SpecialState.Null && curSpecialStates[0] < SpecialState.FloatState)
|
|
|
+ if (PriorityOrder(SpecialState.FloatState))
|
|
|
{
|
|
|
return;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
rb.useGravity = false;
|
|
|
floatingState = 1;
|
|
|
@@ -235,63 +254,88 @@ public class AttributeStatus : MonoBehaviour
|
|
|
attributeTime = floatState.time * (1 - resistances.Float);
|
|
|
|
|
|
curSpecialStates[0] = SpecialState.FloatState;
|
|
|
- character.ChangeState(CharacterState.SpecialStatus);
|
|
|
+ character.ChangeState(CharacterState.SpecialStatus_Float);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//受到击飞
|
|
|
public void AddBlowUp(AttackInfo.BlowUp blowUp, float dir)
|
|
|
{
|
|
|
- if (rb.useGravity)
|
|
|
+ if (!rb.useGravity)
|
|
|
{
|
|
|
- if(curSpecialStates[0]!=SpecialState.Null && curSpecialStates[0] < SpecialState.BlownUp)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- attributeTime = blowUp.time * (1 - resistances.BlowUp);
|
|
|
- Vector3 vec3 = blowUp.dir.normalized;
|
|
|
- if(dir < 0)
|
|
|
- {
|
|
|
- vec3.x = -vec3.x;
|
|
|
- }
|
|
|
- rb.AddForce(vec3 * blowUp.force * (1 - resistances.BlowUp), ForceMode.Impulse);
|
|
|
- curSpecialStates[0] = SpecialState.BlownUp;
|
|
|
- character.ChangeState(CharacterState.SpecialStatus);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (PriorityOrder(SpecialState.BlownUp))
|
|
|
+ {
|
|
|
+ return;
|
|
|
}
|
|
|
+ attributeTime = blowUp.time * (1 - resistances.BlowUp);
|
|
|
+ Vector3 vec3 = blowUp.dir.normalized;
|
|
|
+ if (dir < 0)
|
|
|
+ {
|
|
|
+ vec3.x = -vec3.x;
|
|
|
+ }
|
|
|
+ rb.AddForce(vec3 * blowUp.force * (1 - resistances.BlowUp), ForceMode.Impulse);
|
|
|
+ curSpecialStates[0] = SpecialState.BlownUp;
|
|
|
+ character.ChangeState(CharacterState.SpecialStatus_BlowUp);
|
|
|
}
|
|
|
|
|
|
//受到击落
|
|
|
public void AddShotDown(AttackInfo.ShotDown shotDown, float dir)
|
|
|
{
|
|
|
- if (!rb.useGravity)
|
|
|
+ if (rb.useGravity)
|
|
|
{
|
|
|
- if (curSpecialStates[0] != SpecialState.Null && curSpecialStates[0] < SpecialState.ShotDown)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- attributeTime = shotDown.time * (1 - resistances.ShotDown);
|
|
|
- Vector3 vec3 = shotDown.dir.normalized;
|
|
|
- if (dir < 0)
|
|
|
- {
|
|
|
- vec3.x = -vec3.x;
|
|
|
- }
|
|
|
- rb.useGravity = true;
|
|
|
- rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
|
|
|
- rb.AddForce(vec3 * shotDown.force * (1 - resistances.ShotDown),ForceMode.Impulse);
|
|
|
- curSpecialStates[0] = SpecialState.ShotDown;
|
|
|
- character.ChangeState(CharacterState.SpecialStatus);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (PriorityOrder(SpecialState.ShotDown))
|
|
|
+ {
|
|
|
+ return;
|
|
|
}
|
|
|
+ attributeTime = shotDown.time * (1 - resistances.ShotDown);
|
|
|
+ Vector3 vec3 = shotDown.dir.normalized;
|
|
|
+ if (dir < 0)
|
|
|
+ {
|
|
|
+ vec3.x = -vec3.x;
|
|
|
+ }
|
|
|
+ rb.useGravity = true;
|
|
|
+ rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
|
|
|
+ rb.AddForce(vec3 * shotDown.force * (1 - resistances.ShotDown), ForceMode.Impulse);
|
|
|
+ curSpecialStates[0] = SpecialState.ShotDown;
|
|
|
+ character.ChangeState(CharacterState.SpecialStatus_ShotDown);
|
|
|
}
|
|
|
|
|
|
//受到击晕
|
|
|
public void AddStun(AttackInfo.Stun stun)
|
|
|
{
|
|
|
- if (curSpecialStates[0] != SpecialState.Null && curSpecialStates[0] < SpecialState.Stun)
|
|
|
+ if (PriorityOrder(SpecialState.Stun))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
attributeTime = stun.time * (1 - resistances.Stun);
|
|
|
curSpecialStates[0] = SpecialState.Stun;
|
|
|
- character.ChangeState(CharacterState.SpecialStatus);
|
|
|
+ character.ChangeState(CharacterState.SpecialStatus_Stun);
|
|
|
+ }
|
|
|
+
|
|
|
+ //受到穿甲
|
|
|
+ public int AddArmor(AttackInfo.Armor armor,int damage)
|
|
|
+ {
|
|
|
+ //计算护甲减免
|
|
|
+ int am = resistances.armor;
|
|
|
+ if (am > 0)
|
|
|
+ {
|
|
|
+ int ap = armor.rate;
|
|
|
+ int c = am - ap;
|
|
|
+ if (c < 0)
|
|
|
+ {
|
|
|
+ c = 0;
|
|
|
+ }
|
|
|
+ damage = (int)(damage * (100f / (100 + c)) + 0.5f);
|
|
|
+ }
|
|
|
+ return damage;
|
|
|
+ }
|
|
|
+
|
|
|
+ //受到易伤
|
|
|
+ public void AddVulnerable(AttackInfo.Vulnerable vulnerable)
|
|
|
+ {
|
|
|
+
|
|
|
}
|
|
|
}
|