|
|
@@ -8,15 +8,10 @@ using Sirenix.OdinInspector;
|
|
|
public enum SpecialState
|
|
|
{
|
|
|
Null = -1,
|
|
|
-
|
|
|
- //控制
|
|
|
FloatState = 0,
|
|
|
ShotDown = 1,
|
|
|
BlownUp = 2,
|
|
|
Stun = 3,
|
|
|
-
|
|
|
- //非控制
|
|
|
- armor,
|
|
|
}
|
|
|
|
|
|
public class AttributeStatus : MonoBehaviour
|
|
|
@@ -26,7 +21,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
private Rigidbody rb;
|
|
|
private Foot foot;
|
|
|
|
|
|
- public List<SpecialState> curSpecialStates = new List<SpecialState> {SpecialState.Null}; //[0]存放控制类状态,没有则为SpecialState.Null,[1:]存放其他状态
|
|
|
+ public SpecialState curSpecialStates = SpecialState.Null;
|
|
|
|
|
|
[Header("各状态时间")]
|
|
|
[DisplayOnly] public float attributeTime;
|
|
|
@@ -55,7 +50,6 @@ public class AttributeStatus : MonoBehaviour
|
|
|
public float decelerationRatioX = 2f;
|
|
|
public float decelerationRatioY = 15f;
|
|
|
|
|
|
- //漂浮
|
|
|
[FoldoutGroup("漂浮")]
|
|
|
[DisplayOnly]public int floatingState; //0:不漂浮;1:漂浮中;2:飘着;3:掉下去
|
|
|
private Vector3 origPos; //初始位置
|
|
|
@@ -68,6 +62,11 @@ public class AttributeStatus : MonoBehaviour
|
|
|
private float rise = 1;
|
|
|
private float normalFallSpeed = 15f;
|
|
|
|
|
|
+ [FoldoutGroup("易伤")]
|
|
|
+ [DisplayOnly][ToggleLeft] public bool haveVulnerable;
|
|
|
+ [DisplayOnly] public float vulnerableTime;
|
|
|
+ private float vulnerableRate;
|
|
|
+
|
|
|
private void Awake()
|
|
|
{
|
|
|
character = GetComponent<MoveCharacter>();
|
|
|
@@ -75,6 +74,15 @@ public class AttributeStatus : MonoBehaviour
|
|
|
foot = GetComponentInChildren<Foot>();
|
|
|
}
|
|
|
|
|
|
+ public void Update()
|
|
|
+ {
|
|
|
+ vulnerableTime -= Time.deltaTime;
|
|
|
+ if (vulnerableTime <= 0)
|
|
|
+ {
|
|
|
+ haveVulnerable = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//CharacterState为SpecialStatus时调用此函数
|
|
|
public void SpecialStateEffect(SpecialState specialState)
|
|
|
{
|
|
|
@@ -107,7 +115,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
{
|
|
|
floatingState = 0;
|
|
|
character.ChangeState(CharacterState.Idle);
|
|
|
- curSpecialStates[0] = SpecialState.Null;
|
|
|
+ curSpecialStates = SpecialState.Null;
|
|
|
return;
|
|
|
}
|
|
|
break;
|
|
|
@@ -156,7 +164,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
//眩晕状态
|
|
|
if (attributeTime <= 0)
|
|
|
{
|
|
|
- curSpecialStates[0] = SpecialState.Null;
|
|
|
+ curSpecialStates = SpecialState.Null;
|
|
|
character.ChangeState(CharacterState.Idle);
|
|
|
}
|
|
|
else
|
|
|
@@ -193,7 +201,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
rb.useGravity = false;
|
|
|
if (character.AdjustHeight())
|
|
|
{
|
|
|
- curSpecialStates[0] = SpecialState.Null;
|
|
|
+ curSpecialStates = SpecialState.Null;
|
|
|
character.ChangeState(CharacterState.Idle);
|
|
|
}
|
|
|
}
|
|
|
@@ -208,7 +216,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
case SpecialState.Stun:
|
|
|
if (attributeTime <= 0)
|
|
|
{
|
|
|
- curSpecialStates[0] = SpecialState.Null;
|
|
|
+ curSpecialStates = SpecialState.Null;
|
|
|
character.ChangeState(CharacterState.Idle);
|
|
|
}
|
|
|
else
|
|
|
@@ -220,10 +228,16 @@ public class AttributeStatus : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public int DamageCalculation(int damage)
|
|
|
+ {
|
|
|
+ damage = (int)(damage * (1 + vulnerableRate) + 0.5f);
|
|
|
+ return damage;
|
|
|
+ }
|
|
|
+
|
|
|
//判断优先级,ture为优先级高于当前控制
|
|
|
public bool PriorityOrder(SpecialState specialState)
|
|
|
{
|
|
|
- if (curSpecialStates[0] != SpecialState.Null && curSpecialStates[0] < specialState)
|
|
|
+ if (curSpecialStates != SpecialState.Null && curSpecialStates < specialState)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
@@ -253,7 +267,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
height = UnityEngine.Random.Range(floatState.height.x, floatState.height.y);
|
|
|
attributeTime = floatState.time * (1 - resistances.Float);
|
|
|
|
|
|
- curSpecialStates[0] = SpecialState.FloatState;
|
|
|
+ curSpecialStates = SpecialState.FloatState;
|
|
|
character.ChangeState(CharacterState.SpecialStatus_Float);
|
|
|
}
|
|
|
|
|
|
@@ -275,7 +289,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
vec3.x = -vec3.x;
|
|
|
}
|
|
|
rb.AddForce(vec3 * blowUp.force * (1 - resistances.BlowUp), ForceMode.Impulse);
|
|
|
- curSpecialStates[0] = SpecialState.BlownUp;
|
|
|
+ curSpecialStates = SpecialState.BlownUp;
|
|
|
character.ChangeState(CharacterState.SpecialStatus_BlowUp);
|
|
|
}
|
|
|
|
|
|
@@ -299,7 +313,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
rb.useGravity = true;
|
|
|
rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
|
|
|
rb.AddForce(vec3 * shotDown.force * (1 - resistances.ShotDown), ForceMode.Impulse);
|
|
|
- curSpecialStates[0] = SpecialState.ShotDown;
|
|
|
+ curSpecialStates = SpecialState.ShotDown;
|
|
|
character.ChangeState(CharacterState.SpecialStatus_ShotDown);
|
|
|
}
|
|
|
|
|
|
@@ -311,7 +325,7 @@ public class AttributeStatus : MonoBehaviour
|
|
|
return;
|
|
|
}
|
|
|
attributeTime = stun.time * (1 - resistances.Stun);
|
|
|
- curSpecialStates[0] = SpecialState.Stun;
|
|
|
+ curSpecialStates = SpecialState.Stun;
|
|
|
character.ChangeState(CharacterState.SpecialStatus_Stun);
|
|
|
}
|
|
|
|
|
|
@@ -336,6 +350,8 @@ public class AttributeStatus : MonoBehaviour
|
|
|
//受到易伤
|
|
|
public void AddVulnerable(AttackInfo.Vulnerable vulnerable)
|
|
|
{
|
|
|
-
|
|
|
+ vulnerableTime = vulnerable.time;
|
|
|
+ vulnerableRate = vulnerable.rate;
|
|
|
+ haveVulnerable = true;
|
|
|
}
|
|
|
}
|