Browse Source

装备完善,单机类完成

FantasyUFG 5 years ago
parent
commit
427aec02ef

File diff suppressed because it is too large
+ 332 - 305
assets/scene/Game.fire


+ 5 - 5
assets/script/Game/Ai/AiCharactor.js

@@ -63,7 +63,7 @@ cc.Class({
     },
     dodge(bLeft) { //躲闪
 
-        console.log("Ai躲闪");
+
         //发射躲闪事件 
         if (bLeft == 0) {
             //左躲闪
@@ -83,19 +83,19 @@ cc.Class({
             //普通挨打
             if (bLeft == 0) {
                 //左挨打
-                console.log("Ai挨右打");
+
                 this.armatureDisplay.node.scaleX = -1;
                 this.armature.animation.play("be_beaten", 1);
             } else if (bLeft == 1) {
                 //右挨打
-                console.log("Ai挨左打");
+
                 this.armatureDisplay.node.scaleX = 1;
                 this.armature.animation.play("be_beaten", 1);
             }
             this.node.emit("hurt_ord");
         }
         if (type == 1) {
-            console.log("Ai挨暴打");
+
             if (bLeft == 0) {
                 //左挨打
                 //被暴打
@@ -111,7 +111,7 @@ cc.Class({
             this.node.emit("hurt_critical");
         }
         if (type == 2) {
-            console.log("Ai挨连打");
+
             if (bLeft == 0) {
 
                 //被连击打

+ 14 - 6
assets/script/Game/Ai/AiPlayerController.js

@@ -5,6 +5,8 @@ cc.Class({
         charactor: cc.Node,
         PlayerController: cc.Node,
         PlayerctorScp: cc.Node,
+
+        states: cc.Node,
     },
     onLoad() {
         this._super();
@@ -40,6 +42,8 @@ cc.Class({
         this.PlayerControScp = this.PlayerController.getComponent('PlayerController');
         //角色脚本
         this.playerctorScp = this.PlayerctorScp.getComponent('Charactor');
+
+        this.stateScp = this.states.getComponent('AiPlayerStates');
     },
     update(dt) {
 
@@ -49,7 +53,7 @@ cc.Class({
         this._Statepassivity = true;
 
         let random = parseInt(Math.round(Math.random() * 10 + 1))
-        console.log("防守:", random);
+
         if (random < 5) {
             //半概率不躲避 被击中
             if (direction == 1) {
@@ -71,7 +75,7 @@ cc.Class({
                     this.ctorScp.hurt(0, type);
                     this._Hurt = true;
                 } else {
-                    console.log("Ai左躲闪");
+
                     this.ctorScp.dodge(0);
                     this._LeftDodg = true;
                 }
@@ -83,16 +87,20 @@ cc.Class({
                     this.ctorScp.hurt(1, type);
                     this._Hurt = true;
                 } else {
-                    console.log("Ai右躲闪");
+
                     this.ctorScp.dodge(1);
                     this._RightDodge = true;
                 }
 
             } else {
                 //防御
-                console.log("Ai防御");
-                this.ctorScp.block();
-                this._Defence = true;
+                if (this.stateScp._endurance >= this.stateScp._block_minus_endurance) {
+                    this.ctorScp.block();
+
+                    this._Defence = true;
+                } else {
+                    this._Defence = false;
+                }
             }
         }
 

+ 45 - 2
assets/script/Game/Ai/AiPlayerStates.js

@@ -5,10 +5,15 @@ cc.Class({
         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; //血量
@@ -28,7 +33,7 @@ cc.Class({
         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);
 
     },
@@ -36,14 +41,20 @@ cc.Class({
     start() {
         this.Charactor.on("attack", () => {
             //console.log("检测到攻击2");
+
+            cc.audioEngine.playEffect(this.UiController.audioArr[3]);
         });
         this.Charactor.on("attack_critical_strike", () => {
             //console.log("检测到暴击2");
 
+            cc.audioEngine.playEffect(this.UiController.audioArr[3]);
         });
         this.Charactor.on("attack_double-hit", () => {
             //console.log("检测到连击2");
 
+            cc.audioEngine.playEffect(this.UiController.audioArr[3]);
+            cc.audioEngine.playEffect(this.UiController.audioArr[3]);
+
         });
         this.Charactor.on("dodge", () => {
             //console.log("检测到躲闪2");
@@ -52,6 +63,8 @@ cc.Class({
         });
         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;
@@ -59,16 +72,24 @@ cc.Class({
         });
         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", () => {
+
+            cc.audioEngine.playEffect(this.UiController.audioArr[4]);
+
+            cc.audioEngine.playEffect(this.UiController.audioArr[4]);
             //console.log("检测到受连攻");
             this._hp = this.minusblood(this._hp);
 
@@ -76,7 +97,29 @@ cc.Class({
             this._hp = this.minusblood(this._hp);
             this.progressBar_hp.getComponent(cc.Sprite).fillRange = this._hp / this._maxhp;
         });
+        this.init();
     },
 
-    // update (dt) {},
+    update(dt) {
+        if (this._hp <= 0 || this._hp <= this.playerStateScp._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_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');
+
+    },
 });

+ 1 - 1
assets/script/Game/Base/BaseGameStates.js

@@ -11,7 +11,7 @@ cc.Class({
         this.player_gold = 10000;
         this.player_energy = 10001;
         this.player_sex = 0;
-
+        this.game_time = 720; //战斗时间
     },
     start() {
 

+ 15 - 16
assets/script/Game/Base/BasePlayerStates.js

@@ -28,7 +28,7 @@ cc.Class({
     //#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) {
@@ -37,7 +37,7 @@ cc.Class({
         return oneself_hp;
     },
     minusblood_critical(oneself_hp) {
-        console.log("暴击血量减少");
+
         let _oligemia = this.damage * 2 - this.defense;
         oneself_hp -= _oligemia;
         if (oneself_hp <= 0) {
@@ -49,7 +49,7 @@ cc.Class({
     //加血 
     //格挡加血 被动回血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;
@@ -74,7 +74,7 @@ cc.Class({
     //#region 蓝量变化
     //减蓝  endurance-=this.block_minus_endurance
     minusendurance(oneself_endurance) {
-        console.log("蓝量减少");
+
         oneself_endurance -= this.block_minus_endurance;
         if (oneself_endurance <= 0) {
             oneself_endurance = 0;
@@ -85,7 +85,7 @@ cc.Class({
     //加蓝 
     //闪避加蓝 被动回蓝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;
@@ -102,15 +102,14 @@ cc.Class({
         //}
     },
     //#endregion
-    //结果
-    Result_Show(playerHp, AiHp) {
-        if (playerHp <= 0) {
-            console.log("ai胜利");
-            return false;
-        }
-        if (AiHp <= 0) {
-            console.log("玩家胜利");
-            return true;
-        }
-    }
+    // //结果
+    // Result_Show(playerHp, AiHp) {
+    //     if (playerHp <= 0) {
+    //         return false;
+    //     }
+    //     if (AiHp <= 0) {
+    //         return true;
+    //     }
+    // },
+
 });

+ 2 - 0
assets/script/Game/GameStates.js

@@ -41,6 +41,8 @@ cc.Class({
             }
         }
 
+
+
     },
     start() {
         //console.log("金币", this.player_gold);

+ 3 - 5
assets/script/Game/Player/Charactor.js

@@ -58,8 +58,6 @@ cc.Class({
         }
     },
     dodge(bLeft) { //躲闪
-
-        console.log("躲闪");
         //发射躲闪事件 
         if (bLeft == 0) {
             //左躲闪
@@ -75,7 +73,7 @@ cc.Class({
     hurt(bLeft, type) { ////挨打 左右拳,击打类型
         //发射挨打事件 
         if (type == 0) {
-            console.log("挨打");
+
             if (bLeft == 0) {
                 //左挨打
                 this.armatureDisplay.node.scaleX = 0.39;
@@ -88,7 +86,7 @@ cc.Class({
             this.node.emit("hurt_ord");
         }
         if (type == 1) {
-            console.log("挨暴打");
+
             if (bLeft == 0) {
                 //左挨打
                 //被暴打
@@ -104,7 +102,7 @@ cc.Class({
             this.node.emit("hurt_critical");
         }
         if (type == 2) {
-            console.log("挨连打");
+
             if (bLeft == 0) {
 
                 //被连击打

+ 15 - 5
assets/script/Game/Player/PlayerController.js

@@ -5,6 +5,8 @@ cc.Class({
         TouchNode: cc.Node,
         charactor: cc.Node,
         AiController: cc.Node,
+
+        states: cc.Node,
     },
     onLoad() {
         this._super();
@@ -26,7 +28,7 @@ cc.Class({
         let Self = this;
 
         this.TouchNode.on('gesture', function(event) {
-            console.log(event.name);
+            //console.log(event.name);
             Self.Gesture(event.name);
         });
     },
@@ -38,11 +40,12 @@ cc.Class({
         this.ctorScp = this.charactor.getComponent('Charactor');
         this.AiControScp = this.AiController.getComponent('AiPlayerController');
         //this.statesScp = this.charactor.getComponent('PlayerStates');
+        this.stateScp = this.states.getComponent('PlayerStates');
     },
     Gesture(name) {
         var randomnum_1 = parseInt(Math.round(Math.random() * 98 + 1)); //(0-100]
         var randomnum_2 = parseInt(Math.round(Math.random() + 1)); //[1-2]
-        console.log(randomnum_1, randomnum_2);
+        //console.log(randomnum_1, randomnum_2);
         if (name == 'right_top') {
             if (randomnum_1 >= 1 && randomnum_1 <= 10) {
                 //出现暴击或者连击
@@ -127,9 +130,16 @@ cc.Class({
             this._LeftDodg = true;
             this.ctorScp.dodge(1);
         } else if (name == 'down') {
-            this._Defence = true;
-            this.AiControScp._Statepassivity = false;
-            this.ctorScp.block();
+            if (this.stateScp._endurance >= this.stateScp._block_minus_endurance) {
+                this._Defence = true;
+                this.AiControScp._Statepassivity = false;
+                this.ctorScp.block();
+            } else {
+                this._Defence = false;
+                this.AiControScp._Statepassivity = true;
+
+            }
+
         }
     },
 

+ 29 - 23
assets/script/Game/Player/PlayerStates.js

@@ -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;
         }
     },
 });

+ 5 - 5
assets/script/Game/Touch.js

@@ -29,13 +29,13 @@ cc.Class({
         if (dirvecY >= 0) {
             if (dirvecX > 0) {
                 //向右 上  出左拳
-                console.log("右上滑!");
+                //console.log("右上滑!");
                 this.node.emit("gesture", { name: 'right_top' });
 
             } else if (dirvecX < 0) {
 
                 //向左上 出右拳
-                console.log("左上滑!");
+                //console.log("左上滑!");
                 this.node.emit("gesture", { name: 'left_top' });
 
             }
@@ -43,17 +43,17 @@ cc.Class({
         } else if (dirvecY <= 0) {
 
             if (dirvecX > 15) {
-                console.log("右下滑!");
+                //console.log("右下滑!");
                 this.node.emit("gesture", { name: 'right_down' });
 
             } else if (dirvecX < -15) {
 
-                console.log("左下滑!");
+                // console.log("左下滑!");
                 this.node.emit("gesture", { name: 'left_down' });
 
 
             } else if (dirvecX <= 15 && dirvecX >= -15) {
-                console.log("向下");
+                // console.log("向下");
                 this.node.emit("gesture", { name: 'down' });
             }
         }

Some files were not shown because too many files changed in this diff