cc.Class({
    extends: require("BasePlayerStates"),

    properties: {
        playerController: cc.Node,
        Charactor: cc.Node,

        progressBar_hp: cc.Node,
        progressBar_endur: cc.Node,
    },
    onLoad() {
        this._super();
        this._hp = this.hp;
        this._maxhp = this.maxhp; //血量
        this._endurance = this.endurance;
        this._maxendurance = this.maxendurance; //蓝量
        this._damage = this.damage; //攻击力
        this._defense = this.defense; //防御
        this._combo_rate = this.combo_rate; //连击率
        this._crit_rate = this.crit_rate; //暴击率
        this._dodge_endurance = this.dodge_endurance; //闪避回蓝
        this._defense_hp = this.defense_hp; //格挡回血
        this._recover_hp = this.recover_hp; //被动回血1/s
        this._recover_endurance = this.recover_endurance; //被动回蓝1/s
        this._block_minus_endurance = this.block_minus_endurance; //格挡减蓝量

        //被动回血回蓝
        this.schedule(() => {
            this._hp = this.addblood(this._maxhp, this._hp, 0);
            this._endurance = this.addendurance(this._maxendurance, this._endurance, 0);
            console.log("Ai被动", this._hp, this._endurance);
        }, 1);

    },

    start() {
        this.Charactor.on("attack", () => {
            //console.log("检测到攻击2");
        });
        this.Charactor.on("attack_critical_strike", () => {
            //console.log("检测到暴击2");

        });
        this.Charactor.on("attack_double-hit", () => {
            //console.log("检测到连击2");

        });
        this.Charactor.on("dodge", () => {
            //console.log("检测到躲闪2");
            this.addendurance(this._maxendurance, this._endurance, 1); //闪避回蓝
            this.progressBar_endur.getComponent(cc.Sprite).fillRange = this._endurance / this._maxendurance;
        });
        this.Charactor.on("block", () => {
            // console.log("检测到防御2");
            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("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_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;
        });
    },

    // update (dt) {},
});