BasePlayerStates.js 3.2 KB

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