Browse Source

player attack

yichael 5 years ago
parent
commit
6e850fab1a

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


+ 12 - 0
assets/script/Game/Ai.meta

@@ -0,0 +1,12 @@
+{
+  "ver": "1.1.2",
+  "uuid": "5e8fed0f-83ba-425a-a6cb-54c533ed67f7",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 13 - 0
assets/script/Game/Base/BaseCharactor.js

@@ -0,0 +1,13 @@
+
+cc.Class({
+    extends: cc.Component,
+
+    properties: {
+      
+    },
+    // onLoad () {},
+    start () {
+
+    },
+    // update (dt) {},
+});

+ 9 - 0
assets/script/Game/Base/BaseCharactor.js.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.8",
+  "uuid": "1057f91f-1344-4c64-a79e-041db787607b",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 1 - 27
assets/script/Game/Base/BaseGameMode.js

@@ -1,38 +1,12 @@
-// Learn cc.Class:
-//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
-// Learn Attribute:
-//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
-// Learn life-cycle callbacks:
-//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
-
 cc.Class({
     extends: cc.Component,
 
     properties: {
-        // foo: {
-        //     // ATTRIBUTES:
-        //     default: null,        // The default value will be used only when the component attaching
-        //                           // to a node for the first time
-        //     type: cc.SpriteFrame, // optional, default is typeof default
-        //     serializable: true,   // optional, default is true
-        // },
-        // bar: {
-        //     get () {
-        //         return this._bar;
-        //     },
-        //     set (value) {
-        //         this._bar = value;
-        //     }
-        // },
+       
     },
-
-    // LIFE-CYCLE CALLBACKS:
-
     // onLoad () {},
-
     start () {
 
     },
-
     // update (dt) {},
 });

+ 13 - 0
assets/script/Game/Base/BaseGameStates.js

@@ -0,0 +1,13 @@
+
+cc.Class({
+    extends: cc.Component,
+
+    properties: {
+      
+    },
+    // onLoad () {},
+    start () {
+
+    },
+    // update (dt) {},
+});

+ 9 - 0
assets/script/Game/Base/BaseGameStates.js.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.8",
+  "uuid": "adea5bd4-f138-4dc8-a183-97d5709973c6",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 1 - 20
assets/script/Game/Base/BasePlayerController.js

@@ -2,30 +2,11 @@ cc.Class({
     extends: cc.Component,
 
     properties: {
-        // foo: {
-        //     // ATTRIBUTES:
-        //     default: null,        // The default value will be used only when the component attaching
-        //                           // to a node for the first time
-        //     type: cc.SpriteFrame, // optional, default is typeof default
-        //     serializable: true,   // optional, default is true
-        // },
-        // bar: {
-        //     get () {
-        //         return this._bar;
-        //     },
-        //     set (value) {
-        //         this._bar = value;
-        //     }
-        // },
+       
     },
-
-    // LIFE-CYCLE CALLBACKS:
-
     // onLoad () {},
-
     start () {
 
     },
-
     // update (dt) {},
 });

+ 1 - 24
assets/script/Game/Base/BasePlayerStates.js

@@ -1,33 +1,10 @@
-// Learn cc.Class:
-//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
-// Learn Attribute:
-//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
-// Learn life-cycle callbacks:
-//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
 
 cc.Class({
     extends: cc.Component,
 
     properties: {
-        // foo: {
-        //     // ATTRIBUTES:
-        //     default: null,        // The default value will be used only when the component attaching
-        //                           // to a node for the first time
-        //     type: cc.SpriteFrame, // optional, default is typeof default
-        //     serializable: true,   // optional, default is true
-        // },
-        // bar: {
-        //     get () {
-        //         return this._bar;
-        //     },
-        //     set (value) {
-        //         this._bar = value;
-        //     }
-        // },
+   
     },
-
-    // LIFE-CYCLE CALLBACKS:
-
     // onLoad () {},
 
     start () {

+ 2 - 25
assets/script/Game/GameMode.js

@@ -1,33 +1,10 @@
-// Learn cc.Class:
-//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
-// Learn Attribute:
-//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
-// Learn life-cycle callbacks:
-//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
 
 cc.Class({
-    extends: cc.Component,
+    extends: require("BaseGameMode"),
 
     properties: {
-        // foo: {
-        //     // ATTRIBUTES:
-        //     default: null,        // The default value will be used only when the component attaching
-        //                           // to a node for the first time
-        //     type: cc.SpriteFrame, // optional, default is typeof default
-        //     serializable: true,   // optional, default is true
-        // },
-        // bar: {
-        //     get () {
-        //         return this._bar;
-        //     },
-        //     set (value) {
-        //         this._bar = value;
-        //     }
-        // },
+       
     },
-
-    // LIFE-CYCLE CALLBACKS:
-
     // onLoad () {},
 
     start () {

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

@@ -0,0 +1,12 @@
+cc.Class({
+    extends: require("BaseGameStates"),
+
+    properties: {
+       
+    },
+    // onLoad () {},
+    start () {
+
+    },
+    // update (dt) {},
+});

+ 9 - 0
assets/script/Game/GameStates.js.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.8",
+  "uuid": "0d713884-722d-4015-a416-62c39d716777",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 12 - 0
assets/script/Game/Player.meta

@@ -0,0 +1,12 @@
+{
+  "ver": "1.1.2",
+  "uuid": "ee4e2607-67af-4aca-9bfc-ccd6a30b73fc",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 40 - 0
assets/script/Game/Player/Charactor.js

@@ -0,0 +1,40 @@
+
+cc.Class({
+    extends: require("BaseCharactor"),
+
+    properties: {
+     
+    },
+    onLoad () {
+        
+        this.armatureDisplay = this.node.getComponent(dragonBones.ArmatureDisplay);
+        this.armature = this.armatureDisplay.armature();
+
+        //添加动画事件监听
+        this.armatureDisplay.addEventListener(dragonBones.EventObject.COMPLETE, this.animationEventHandler, this);
+    },
+
+    start () {
+
+    },
+    attack(bLeft){
+        if(bLeft)
+        {
+            this.armature.animation.play("attack",1);
+        }
+        else
+        {
+            this.armature.animation.play("attack",1);
+        }
+    },
+    animationEventHandler(event) {
+        if (event.type === dragonBones.EventObject.COMPLETE) {
+            if (event.animationState.name === "attack") {
+                console.log("attack 动作播放完毕!!!");          
+                //TODO:
+                this.armature.animation.play("idle",-1);
+            }
+        }
+    }
+    // update (dt) {},
+});

+ 9 - 0
assets/script/Game/Player/Charactor.js.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "1.0.8",
+  "uuid": "b6208898-f9b9-45f5-b3a6-d7ac3fe24414",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 69 - 0
assets/script/Game/Player/PlayerController.js

@@ -0,0 +1,69 @@
+cc.Class({
+    extends: require("BasePlayerController"),
+
+    properties: {
+        leftTouchNode:cc.Node,
+        rightTouchNode:cc.Node,
+        charactor:cc.Node,
+    },
+    onLoad () {
+        //注册回调事件
+        let Self = this;
+        this.leftTouchNode.on('gesture', function (event) {
+            console.log(event.name);
+            Self.leftGesture(event.name);
+        })
+
+        this.rightTouchNode.on('gesture', function (event) {
+            console.log(event.name);
+            Self.rightGesture(event.name);
+        })
+    },
+    start () {
+        this.init();
+    },
+    init(){
+        //角色脚本
+        this.ctorScp = this.charactor.getComponent('BaseCharactor');
+    },
+    leftGesture(name)
+    {
+        if(name == 'up')
+        {
+            this.ctorScp.attack(1);
+        }
+        else if(name == 'down')
+        {
+  
+        }
+        else if(name == 'left')
+        {
+
+        }
+        else if(name == 'right')
+        {
+            this.ctorScp.attack(1);
+        }
+    },
+    rightGesture(name)
+    {
+        if(name == 'up')
+        {
+            this.ctorScp.attack(0);
+        }
+        else if(name == 'down')
+        {
+
+        }
+        else if(name == 'left')
+        {
+            this.ctorScp.attack(0);
+        }
+        else if(name == 'right')
+        {
+ 
+        }
+    },
+   
+    // update (dt) {},
+});

+ 0 - 0
assets/script/Game/PlayerController.js.meta → assets/script/Game/Player/PlayerController.js.meta


+ 0 - 26
assets/script/Game/PlayerController.js

@@ -1,26 +0,0 @@
-cc.Class({
-    extends: require("BasePlayerController"),
-
-    properties: {
-        leftTouchNode:cc.Node,
-        rightTouchNode:cc.Node,
-    },
-    onLoad () {
-        //注册回调事件
-
-        this.leftTouchNode.on('gesture', function (event) {
-            console.log(event.name);
-        })
-
-        this.rightTouchNode.on('gesture', function (event) {
-            console.log(event.name);
-        })
-    },
-    start () {
-
-    },
-    gesture(){
-
-    }
-    // update (dt) {},
-});

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

@@ -36,12 +36,12 @@ cc.Class({
             if (endX  > 0){
                 //向左函数
                 // console.log('left');
-                this.node.emit("gesture",{name:'touchLeft'});
+                this.node.emit("gesture",{name:'left'});
                 // this.dispatch('touchLeft');
             } else {
                 //向右函数
                 // console.log('right');
-                this.node.emit("gesture",{name:'touchRight'});
+                this.node.emit("gesture",{name:'right'});
             }
         } else {
             //手势向上下
@@ -49,11 +49,11 @@ cc.Class({
             if (endY  > 0){
                 //向下函数
                 // console.log('down');
-                this.node.emit("gesture",{name:'touchDown'});
+                this.node.emit("gesture",{name:'down'});
             } else {
                 //向上函数
                 // console.log('up');
-                this.node.emit("gesture",{name:'touchUp'});
+                this.node.emit("gesture",{name:'up'});
             }
          }
     }

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