|
|
@@ -4,6 +4,9 @@ cc.Class({
|
|
|
properties: {
|
|
|
playerController: cc.Node,
|
|
|
Charactor: cc.Node,
|
|
|
+
|
|
|
+ progressBar_hp: cc.Node,
|
|
|
+ progressBar_endur: cc.Node,
|
|
|
},
|
|
|
onLoad() {
|
|
|
this._super();
|
|
|
@@ -22,27 +25,55 @@ cc.Class({
|
|
|
this._block_minus_endurance = this.block_minus_endurance; //格挡减蓝量
|
|
|
this.init();
|
|
|
//this.oligemia();//继承BasePlayerStates函数
|
|
|
- this.Charactor.on("attack", function() {
|
|
|
- console.log("检测到攻击1");
|
|
|
+ this.Charactor.on("attack", () => {
|
|
|
+ //console.log("检测到攻击1");
|
|
|
});
|
|
|
- this.Charactor.on("attack_critical_strike", function() {
|
|
|
- console.log("检测到暴击1");
|
|
|
+ this.Charactor.on("attack_critical_strike", () => {
|
|
|
+ //console.log("检测到暴击1");
|
|
|
|
|
|
});
|
|
|
- this.Charactor.on("attack_double-hit", function() {
|
|
|
- console.log("检测到连击1");
|
|
|
+ this.Charactor.on("attack_double-hit", () => {
|
|
|
+ //console.log("检测到连击1");
|
|
|
+ });
|
|
|
+ this.Charactor.on("dodge", () => {
|
|
|
+ //console.log("检测到躲闪");
|
|
|
+ this.addendurance(this._maxendurance, this._endurance, 1); //闪避回蓝
|
|
|
+ this.progressBar_endur.getComponent(cc.Sprite).fillRange = this._endurance / this._maxendurance;
|
|
|
});
|
|
|
- this.Charactor.on("dodge", function() {
|
|
|
- console.log("检测到躲闪");
|
|
|
+ this.Charactor.on("block", () => {
|
|
|
+ //console.log("检测到防御");
|
|
|
+ this._endurance = this.minusendurance(this._endurance); //减蓝
|
|
|
+ this._hp = this.addblood(this._maxhp, this._hp, 1); //回血
|
|
|
+ this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
|
|
|
+ this.progressBar_endur.getComponent(cc.Sprite).fillRange = this._endurance / this._maxendurance;
|
|
|
});
|
|
|
- this.Charactor.on("block", function() {
|
|
|
- console.log("检测到防御");
|
|
|
- this.block();
|
|
|
+ this.Charactor.on("hurt_ord", () => {
|
|
|
+ console.log("检测到受普攻");
|
|
|
+ this._hp = this.minusblood(this._hp);
|
|
|
+ this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
|
|
|
});
|
|
|
- this.Charactor.on("hurt", function() {
|
|
|
- console.log("检测到受伤");
|
|
|
+ this.Charactor.on("hurt_critical", () => {
|
|
|
+ console.log("检测到受暴击");
|
|
|
+ this._hp = this.minusblood_critical(this._hp);
|
|
|
+ //console.log("暴击后的血量:", this._hp);
|
|
|
+ this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
|
|
|
+ });
|
|
|
+ this.Charactor.on("hurt_double", () => {
|
|
|
+ console.log("检测到受连攻");
|
|
|
+ this._hp = this.minusblood(this._hp);
|
|
|
+
|
|
|
+ this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
|
|
|
+ this._hp = this.minusblood(this._hp);
|
|
|
+ this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
|
|
|
|
|
|
});
|
|
|
+ //被动回血回蓝
|
|
|
+ this.schedule(() => {
|
|
|
+
|
|
|
+ this._hp = this.addblood(this._maxhp, this._hp, 0);
|
|
|
+ this._endurance = this.addendurance(this._maxendurance, this._endurance, 0);
|
|
|
+ console.log("玩家被动", this._hp, this._endurance);
|
|
|
+ }, 1);
|
|
|
},
|
|
|
start() {
|
|
|
|
|
|
@@ -52,11 +83,5 @@ cc.Class({
|
|
|
this.controScp = this.playerController.getComponent('PlayerController');
|
|
|
this.charactortroScp = this.Charactor.getComponent('Charactor');
|
|
|
},
|
|
|
- block() { //防御
|
|
|
- this.minusendurance(this._endurance); //减蓝
|
|
|
- },
|
|
|
- hurt() { //受伤
|
|
|
- this.minusblood(this._hp); //减血
|
|
|
- },
|
|
|
update(dt) {},
|
|
|
});
|