cc.Class({ extends: cc.Component, properties: { }, onLoad() { this.hp = 110; this.maxhp = 110; //血量 this.endurance = 100; this.maxendurance = 100; //蓝量 this.damage = 11; //攻击力 this.defense = 3; //防御 this.combo_rate = 5; //连击率 this.crit_rate = 5; //暴击率 this.dodge_endurance = 10; //闪避回蓝 this.defense_hp = 11; //格挡回血 this.recover_hp = 1; //被动回血1/s this.recover_endurance = 1; //被动回蓝1/s this.block_minus_endurance = 10; //格挡减蓝量 }, start() { }, //#region 血量变化 是否暴击bool_crit 是否连击bool_combo //减血 不暴击 不连击 hpnum=otherdamage-defense 连击hpnum*2 minusblood(oneself_hp) { console.log("血量减少"); let _oligemia = this.damage - this.defense; oneself_hp -= _oligemia; if (oneself_hp <= 0) { oneself_hp = 0; } return oneself_hp; }, minusblood_critical(oneself_hp) { console.log("暴击血量减少"); let _oligemia = this.damage * 2 - this.defense; oneself_hp -= _oligemia; if (oneself_hp <= 0) { oneself_hp = 0; } return oneself_hp; }, //加血 //格挡加血 被动回血recover_hp, defense_hp ---恢复血量类型 0被动回血 1格挡回血heal_bool addblood(oneself_maxhp, oneself_hp, heal_type) { console.log("血量增加"); //if (heal_bool) { if (oneself_hp >= oneself_maxhp) { oneself_hp == oneself_maxhp; return oneself_hp;; } if (heal_type == 0) { //被动回血 1/s // this.schedule(function() { oneself_hp += this.recover_hp; return oneself_hp; //}, 1); } if (heal_type == 1) { //格挡回血 11/次 oneself_hp += this.defense_hp; return oneself_hp; } // } }, //#endregion // update (dt) {}, //#region 蓝量变化 //减蓝 endurance-=this.block_minus_endurance minusendurance(oneself_endurance) { console.log("蓝量减少"); oneself_endurance -= this.block_minus_endurance; if (oneself_endurance <= 0) { oneself_endurance = 0; return oneself_endurance; } return oneself_endurance; }, //加蓝 //闪避加蓝 被动回蓝recover_endurance, dodge_endurance -heal_bool--恢复蓝量类型 0被动回蓝 1闪避回蓝 addendurance(oneself_maxendurance, oneself_endurance, heal_type) { console.log("蓝量增加"); //if (heal_bool) { if (oneself_endurance >= oneself_maxendurance) { oneself_endurance == oneself_maxendurance; return oneself_endurance; } if (heal_type == 0) { //被动回蓝 1/s oneself_endurance += this.recover_endurance; return oneself_endurance; } if (heal_type == 1) { //闪避回蓝 11/次 oneself_endurance += this.dodge_endurance; return oneself_endurance; } //} }, //#endregion //结果 Result_Show(playerHp, AiHp) { if (playerHp <= 0) { console.log("ai胜利"); return false; } if (AiHp <= 0) { console.log("玩家胜利"); return true; } } });