AiPlayerStates.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. cc.Class({
  2. extends: require("BasePlayerStates"),
  3. properties: {
  4. playerController: cc.Node,
  5. Charactor: cc.Node,
  6. progressBar_hp: cc.Node,
  7. progressBar_endur: cc.Node,
  8. },
  9. onLoad() {
  10. this._super();
  11. this._hp = this.hp;
  12. this._maxhp = this.maxhp; //血量
  13. this._endurance = this.endurance;
  14. this._maxendurance = this.maxendurance; //蓝量
  15. this._damage = this.damage; //攻击力
  16. this._defense = this.defense; //防御
  17. this._combo_rate = this.combo_rate; //连击率
  18. this._crit_rate = this.crit_rate; //暴击率
  19. this._dodge_endurance = this.dodge_endurance; //闪避回蓝
  20. this._defense_hp = this.defense_hp; //格挡回血
  21. this._recover_hp = this.recover_hp; //被动回血1/s
  22. this._recover_endurance = this.recover_endurance; //被动回蓝1/s
  23. this._block_minus_endurance = this.block_minus_endurance; //格挡减蓝量
  24. //被动回血回蓝
  25. this.schedule(() => {
  26. this._hp = this.addblood(this._maxhp, this._hp, 0);
  27. this._endurance = this.addendurance(this._maxendurance, this._endurance, 0);
  28. console.log("Ai被动", this._hp, this._endurance);
  29. }, 1);
  30. },
  31. start() {
  32. this.Charactor.on("attack", () => {
  33. //console.log("检测到攻击2");
  34. });
  35. this.Charactor.on("attack_critical_strike", () => {
  36. //console.log("检测到暴击2");
  37. });
  38. this.Charactor.on("attack_double-hit", () => {
  39. //console.log("检测到连击2");
  40. });
  41. this.Charactor.on("dodge", () => {
  42. //console.log("检测到躲闪2");
  43. this.addendurance(this._maxendurance, this._endurance, 1); //闪避回蓝
  44. this.progressBar_endur.getComponent(cc.Sprite).fillRange = this._endurance / this._maxendurance;
  45. });
  46. this.Charactor.on("block", () => {
  47. // console.log("检测到防御2");
  48. this._endurance = this.minusendurance(this._endurance); //减蓝
  49. this._hp = this.addblood(this._maxhp, this._hp, 1); //回血
  50. this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
  51. this.progressBar_endur.getComponent(cc.Sprite).fillRange = this._endurance / this._maxendurance;
  52. });
  53. this.Charactor.on("hurt_ord", () => {
  54. // console.log("检测到受普攻");
  55. this._hp = this.minusblood(this._hp);
  56. this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
  57. });
  58. this.Charactor.on("hurt_critical", () => {
  59. //console.log("检测到受暴击");
  60. this._hp = this.minusblood_critical(this._hp);
  61. //console.log("暴击后的血量:", this._hp);
  62. this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
  63. });
  64. this.Charactor.on("hurt_double", () => {
  65. //console.log("检测到受连攻");
  66. this._hp = this.minusblood(this._hp);
  67. this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
  68. this._hp = this.minusblood(this._hp);
  69. this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
  70. });
  71. },
  72. // update (dt) {},
  73. });