|
|
@@ -11,23 +11,18 @@ cc.Class({
|
|
|
//PlayerState: cc.Node,
|
|
|
AiPlayerState: cc.Node,
|
|
|
|
|
|
- PanelResult: cc.Node,
|
|
|
+ //PanelResult: cc.Node,
|
|
|
|
|
|
- ResultArr: {
|
|
|
- default: [],
|
|
|
- type: cc.Prefab,
|
|
|
- },
|
|
|
- interface_game: cc.Node,
|
|
|
+ // ResultArr: {
|
|
|
+ // default: [],
|
|
|
+ // type: cc.Prefab,
|
|
|
+ // },
|
|
|
+ //interface_game: cc.Node,
|
|
|
},
|
|
|
onLoad() {
|
|
|
- // cc.loader.loadResDir("prefab/Result", cc.Prefab, (err, ResultArr) => {
|
|
|
- // // ...
|
|
|
- // console.log("belt预设:", );
|
|
|
- // for (let i = 0; i < ResultArr.length; i++) {
|
|
|
- // this.ResultArr[i] = ResultArr[i];
|
|
|
- // }
|
|
|
+ this.game = cc.find("Canvas/Game");
|
|
|
|
|
|
- // });
|
|
|
+ this.PanelResult = cc.find("Canvas/PanelResult");
|
|
|
this._super();
|
|
|
this._hp = this.hp;
|
|
|
this._maxhp = this.maxhp; //血量
|
|
|
@@ -43,16 +38,21 @@ cc.Class({
|
|
|
this._recover_endurance = this.recover_endurance; //被动回蓝1/s
|
|
|
this._block_minus_endurance = this.block_minus_endurance; //格挡减蓝量
|
|
|
this.init();
|
|
|
+ //回复状态
|
|
|
//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("检测到躲闪");
|
|
|
@@ -61,24 +61,25 @@ cc.Class({
|
|
|
});
|
|
|
this.Charactor.on("block", () => {
|
|
|
//console.log("检测到防御");
|
|
|
+ cc.audioEngine.playEffect(this.UiController.audioArr[1]);
|
|
|
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("检测到受普攻");
|
|
|
+ cc.audioEngine.playEffect(this.UiController.audioArr[4]);
|
|
|
this._hp = this.minusblood(this._hp);
|
|
|
this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
|
|
|
});
|
|
|
this.Charactor.on("hurt_critical", () => {
|
|
|
- console.log("检测到受暴击");
|
|
|
+ cc.audioEngine.playEffect(this.UiController.audioArr[4]);
|
|
|
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("检测到受连攻");
|
|
|
+ cc.audioEngine.playEffect(this.UiController.audioArr[4]);
|
|
|
this._hp = this.minusblood(this._hp);
|
|
|
|
|
|
this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
|
|
|
@@ -91,28 +92,33 @@ cc.Class({
|
|
|
|
|
|
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() {
|
|
|
this.init();
|
|
|
},
|
|
|
init() {
|
|
|
+ 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');
|
|
|
+
|
|
|
},
|
|
|
update(dt) {
|
|
|
- let result = this.Result_Show(this._hp, this.aiplayerStateScp._hp);
|
|
|
- if (result) {
|
|
|
- this.PanelResult.addChild(cc.instantiate(this.ResultArr[1]));
|
|
|
- this.interface_game.active = false;
|
|
|
- this.scheduleOnce(function() {
|
|
|
|
|
|
- }, 2);
|
|
|
+ if (this._hp <= 0 || this._hp <= this.aiplayerStateScp._hp && this.gamestate._game_time == 0) {
|
|
|
+ cc.audioEngine.playEffect(this.UiController.audioArr[2]);
|
|
|
+ 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;
|
|
|
}
|
|
|
},
|
|
|
});
|