BasePlayerStates.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 = 5; //连击率
  13. this.crit_rate = 5; //暴击率
  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. console.log("血量减少");
  26. let _oligemia = this.damage - this.defense;
  27. oneself_hp -= _oligemia;
  28. if (oneself_hp <= 0) {
  29. oneself_hp = 0;
  30. }
  31. },
  32. //加血
  33. //格挡加血 被动回血recover_hp, defense_hp ---恢复血量类型 0被动回血 1格挡回血
  34. addblood(oneself_maxhp, oneself_hp, heal_bool, heal_type) {
  35. console.log("血量增加");
  36. if (heal_bool) {
  37. if (oneself_hp >= oneself_maxhp) {
  38. oneself_hp == oneself_maxhp;
  39. return;
  40. }
  41. if (heal_type == 0) { //被动回血 1/s
  42. this.schedule(function() {
  43. oneself_hp += this.recover_hp;
  44. }, 1);
  45. }
  46. if (heal_type == 1) { //格挡回血 11/次
  47. oneself_hp += this.defense_hp;
  48. }
  49. }
  50. },
  51. //#endregion
  52. // update (dt) {},
  53. //#region 蓝量变化
  54. //减蓝 endurance-=this.block_minus_endurance
  55. minusendurance(oneself_endurance) {
  56. console.log("蓝量减少");
  57. oneself_endurance -= this.block_minus_endurance;
  58. if (oneself_endurance <= 0) {
  59. oneself_endurance = 0;
  60. }
  61. },
  62. //加蓝
  63. //闪避加蓝 被动回蓝recover_endurance, dodge_endurance ---恢复蓝量类型 0被动回蓝 1闪避回蓝
  64. addendurance(oneself_maxendurance, oneself_endurance, heal_bool, heal_type) {
  65. console.log("蓝量增加");
  66. if (heal_bool) {
  67. if (oneself_endurance >= oneself_maxendurance) {
  68. oneself_endurance == oneself_maxendurance;
  69. return;
  70. }
  71. if (heal_type == 0) { //被动回蓝 1/s
  72. this.schedule(function() {
  73. oneself_endurance += this.recover_endurance;
  74. }, 1);
  75. }
  76. if (heal_type == 1) { //闪避回蓝 11/次
  77. oneself_endurance += this.dodge_endurance;
  78. }
  79. }
  80. }
  81. //#endregion
  82. });