BasePlayerStates.js 3.4 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 = 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. return oneself_hp;
  32. },
  33. minusblood_critical(oneself_hp) {
  34. console.log("暴击血量减少");
  35. let _oligemia = this.damage * 2 - this.defense;
  36. oneself_hp -= _oligemia;
  37. if (oneself_hp <= 0) {
  38. oneself_hp =
  39. 0;
  40. }
  41. return oneself_hp;
  42. },
  43. //加血
  44. //格挡加血 被动回血recover_hp, defense_hp ---恢复血量类型 0被动回血 1格挡回血heal_bool
  45. addblood(oneself_maxhp, oneself_hp, heal_type) {
  46. console.log("血量增加");
  47. //if (heal_bool) {
  48. if (oneself_hp >= oneself_maxhp) {
  49. oneself_hp == oneself_maxhp;
  50. return oneself_hp;;
  51. }
  52. if (heal_type == 0) { //被动回血 1/s
  53. // this.schedule(function() {
  54. oneself_hp += this.recover_hp;
  55. return oneself_hp;
  56. //}, 1);
  57. }
  58. if (heal_type == 1) { //格挡回血 11/次
  59. oneself_hp += this.defense_hp;
  60. return oneself_hp;
  61. }
  62. // }
  63. },
  64. //#endregion
  65. // update (dt) {},
  66. //#region 蓝量变化
  67. //减蓝 endurance-=this.block_minus_endurance
  68. minusendurance(oneself_endurance) {
  69. console.log("蓝量减少");
  70. oneself_endurance -= this.block_minus_endurance;
  71. if (oneself_endurance <= 0) {
  72. oneself_endurance = 0;
  73. return oneself_endurance;
  74. }
  75. return oneself_endurance;
  76. },
  77. //加蓝
  78. //闪避加蓝 被动回蓝recover_endurance, dodge_endurance -heal_bool--恢复蓝量类型 0被动回蓝 1闪避回蓝
  79. addendurance(oneself_maxendurance, oneself_endurance, heal_type) {
  80. console.log("蓝量增加");
  81. //if (heal_bool) {
  82. if (oneself_endurance >= oneself_maxendurance) {
  83. oneself_endurance == oneself_maxendurance;
  84. return oneself_endurance;
  85. }
  86. if (heal_type == 0) { //被动回蓝 1/s
  87. oneself_endurance += this.recover_endurance;
  88. return oneself_endurance;
  89. }
  90. if (heal_type == 1) { //闪避回蓝 11/次
  91. oneself_endurance += this.dodge_endurance;
  92. return oneself_endurance;
  93. }
  94. //}
  95. },
  96. //#endregion
  97. //结果
  98. Result_Show(playerHp, AiHp) {
  99. if (playerHp <= 0) {
  100. console.log("ai胜利");
  101. return false;
  102. }
  103. if (AiHp <= 0) {
  104. console.log("玩家胜利");
  105. return true;
  106. }
  107. }
  108. });