AttributeStatus.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using System;
  4. using Sirenix.OdinInspector;
  5. using DG.Tweening;
  6. //各个状态
  7. public enum SpecialState
  8. {
  9. Null = -1,
  10. FloatState = 0,
  11. BlownUp = 1,
  12. ShotDown = 2,
  13. Weak = 3,
  14. }
  15. public class AttributeStatus : MonoBehaviour
  16. {
  17. //组件
  18. private MoveCharacter character;
  19. private Rigidbody rb;
  20. private Foot foot;
  21. private HitFeedbackSystem hitFeedbackSystem;
  22. //behit参数
  23. [DisplayOnly] public SpecialState curSpecialStates = SpecialState.Null;
  24. public AttackController.AttackMethod attackMethod;
  25. [LabelText("控制时间")] [DisplayOnly] public float attributeTime;
  26. [TabGroup("漂浮")]
  27. [DisplayOnly] public int floatingState; //0:不漂浮;1:漂浮中;2:飘着;3:掉下去
  28. private Vector3 origPos; //初始位置
  29. private float curHeight; //当前所在高度
  30. private float riseTime; //上升时间
  31. private float backSpeed; //返回速度
  32. private float rotateSpeed; //旋转速度
  33. private float rotateDir; //旋转方向
  34. private float height; //漂浮高度
  35. private float rise = 1;
  36. private float normalFallSpeed = 15f;
  37. [TabGroup("击飞击落")] [DisplayOnly] public int hitState;
  38. [TabGroup("击飞击落")] [DisplayOnly] public bool isFly;
  39. [TabGroup("击飞击落")] [DisplayOnly] public int jumpNum;
  40. [TabGroup("击飞击落")] [LabelText("弹跳力比例")] public float jumpNumRate;
  41. [TabGroup("击飞击落")] [LabelText("X方向阻力")] public float decelerationRatioX = 2f;
  42. [TabGroup("击飞击落")] [LabelText("Y方向重力")] public float decelerationRatioY = 15f;
  43. public Character landingDamageFrom;
  44. private Vector3 startFlyPos;
  45. [TabGroup("击飞击落")] [LabelText("旋转中心高度")] public float rotateCenterHeight = 1f;
  46. [TabGroup("击飞击落")] [LabelText("起飞预设角度")] public float startFlyAngle = 15f;
  47. [Tooltip("x为最小值,y为最大值")]
  48. [TabGroup("击飞击落")] [LabelText("飞行预设角速度随机范围")] public Vector2 flyingRotateSpeedRange = new Vector2(15, 45);
  49. private float flyingRotateSpeed;
  50. private Vector3 scale;
  51. [TabGroup("击飞击落")] [LabelText("压缩程度")] public float compressionDegree = 0.8f;
  52. [Tooltip("x为向下压缩经过的时间,y为回弹经过的时间")]
  53. [TabGroup("击飞击落")] [LabelText("压缩速度")] public Vector2 compressionSpeed = new Vector2(0.2f, 0.4f);
  54. [TabGroup("击飞击落")] [LabelText("弹跳速度")] public float jumpVel = 5f;
  55. [TabGroup("击飞击落")] private Vector3 flyForce;
  56. [TabGroup("易伤")]
  57. [DisplayOnly] public bool haveVulnerable = false;
  58. [TabGroup("易伤")]
  59. [DisplayOnly] public float vulnerableRate = 0f;
  60. [DisplayOnly] public float vulnerableTime;
  61. [TabGroup("累伤")] [DisplayOnly] public float stackingWoudsTime;
  62. [TabGroup("累伤")] [DisplayOnly] public float stackingWords;
  63. //抗性
  64. [Serializable]
  65. public struct Resistances
  66. {
  67. [LabelText("控制层级")] public int controlOrder;
  68. //控制效果抗性
  69. [Range(0, 1)]
  70. [LabelText("漂浮抗性")]
  71. public float Float;
  72. [Range(0, 1)]
  73. [LabelText("击飞抗性")]
  74. public float BlowUp;
  75. [Range(0, 1)]
  76. [LabelText("击落抗性")]
  77. public float ShotDown;
  78. [Range(0, 1)]
  79. [LabelText("击晕抗性")]
  80. public float Weak;
  81. [Space]
  82. //非控制效果抗性
  83. [LabelText("护甲值")] public int armor;
  84. [LabelText("闪避")] public int dodge;
  85. }
  86. [LabelText("抗性")] public Resistances resistances;
  87. public void Init()
  88. {
  89. stackingWoudsTime = 0;
  90. stackingWords = 0;
  91. }
  92. private void Awake()
  93. {
  94. character = GetComponentInParent<MoveCharacter>();
  95. rb = character.rb;
  96. foot = character.foot;
  97. hitFeedbackSystem = GetComponent<HitFeedbackSystem>();
  98. scale = character.mecanim.transform.localScale;
  99. }
  100. public void Update()
  101. {
  102. //易伤
  103. if (haveVulnerable)
  104. {
  105. vulnerableTime -= Time.deltaTime;
  106. if (vulnerableTime <= 0)
  107. {
  108. vulnerableRate = 0f;
  109. haveVulnerable = false;
  110. }
  111. }
  112. //累伤
  113. if (stackingWords > 0)
  114. {
  115. stackingWoudsTime -= Time.deltaTime;
  116. if (stackingWoudsTime <= 0)
  117. {
  118. stackingWords = 0;
  119. }
  120. }
  121. }
  122. public void AddSpecialState(AttackController.AttackMethod attackMethod, Character attackFrom)
  123. {
  124. if (attackMethod.attackInfo.attackEffect.Count > 0)
  125. {
  126. AttackEffect attackEffect = AttackEffect.Null;
  127. foreach (AttackEffect ae in attackMethod.attackInfo.attackEffect)
  128. {
  129. switch (attackMethod.attackInfo.attackEffect[0])
  130. {
  131. /*控制*/
  132. //漂浮
  133. case AttackEffect.FloatState:
  134. if (resistances.Float == 1)
  135. {
  136. break;
  137. }
  138. if (PriorityOrder(SpecialState.FloatState, attackMethod.attackInfo.floatState.ControlOrder))
  139. {
  140. attackEffect = AttackEffect.FloatState;
  141. }
  142. break;
  143. //击飞
  144. case AttackEffect.BlowUp:
  145. if (resistances.BlowUp == 1)
  146. {
  147. break;
  148. }
  149. if (!character.nowCanFly)
  150. {
  151. if (PriorityOrder(SpecialState.BlownUp,attackMethod.attackInfo.blowUp.ControlOrder))
  152. {
  153. attackEffect = AttackEffect.BlowUp;
  154. }
  155. }
  156. break;
  157. //击落
  158. case AttackEffect.ShotDown:
  159. if (resistances.ShotDown == 1)
  160. {
  161. break;
  162. }
  163. if (character.nowCanFly || !character.canNotShotDown)
  164. {
  165. if (PriorityOrder(SpecialState.ShotDown,attackMethod.attackInfo.shotDown.ControlOrder))
  166. {
  167. attackEffect = AttackEffect.ShotDown;
  168. }
  169. }
  170. break;
  171. //击晕
  172. case AttackEffect.Weak:
  173. if (resistances.Weak == 1)
  174. {
  175. break;
  176. }
  177. if (PriorityOrder(SpecialState.Weak,attackMethod.attackInfo.weak.ControlOrder))
  178. {
  179. attackEffect = AttackEffect.Weak;
  180. }
  181. break;
  182. }
  183. }
  184. if (attackEffect != AttackEffect.Null)
  185. {
  186. switch (attackEffect)
  187. {
  188. /*控制*/
  189. //漂浮
  190. case AttackEffect.FloatState:
  191. AddFloat(attackMethod);
  192. break;
  193. //击飞
  194. case AttackEffect.BlowUp:
  195. AddBlowUp(attackMethod, attackFrom.bodyTrans);
  196. if (attackMethod.attackInfo.blowUp.haveLandingDamage)
  197. {
  198. landingDamageFrom = attackFrom;
  199. }
  200. break;
  201. //击落
  202. case AttackEffect.ShotDown:
  203. AddShotDown(attackMethod, attackFrom.bodyTrans);
  204. if (attackMethod.attackInfo.shotDown.haveLandingDamage)
  205. {
  206. landingDamageFrom = attackFrom;
  207. }
  208. break;
  209. //击晕
  210. case AttackEffect.Weak:
  211. AddWeak(attackMethod);
  212. break;
  213. }
  214. return;
  215. }
  216. }
  217. if (curSpecialStates == SpecialState.Null)
  218. {
  219. hitFeedbackSystem.EnterHitStun(attackFrom);
  220. }
  221. else
  222. {
  223. hitFeedbackSystem.canBeHitStun = false;
  224. }
  225. }
  226. //CharacterState为SpecialStatus时调用此函数
  227. public void SpecialStateEffect(SpecialState specialState)
  228. {
  229. switch (specialState)
  230. {
  231. //漂浮
  232. case SpecialState.FloatState:
  233. switch (floatingState)
  234. {
  235. case 1:
  236. character.transform.localEulerAngles += new Vector3(0, 0, 1) * rotateDir * rotateSpeed * Time.deltaTime;
  237. curHeight = Mathf.SmoothDamp(curHeight, height, ref rise, riseTime);
  238. character.transform.position = new Vector3(origPos.x, curHeight, origPos.z);
  239. if (curHeight >= height - 0.02f)
  240. {
  241. floatingState = 2;
  242. height = character.transform.position.y;
  243. }
  244. break;
  245. case 2:
  246. character.transform.localEulerAngles += new Vector3(0, 0, 1) * rotateDir * rotateSpeed * Time.deltaTime;
  247. break;
  248. case 3:
  249. if (character.transform.position.y >= origPos.y + 0.05f)
  250. {
  251. curHeight -= normalFallSpeed * Time.deltaTime;
  252. character.transform.position = new Vector3(origPos.x, curHeight, origPos.z);
  253. }
  254. else if (foot.TrigGround || curHeight <= origPos.y + 0.05f)
  255. {
  256. floatingState = 0;
  257. character.bodyCollider.layer = character.gameObject.layer;
  258. character.isAdjustHeight = 1;
  259. OutSpecialState();
  260. return;
  261. }
  262. break;
  263. }
  264. PlayerController playerController = GetComponent<PlayerController>();
  265. if (playerController != null)
  266. {
  267. if (playerController.mp > 0)
  268. {
  269. playerController.lostMp += playerController.mpReplySpeed * Time.deltaTime;
  270. playerController.mp -= playerController.mpReplySpeed * Time.deltaTime;
  271. }
  272. if (playerController.lostMp >= playerController.addMp)
  273. {
  274. PoolManager.Instantiate(playerController.soul, character.transform.position, new Quaternion(0, 0, 0, 0), null);
  275. playerController.lostMp = 0;
  276. }
  277. }
  278. attributeTime -= Time.deltaTime;
  279. if (attributeTime <= 0)
  280. {
  281. character.transform.localEulerAngles = Vector3.zero;
  282. floatingState = 3;
  283. rb.useGravity = true;
  284. }
  285. break;
  286. //击飞
  287. case SpecialState.BlownUp:
  288. //击落
  289. case SpecialState.ShotDown:
  290. Vector3 vel = rb.velocity;
  291. switch (hitState)
  292. {
  293. case -1:
  294. break;
  295. case 0:
  296. if (isFly && foot.TrigGround && vel.y < 0.1f)
  297. {
  298. if (!foot.haveGravity)
  299. {
  300. character.transform.position = new Vector3(transform.position.x, character.platformPosY, transform.position.z);
  301. }
  302. int landingDamage;
  303. if (specialState == SpecialState.BlownUp)
  304. {
  305. if (attackMethod.attackInfo.blowUp.haveLandingDamage)
  306. {
  307. landingDamage = (int)(Mathf.Abs(transform.position.x - startFlyPos.x) * attackMethod.attackInfo.blowUp.landingDamageRate)/* + GameManager.instance.blowUpDamage*/;
  308. if (landingDamage > 0)
  309. {
  310. character.BeHit(attackMethod, landingDamageFrom, landingDamage);
  311. }
  312. }
  313. }
  314. else
  315. {
  316. AttackInfo.ShotDown shotDown = attackMethod.attackInfo.shotDown;
  317. if (shotDown.haveLandingDamage)
  318. {
  319. landingDamage = (int)(Mathf.Abs(transform.position.y - startFlyPos.y) * shotDown.landingDamageRate * (1 - resistances.ShotDown)) /*+ GameManager.instance.downDamage*/;
  320. landingDamage = Mathf.Clamp(landingDamage, shotDown.minLandingDamage, landingDamage);
  321. if (landingDamage > 0)
  322. {
  323. character.BeHit(attackMethod, landingDamageFrom, landingDamage);
  324. }
  325. }
  326. }
  327. jumpNum--;
  328. if (jumpNum < 0)
  329. {
  330. vel = vel / 5f;
  331. vel.y = jumpVel;
  332. character.mecanim.transform.localPosition = Vector3.zero;
  333. character.mecanim.transform.localRotation = Quaternion.Euler(0, 0, 0);
  334. character.transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, character.platformRotZ);
  335. character.ani.Play(AnimatorHash.ANIMATOR_weak, 0, 0);
  336. character.bodyCollider.layer = character.gameObject.layer;
  337. hitState = 1;
  338. }
  339. else
  340. {
  341. flyForce *= jumpNumRate;
  342. rb.AddForce(flyForce, ForceMode.Impulse);
  343. }
  344. BounceEffect();
  345. }
  346. else
  347. {
  348. if (vel.x > 0)
  349. {
  350. vel.x -= decelerationRatioX * Time.deltaTime;
  351. }
  352. else
  353. {
  354. vel.x += decelerationRatioX * Time.deltaTime;
  355. }
  356. vel.y -= decelerationRatioY * Time.deltaTime;
  357. character.mecanim.transform.RotateAround(
  358. character.transform.position + rotateCenterHeight * Vector3.up,
  359. Vector3.forward,
  360. flyingRotateSpeed * Time.deltaTime);
  361. isFly = true;
  362. }
  363. break;
  364. case 1:
  365. //眩晕状态
  366. if (attributeTime <= 0)
  367. {
  368. character.isAdjustHeight = 1;
  369. character.nowCanFly = character.canFly;
  370. OutSpecialState();
  371. }
  372. else
  373. {
  374. if (vel.x > 0)
  375. {
  376. vel.x -= decelerationRatioX * Time.deltaTime;
  377. }
  378. else
  379. {
  380. vel.x += decelerationRatioX * Time.deltaTime;
  381. }
  382. if (!foot.TrigGround || vel.y > 0.1f)
  383. {
  384. vel.y -= decelerationRatioY * Time.deltaTime;
  385. }
  386. attributeTime -= Time.deltaTime;
  387. }
  388. break;
  389. }
  390. rb.velocity = vel;
  391. break;
  392. //眩晕
  393. case SpecialState.Weak:
  394. if (attributeTime <= 0)
  395. {
  396. OutSpecialState();
  397. }
  398. else
  399. {
  400. if (!character.isFrozen) rb.velocity = Vector3.zero;
  401. attributeTime -= Time.deltaTime;
  402. }
  403. break;
  404. }
  405. }
  406. void BounceEffect()
  407. {
  408. Transform spine = character.mecanim.transform;
  409. Sequence landSequence = DOTween.Sequence();
  410. landSequence.Append(spine.DOScaleY(scale.y * compressionDegree, compressionSpeed.x));
  411. landSequence.Append(spine.DOScaleY(scale.y, compressionSpeed.y));
  412. }
  413. public void OutSpecialState()
  414. {
  415. character.mecanim.transform.localRotation = Quaternion.Euler(0, 0, 0);
  416. curSpecialStates = SpecialState.Null;
  417. if (character.canFly)
  418. {
  419. rb.useGravity = false;
  420. character.isAdjustHeight = 1;
  421. }
  422. character.ChangeState(CharacterState.Idle);
  423. }
  424. //判断优先级,ture为优先级高于当前控制
  425. public bool PriorityOrder(SpecialState specialState, int controlOrder)
  426. {
  427. //控制层级小于控制抗性层级,该控制效果无效
  428. if (controlOrder < resistances.controlOrder)
  429. {
  430. return false;
  431. }
  432. if (curSpecialStates == SpecialState.Null)
  433. {
  434. curSpecialStates = specialState;
  435. return true;
  436. }
  437. else
  438. {
  439. if (curSpecialStates >= specialState)
  440. {
  441. curSpecialStates = specialState;
  442. return true;
  443. }
  444. }
  445. return false;
  446. }
  447. //受到漂浮
  448. public void AddFloat(AttackController.AttackMethod attackMethod)
  449. {
  450. if (resistances.Float == 1)
  451. {
  452. return;
  453. }
  454. this.attackMethod = attackMethod;
  455. AttackInfo.FloatState floatState = attackMethod.attackInfo.floatState;
  456. rb.isKinematic = false;
  457. rb.useGravity = false;
  458. floatingState = 1;
  459. origPos = character.transform.position;
  460. curHeight = origPos.y;
  461. riseTime = UnityEngine.Random.Range(floatState.upTime.x, floatState.upTime.y);
  462. backSpeed = UnityEngine.Random.Range(floatState.backSpeed.x, floatState.backSpeed.y);
  463. if (gameObject.tag == "Enemy" || gameObject.tag == "Player")
  464. {
  465. backSpeed = -backSpeed;
  466. }
  467. rotateSpeed = UnityEngine.Random.Range(floatState.rotateSpeed.x, floatState.rotateSpeed.y);
  468. rotateDir = (1.5f - UnityEngine.Random.Range(1, 3)) * 2;
  469. height = UnityEngine.Random.Range(floatState.height.x, floatState.height.y);
  470. attributeTime = floatState.time * (1 - resistances.Float);
  471. character.ChangeState(CharacterState.SpecialStatus_Float);
  472. character.ChangeStateText(CharacterState.SpecialStatus_Float);
  473. }
  474. //受到击飞
  475. public void AddBlowUp(AttackController.AttackMethod attackMethod, Transform attackFrom)
  476. {
  477. if (resistances.BlowUp == 1)
  478. {
  479. return;
  480. }
  481. this.attackMethod = attackMethod;
  482. AttackInfo.BlowUp blowUp = attackMethod.attackInfo.blowUp;
  483. attributeTime = blowUp.time * (1 - resistances.BlowUp);
  484. Vector3 vec3 = new Vector3(
  485. blowUp.dir.x + UnityEngine.Random.Range(-blowUp.dirRandom.x / 2f, blowUp.dirRandom.x / 2f),
  486. blowUp.dir.y + UnityEngine.Random.Range(-blowUp.dirRandom.y / 2f, blowUp.dirRandom.y / 2f),
  487. 0).normalized;
  488. int attackDir = 0;
  489. switch (blowUp.directionType)
  490. {
  491. case AttackInfo.BlowUp.DirectionType.Common:
  492. attackDir = attackFrom.localScale.x < 0 ? -1 : 1;
  493. break;
  494. case AttackInfo.BlowUp.DirectionType.Spread:
  495. attackDir = attackFrom.position.x < transform.position.x ? -1 : 1;
  496. break;
  497. case AttackInfo.BlowUp.DirectionType.Explosion:
  498. attackDir = 1;
  499. vec3 = transform.position - attackFrom.transform.position;
  500. vec3.y += 0.5f;
  501. break;
  502. }
  503. if (attackDir < 0)
  504. {
  505. vec3.x = -vec3.x;
  506. }
  507. hitState = -1;
  508. character.ChangeState(CharacterState.SpecialStatus_BlowUp);
  509. character.ChangeStateText(CharacterState.SpecialStatus_BlowUp);
  510. rb.useGravity = true;
  511. rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
  512. rb.velocity = Vector3.zero;
  513. flyForce = vec3 * blowUp.force * (1 - resistances.BlowUp);
  514. rb.AddForce(flyForce, ForceMode.Impulse);
  515. rb.transform.rotation = Quaternion.Euler(0, 0, 0);
  516. character.mecanim.transform.RotateAround(
  517. character.transform.position + rotateCenterHeight * Vector3.up,
  518. Vector3.forward,
  519. startFlyAngle * attackDir);
  520. flyingRotateSpeed = UnityEngine.Random.Range(flyingRotateSpeedRange.x, flyingRotateSpeedRange.y) * attackDir;
  521. startFlyPos = transform.position;
  522. hitState = 0;
  523. isFly = false;
  524. jumpNum = blowUp.jumpNum;
  525. character.ani.Play("hitted", 0, 0);
  526. }
  527. //受到击落
  528. public void AddShotDown(AttackController.AttackMethod attackMethod, Transform attackFrom)
  529. {
  530. if (resistances.ShotDown == 1)
  531. {
  532. return;
  533. }
  534. this.attackMethod = attackMethod;
  535. AttackInfo.ShotDown shotDown = attackMethod.attackInfo.shotDown;
  536. attributeTime = shotDown.time;
  537. Vector3 vec3 = new Vector3(
  538. shotDown.dir.x + UnityEngine.Random.Range(-shotDown.dirRandom.x / 2f, shotDown.dirRandom.x / 2f),
  539. shotDown.dir.y + UnityEngine.Random.Range(-shotDown.dirRandom.y / 2f, shotDown.dirRandom.y / 2f),
  540. 0).normalized;
  541. int attackDir = 0;
  542. switch (shotDown.directionType)
  543. {
  544. case AttackInfo.ShotDown.DirectionType.Common:
  545. attackDir = attackFrom.localScale.x < 0 ? -1 : 1;
  546. break;
  547. case AttackInfo.ShotDown.DirectionType.Spread:
  548. attackDir = attackFrom.position.x < transform.position.x ? -1 : 1;
  549. break;
  550. }
  551. if (attackDir < 0)
  552. {
  553. vec3.x = -vec3.x;
  554. }
  555. rb.useGravity = true;
  556. rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
  557. rb.velocity = Vector3.zero;
  558. rb.AddForce(vec3 * shotDown.force, ForceMode.Impulse);
  559. rb.transform.rotation = Quaternion.Euler(0, 0, 0);
  560. character.ani.Play("hitted", 0, 0);
  561. character.nowCanFly = false;
  562. startFlyPos = transform.position;
  563. hitState = 0;
  564. isFly = false;
  565. character.ChangeState(CharacterState.SpecialStatus_ShotDown);
  566. character.ChangeStateText(CharacterState.SpecialStatus_ShotDown);
  567. }
  568. //受到击晕
  569. public void AddWeak(AttackController.AttackMethod attackMethod)
  570. {
  571. if (resistances.Weak == 1)
  572. {
  573. return;
  574. }
  575. this.attackMethod = attackMethod;
  576. AttackInfo.Weak weak = attackMethod.attackInfo.weak;
  577. attributeTime = weak.time * (1 - resistances.Weak);
  578. character.ani.Play("weak", 0, 0);
  579. character.ChangeState(CharacterState.SpecialStatus_Weak);
  580. character.ChangeStateText(CharacterState.SpecialStatus_Weak);
  581. }
  582. public void AddWeak(float _attributeTime)
  583. {
  584. if (resistances.Weak == 1 || character.isDie)
  585. {
  586. return;
  587. }
  588. attributeTime = _attributeTime;
  589. character.ani.Play("weak", 0, 0);
  590. character.ChangeState(CharacterState.SpecialStatus_Weak);
  591. character.ChangeStateText(CharacterState.SpecialStatus_Weak);
  592. }
  593. //受到穿甲
  594. public int AddArmorPiercing(AttackController.AttackMethod attackMethod)
  595. {
  596. this.attackMethod = attackMethod;
  597. AttackInfo.ArmorPiercing armor = attackMethod.attackInfo.armorPiercing;
  598. //计算护甲减免
  599. int am = resistances.armor;
  600. if (am > 0)
  601. {
  602. am = am - armor.rate;
  603. if (am < 0)
  604. {
  605. am = 0;
  606. }
  607. }
  608. return am;
  609. }
  610. //受到易伤
  611. public void AddVulnerable(float _vulnerableRate,float _vulnerableTime)
  612. {
  613. if(vulnerableRate < _vulnerableRate) vulnerableRate += _vulnerableRate;
  614. vulnerableTime = _vulnerableTime;
  615. haveVulnerable = true;
  616. Debug.Log("添加易伤,vulnerableTime:" + vulnerableTime + ",vulnerableRate:" + vulnerableRate);
  617. }
  618. //受到累伤
  619. public void AddStackingWouds(AttackController.AttackMethod attackMethod)
  620. {
  621. this.attackMethod = attackMethod;
  622. AttackInfo.StackingWounds stackingWounds = attackMethod.attackInfo.stackingWounds;
  623. if(stackingWoudsTime > 0)
  624. {
  625. stackingWords += attackMethod.attackInfo.stackingWounds.damage;
  626. }
  627. stackingWoudsTime = stackingWounds.time;
  628. }
  629. }