cc.Class({ extends: cc.Component, properties: { playerController: cc.Node, Charactor: cc.Node, progressBar_hp: cc.Node, progressBar_endur: cc.Node, //PlayerState: cc.Node, AiPlayerState: cc.Node, //PanelResult: cc.Node, // ResultArr: { // default: [], // type: cc.Prefab, // }, //interface_game: cc.Node, }, onLoad() { this.init(); this.game = cc.find("Canvas/Game"); this.PanelResult = cc.find("Canvas/PanelResult"); this._hp = this.Interface_Info.hp; this._maxhp = this.Interface_Info.maxhp; //血量 this._endurance = this.Interface_Info.endurance; this._maxendurance = this.Interface_Info.maxendurance; //蓝量 this._damage = this.Interface_Info.damage; //攻击力 this._defense = this.Interface_Info.defense; //防御 this._combo_rate = this.Interface_Info.combo_rate; //连击率 this._crit_rate = this.Interface_Info.crit_rate; //暴击率 this._dodge_endurance = this.Interface_Info.dodge_endurance; //闪避回蓝 this._defense_hp = this.Interface_Info.defense_hp; //格挡回血 this._recover_hp = this.Interface_Info.recover_hp; //被动回血1/s this._recover_endurance = this.Interface_Info.recover_endurance; //被动回蓝1/s this._block_minus_endurance = this.Interface_Info.block_minus_endurance; //格挡减蓝量 //回复状态 //this.oligemia();//继承BasePlayerStates函数 this.Charactor.on("attack", () => { //console.log("检测到攻击1"); cc.audioEngine.playEffect(this.UiController.audioArr[3]); }); this.Charactor.on("attack_critical_strike", () => { //console.log("检测到暴击1"); cc.audioEngine.playEffect(this.UiController.audioArr[3]); }); this.Charactor.on("attack_double-hit", () => { //console.log("检测到连击1"); cc.audioEngine.playEffect(this.UiController.audioArr[3]); cc.audioEngine.playEffect(this.UiController.audioArr[3]); }); 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("block", () => { //console.log("检测到防御"); cc.audioEngine.playEffect(this.UiController.audioArr[1]); this._endurance = this.Interface_Info.minusendurance(this._endurance); //减蓝 this._hp = this.Interface_Info.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", () => { cc.audioEngine.playEffect(this.UiController.audioArr[4]); this._hp = this.Interface_Info.minusblood(this._hp); this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp; }); this.Charactor.on("hurt_critical", () => { cc.audioEngine.playEffect(this.UiController.audioArr[4]); this._hp = this.Interface_Info.minusblood_critical(this._hp); //console.log("暴击后的血量:", this._hp); this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp; }); this.Charactor.on("hurt_double", () => { cc.audioEngine.playEffect(this.UiController.audioArr[4]); this._hp = this.Interface_Info.minusblood(this._hp); this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp; this._hp = this.Interface_Info.minusblood(this._hp); this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp; }); //被动回血回蓝 this.schedule(() => { this._hp = this.Interface_Info.addblood(this._maxhp, this._hp, 0); this._endurance = this.Interface_Info.addendurance(this._maxendurance, this._endurance, 0); }, 1); }, start() { console.log("角色血量", this._hp); console.log("角色伤害", this._damage); console.log("角色防御", this._defense); console.log("角色连击", this._combo_rate); }, init() { this._GameState = cc.find("GameStates").getComponent("GameStates"); this.gamestate = cc.find("Canvas/Game/Interface_Game").getComponent('Interface_game'); //角色脚本 this.controScp = this.playerController.getComponent('PlayerController'); this.charactortroScp = this.Charactor.getComponent('Charactor'); //this.playerStateScp = this.PlayerState.getComponent('PlayerStates'); this.aiplayerStateScp = this.AiPlayerState.getComponent('AiPlayerStates'); this.UiController = cc.find("Canvas/UiController").getComponent('UiController'); this.Interface_Info = cc.find("Canvas/Interface_Info").getComponent("Interface_Info"); //角色数据界面脚本 }, update(dt) { if (this._hp <= 0 || this._hp <= this.aiplayerStateScp._hp && this.gamestate._game_time == 0) { cc.audioEngine.playEffect(this.UiController.audioArr[2]); // console.log("失败", this._GameState.gameresult); this.game.removeAllChildren(); var self = this; cc.loader.loadRes("prefab/Result/interface_Loser", cc.Prefab, (err, ResultArr) => { self.PanelResult.addChild(cc.instantiate(ResultArr)) }); // this.interface_game.active = false; } if (this._hp <= this._damage) { this.UiController.Ui_Shake(4); //气血不足 } if (this._endurance <= this._block_minus_endurance) { this.UiController.Ui_Shake(5); //能量不足不足 } }, });