|
|
@@ -102,6 +102,12 @@ public class MoveCharacter : Character
|
|
|
public float transmitTime;
|
|
|
public PortalsController portalsController;
|
|
|
|
|
|
+ [Header("受到持续伤害")]
|
|
|
+ public bool isSustainedInjury; //是否正在受到持续伤害
|
|
|
+ [HideInInspector] public float sustainedInjuryTime; //存储持续伤害经过的时间
|
|
|
+ public float sustainedInjury_IntervalTime; //每次伤害的间隔时间
|
|
|
+ public int sustainedInjury_damage; //每次造成的伤害
|
|
|
+
|
|
|
private void Awake()
|
|
|
{
|
|
|
spinee = bodyTrans.GetChild(0).gameObject;
|
|
|
@@ -288,6 +294,11 @@ public class MoveCharacter : Character
|
|
|
portalsController.rbs.Remove(rb);
|
|
|
}
|
|
|
}
|
|
|
+ //受到持续伤害
|
|
|
+ if (isSustainedInjury)
|
|
|
+ {
|
|
|
+ SustainedInjury();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//伤害减免状态开启(减免程度,减免时长)
|
|
|
@@ -317,66 +328,65 @@ public class MoveCharacter : Character
|
|
|
|
|
|
public override void BeHit(int damage, Vector3 force, bool changeHurt, float repelValue)
|
|
|
{
|
|
|
- if (!isTran)
|
|
|
+ if (isInvisible)
|
|
|
{
|
|
|
- if (isInvisible)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (invincibleTime > 0)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (invincibleTime > 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- //漂浮易伤
|
|
|
- if (isFloat)
|
|
|
- {
|
|
|
- damage = (int)((1 + easyToGetHit) * damage);
|
|
|
- }
|
|
|
+ //漂浮易伤
|
|
|
+ if (isFloat)
|
|
|
+ {
|
|
|
+ damage = (int)((1 + easyToGetHit) * damage);
|
|
|
+ }
|
|
|
|
|
|
- //伤害减免
|
|
|
- if (isDamageReduction)
|
|
|
- {
|
|
|
- damage = (int)((1 - reductionDegree) * damage);
|
|
|
- }
|
|
|
+ //伤害减免
|
|
|
+ if (isDamageReduction)
|
|
|
+ {
|
|
|
+ damage = (int)((1 - reductionDegree) * damage);
|
|
|
+ }
|
|
|
|
|
|
- hp -= damage;
|
|
|
- uiHp.Show(hp, totalHp);
|
|
|
- if (hp <= 0)
|
|
|
- {
|
|
|
- ChangeState(CharacterState.Die);
|
|
|
- if(!canNotAddForce)
|
|
|
- rb.AddForce(force);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (canNotChangeHurt)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- beRepelValue -= repelValue;
|
|
|
- if (changeHurt && state == CharacterState.Weak)
|
|
|
- {
|
|
|
- if (!canNotAddForce)
|
|
|
- rb.AddForce(force * weakHitRate);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (changeHurt && beRepelValue <= 0)
|
|
|
- {
|
|
|
- ChangeState(CharacterState.Weak);
|
|
|
- if (!canNotAddForce)
|
|
|
- rb.AddForce(force);
|
|
|
- }
|
|
|
- }
|
|
|
+ hp -= damage;
|
|
|
+ uiHp.Show(hp, totalHp);
|
|
|
+ if (hp <= 0)
|
|
|
+ {
|
|
|
+ ChangeState(CharacterState.Die);
|
|
|
+ if (!canNotAddForce)
|
|
|
+ rb.AddForce(force);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (canNotChangeHurt)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ beRepelValue -= repelValue;
|
|
|
+ if (changeHurt && state == CharacterState.Weak)
|
|
|
+ {
|
|
|
+ if (!canNotAddForce)
|
|
|
+ rb.AddForce(force * weakHitRate);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (pc == null)
|
|
|
+ if (changeHurt && beRepelValue <= 0)
|
|
|
{
|
|
|
- pc = GetComponentInParent<PlayerController>();
|
|
|
+ ChangeState(CharacterState.Weak);
|
|
|
+ if (!canNotAddForce)
|
|
|
+ rb.AddForce(force);
|
|
|
}
|
|
|
- pc.BeHit(damage, force, false, repelValue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //受到持续伤害
|
|
|
+ public void SustainedInjury()
|
|
|
+ {
|
|
|
+ sustainedInjuryTime += Time.deltaTime;
|
|
|
+ if(sustainedInjuryTime >= sustainedInjury_IntervalTime)
|
|
|
+ {
|
|
|
+ sustainedInjuryTime = 0;
|
|
|
+ BeHit(sustainedInjury_damage, Vector3.zero,false,0);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|