|
|
@@ -4,6 +4,7 @@ using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
using TMPro;
|
|
|
+using System.Linq;
|
|
|
|
|
|
public class MoveCharacter : Character
|
|
|
{
|
|
|
@@ -18,6 +19,7 @@ public class MoveCharacter : Character
|
|
|
[Header("组件")]
|
|
|
public Foot foot;
|
|
|
private ScreenShake ss;
|
|
|
+ [HideInInspector]public AttributeStatus attributeStatus;
|
|
|
|
|
|
[Header("额外重力")]
|
|
|
public float extraRiseGravity = 0; //上升时额外重力加速度
|
|
|
@@ -117,6 +119,7 @@ public class MoveCharacter : Character
|
|
|
mats = mesh.materials;
|
|
|
origY = transform.position.y;
|
|
|
ss = Camera.main.GetComponentInParent<ScreenShake>();
|
|
|
+ attributeStatus = GetComponent<AttributeStatus>();
|
|
|
}
|
|
|
|
|
|
private void Start()
|
|
|
@@ -414,24 +417,132 @@ public class MoveCharacter : Character
|
|
|
if (changeHurt)
|
|
|
{
|
|
|
beRepelValue -= repelValue;
|
|
|
- if (state == CharacterState.Weak)
|
|
|
+ //if (state == CharacterState.Weak)
|
|
|
+ //{
|
|
|
+ // if (!canNotAddForce)
|
|
|
+ // {
|
|
|
+ // rb.AddForce(force * weakHitRate);
|
|
|
+ // ChangeState(CharacterState.Weak);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //else if (beRepelValue <= 0)
|
|
|
+ //{
|
|
|
+ // if (!canNotAddForce)
|
|
|
+ // {
|
|
|
+ // rb.AddForce(force);
|
|
|
+ // }
|
|
|
+ // ChangeState(CharacterState.Weak);
|
|
|
+ //}
|
|
|
+ }
|
|
|
+
|
|
|
+ if (gameObject.layer == 6) //屏幕红闪+抖动
|
|
|
+ {
|
|
|
+ if (ss == null)
|
|
|
+ {
|
|
|
+ ss = Camera.main.GetComponentInParent<ScreenShake>();
|
|
|
+ }
|
|
|
+ ss.enabled = true;
|
|
|
+ if (isSustainedInjury || damage >= heavyDamage)
|
|
|
+ {
|
|
|
+ ss.HeavyShakeShine();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public override void BeHit(AttackInfo attackInfo, float dir)
|
|
|
+ {
|
|
|
+ if (attackInfo.attackEffect.Length > 0)
|
|
|
+ {
|
|
|
+ foreach (AttackEffect ae in attackInfo.attackEffect)
|
|
|
{
|
|
|
- if (!canNotAddForce)
|
|
|
+ switch (ae)
|
|
|
{
|
|
|
- rb.AddForce(force * weakHitRate);
|
|
|
- ChangeState(CharacterState.Weak);
|
|
|
+ case AttackEffect.BlownUp:
|
|
|
+ attributeStatus.AddBlowUp(attackInfo.blowUp,dir);
|
|
|
+ break;
|
|
|
+ case AttackEffect.ShotDown:
|
|
|
+ attributeStatus.AddShotDown();
|
|
|
+ break;
|
|
|
+ case AttackEffect.Stun:
|
|
|
+ attributeStatus.AddStun();
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
- else if (beRepelValue <= 0)
|
|
|
+ }
|
|
|
+
|
|
|
+ int damage = attackInfo.damage;
|
|
|
+ //漂浮易伤
|
|
|
+ if (isFloat)
|
|
|
+ {
|
|
|
+ damage = (int)((1 + easyToGetHit) * damage);
|
|
|
+ }
|
|
|
+
|
|
|
+ //伤害减免
|
|
|
+ if (isDamageReduction)
|
|
|
+ {
|
|
|
+ damage = (int)((1 - reductionDegree) * damage);
|
|
|
+ }
|
|
|
+
|
|
|
+ hp -= damage;
|
|
|
+
|
|
|
+ //伤害跳字
|
|
|
+ if (showInjuryNum)
|
|
|
+ {
|
|
|
+ GameObject injuryNum = Instantiate(injuryNumText);
|
|
|
+ injuryNum.transform.position = new Vector3(transform.position.x + Random.Range(-1f, 1f), transform.position.y + 1, transform.position.z);
|
|
|
+ TextMeshProUGUI text = injuryNum.GetComponentInChildren<TextMeshProUGUI>();
|
|
|
+ text.text = damage.ToString();
|
|
|
+ if (gameObject.CompareTag("Player"))
|
|
|
{
|
|
|
- if (!canNotAddForce)
|
|
|
+ text.color = Color.red;
|
|
|
+ if (debugAttackFrom)
|
|
|
{
|
|
|
- rb.AddForce(force);
|
|
|
+ Debug.Log("主角受到" + damage.ToString() + "点伤害");
|
|
|
}
|
|
|
- ChangeState(CharacterState.Weak);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ uiHp.Show(hp, totalHp);
|
|
|
+ if (hp <= 0)
|
|
|
+ {
|
|
|
+ ChangeState(CharacterState.Die);
|
|
|
+ if (!canNotAddForce)
|
|
|
+ {
|
|
|
+ weakForce = attackInfo.attackDir * attackInfo.force;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ weakForce = Vector3.zero;
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (canNotChangeHurt)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //if (changeHurt)
|
|
|
+ //{
|
|
|
+ // beRepelValue -= repelValue;
|
|
|
+ // //if (state == CharacterState.Weak)
|
|
|
+ // //{
|
|
|
+ // // if (!canNotAddForce)
|
|
|
+ // // {
|
|
|
+ // // rb.AddForce(force * weakHitRate);
|
|
|
+ // // ChangeState(CharacterState.Weak);
|
|
|
+ // // }
|
|
|
+ // //}
|
|
|
+ // //else if (beRepelValue <= 0)
|
|
|
+ // //{
|
|
|
+ // // if (!canNotAddForce)
|
|
|
+ // // {
|
|
|
+ // // rb.AddForce(force);
|
|
|
+ // // }
|
|
|
+ // // ChangeState(CharacterState.Weak);
|
|
|
+ // //}
|
|
|
+ //}
|
|
|
+
|
|
|
if (gameObject.layer == 6) //屏幕红闪+抖动
|
|
|
{
|
|
|
if (ss == null)
|
|
|
@@ -442,7 +553,7 @@ public class MoveCharacter : Character
|
|
|
if (isSustainedInjury || damage >= heavyDamage)
|
|
|
{
|
|
|
ss.HeavyShakeShine();
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|