MoveCharacter.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class MoveCharacter : Character
  5. {
  6. public Foot foot;
  7. public float extraRiseGravity = 0; //上升时额外重力加速度
  8. public float extraFallGravity = -10; //下落时额外重力加速度
  9. public float moveSpeed = 5;
  10. //[HideInInspector]
  11. public float beRepelValue;
  12. public float totalBeRepelValue;
  13. [HideInInspector]
  14. public float weakTime;
  15. public float totalWeakTime;
  16. public float weakUpSpeed = 10f;
  17. public float decelerationRatio = 1f;
  18. public float minHurtKeepTime = 0.2f;
  19. [HideInInspector]
  20. public float hurtKeepTime = 0;
  21. public float hurtChangeVelocity = 1;
  22. public override void BeHit(int damage, Vector3 force, bool changeHurt, float repelValue)
  23. {
  24. print("MoveCharacterBeHit");
  25. if (invincibleTime > 0)
  26. {
  27. return;
  28. }
  29. hp -= damage;
  30. uiHp.Show(hp, totalHp);
  31. if (hp <= 0)
  32. {
  33. rb.AddForce(force);
  34. ChangeState(CharacterState.Die);
  35. return;
  36. }
  37. else if (changeHurt && state == CharacterState.Weak)
  38. {
  39. print("ChangeHurt");
  40. rb.AddForce(force);
  41. ChangeState(CharacterState.Hurt);
  42. beRepelValue = totalBeRepelValue;
  43. return;
  44. }
  45. beRepelValue -= repelValue;
  46. if (changeHurt && beRepelValue <= 0)
  47. {
  48. print("ChangeWeak");
  49. ChangeState(CharacterState.Weak);
  50. }
  51. }
  52. }