| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- cc.Class({
- extends: require("BasePlayerStates"),
- properties: {
- playerController: cc.Node,
- Charactor: cc.Node,
- PlayerState: cc.Node,
- progressBar_hp: cc.Node,
- progressBar_endur: cc.Node,
- },
- onLoad() {
- this.game = cc.find("Canvas/Game");
- this.PanelResult = cc.find("Canvas/PanelResult");
- 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);
- }, 1);
- },
- start() {
- this.Charactor.on("attack1", () => {
- //console.log("检测到攻击2 右");
- cc.audioEngine.playEffect(this.UiController.audioArr[3]);
- });
- this.Charactor.on("attack2", () => {
- //console.log("检测到攻击2 左");
- cc.audioEngine.playEffect(this.UiController.audioArr[3]);
- });
- this.Charactor.on("attack_critical_strike1", () => {
- //console.log("检测到暴击2右");
- //this.UiController.Ui_Shake(2);
- cc.audioEngine.playEffect(this.UiController.audioArr[3]);
- });
- this.Charactor.on("attack_critical_strike2", () => {
- //console.log("检测到暴击2左");
- // this.UiController.Ui_Shake(1);
- cc.audioEngine.playEffect(this.UiController.audioArr[3]);
- });
- this.Charactor.on("attack_double_hit1", () => {
- //console.log("检测到连击2右");
- // this.UiController.Ui_Shake(2);
- cc.audioEngine.playEffect(this.UiController.audioArr[3]);
- cc.audioEngine.playEffect(this.UiController.audioArr[3]);
- });
- this.Charactor.on("attack_double_hit2", () => {
- //console.log("检测到连击2左");
- // this.UiController.Ui_Shake(1);
- cc.audioEngine.playEffect(this.UiController.audioArr[3]);
- cc.audioEngine.playEffect(this.UiController.audioArr[3]);
- });
- 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");
- 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("检测到受普攻");
- this.UiController.Shake(this.Charactor, 2);
- 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("检测到受暴击");
- this.UiController.Shake(this.Charactor, 2);
- 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", () => {
- this.UiController.Shake(this.Charactor, 2);
- cc.audioEngine.playEffect(this.UiController.audioArr[4]);
- cc.audioEngine.playEffect(this.UiController.audioArr[4]);
- //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.init();
- },
- update(dt) {
- if (this._hp <= 0 || this._hp <= this.playerStateScp._hp && this.gamestate._game_time == 0) {
- this._GameState.gameresult = true;
- this._GameState._currPass++;
- if (this._GameState._currPass >= 3) {
- this._GameState._currPass = 3;
- }
- // console.log("胜利", this._GameState.gameresult);
- cc.audioEngine.playEffect(this.UiController.audioArr[2]);
- this.game.removeAllChildren();
- var self = this;
- cc.loader.loadRes("prefab/Result/interface_Win", cc.Prefab, (err, ResultArr) => {
- // ...
- self.PanelResult.addChild(cc.instantiate(ResultArr));
- });
- }
- },
- 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.playerStateScp = this.PlayerState.getComponent('PlayerStates');
- this.UiController = cc.find("Canvas/UiController").getComponent('UiController');
- this._GameState = cc.find("GameStates").getComponent("GameStates");
- },
- });
|