BasePlayerStates.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. },
  5. onLoad() {
  6. this.hp = 110;
  7. this.maxhp = 110; //血量
  8. this.endurance = 100;
  9. this.maxendurance = 100; //蓝量
  10. this.damage = 11; //攻击力
  11. this.defense = 3; //防御
  12. this.combo_rate = 30; //连击率
  13. this.crit_rate = 30; //暴击率
  14. this.dodge_endurance = 10; //闪避回蓝
  15. this.defense_hp = 11; //格挡回血
  16. this.recover_hp = 1; //被动回血1/s
  17. this.recover_endurance = 1; //被动回蓝1/s
  18. this.block_minus_endurance = 10; //格挡减蓝量
  19. },
  20. start() {
  21. },
  22. //#region 血量变化 是否暴击bool_crit 是否连击bool_combo
  23. //减血 不暴击 不连击 hpnum=otherdamage-defense 连击hpnum*2
  24. minusblood(oneself_hp) {
  25. let _oligemia = this.damage - this.defense;
  26. oneself_hp -= _oligemia;
  27. if (oneself_hp <= 0) {
  28. oneself_hp = 0;
  29. }
  30. return oneself_hp;
  31. },
  32. minusblood_critical(oneself_hp) {
  33. let _oligemia = this.damage * 2 - this.defense;
  34. oneself_hp -= _oligemia;
  35. if (oneself_hp <= 0) {
  36. oneself_hp =
  37. 0;
  38. }
  39. return oneself_hp;
  40. },
  41. //加血
  42. //格挡加血 被动回血recover_hp, defense_hp ---恢复血量类型 0被动回血 1格挡回血heal_bool
  43. addblood(oneself_maxhp, oneself_hp, heal_type) {
  44. //if (heal_bool) {
  45. if (oneself_hp >= oneself_maxhp) {
  46. oneself_hp == oneself_maxhp;
  47. return oneself_hp;;
  48. }
  49. if (heal_type == 0) { //被动回血 1/s
  50. // this.schedule(function() {
  51. oneself_hp += this.recover_hp;
  52. return oneself_hp;
  53. //}, 1);
  54. }
  55. if (heal_type == 1) { //格挡回血 11/次
  56. oneself_hp += this.defense_hp;
  57. return oneself_hp;
  58. }
  59. // }
  60. },
  61. //#endregion
  62. // update (dt) {},
  63. //#region 蓝量变化
  64. //减蓝 endurance-=this.block_minus_endurance
  65. minusendurance(oneself_endurance) {
  66. oneself_endurance -= this.block_minus_endurance;
  67. if (oneself_endurance <= 0) {
  68. oneself_endurance = 0;
  69. return oneself_endurance;
  70. }
  71. return oneself_endurance;
  72. },
  73. //加蓝
  74. //闪避加蓝 被动回蓝recover_endurance, dodge_endurance -heal_bool--恢复蓝量类型 0被动回蓝 1闪避回蓝
  75. addendurance(oneself_maxendurance, oneself_endurance, heal_type) {
  76. //if (heal_bool) {
  77. if (oneself_endurance >= oneself_maxendurance) {
  78. oneself_endurance == oneself_maxendurance;
  79. return oneself_endurance;
  80. }
  81. if (heal_type == 0) { //被动回蓝 1/s
  82. oneself_endurance += this.recover_endurance;
  83. return oneself_endurance;
  84. }
  85. if (heal_type == 1) { //闪避回蓝 11/次
  86. oneself_endurance += this.dodge_endurance;
  87. return oneself_endurance;
  88. }
  89. //}
  90. },
  91. //#endregion
  92. // //结果
  93. // Result_Show(playerHp, AiHp) {
  94. // if (playerHp <= 0) {
  95. // return false;
  96. // }
  97. // if (AiHp <= 0) {
  98. // return true;
  99. // }
  100. // },
  101. });