|
|
@@ -2,50 +2,91 @@ cc.Class({
|
|
|
extends: require("BasePlayerController"),
|
|
|
|
|
|
properties: {
|
|
|
- leftTouchNode: cc.Node,
|
|
|
- rightTouchNode: cc.Node,
|
|
|
+ TouchNode: cc.Node,
|
|
|
charactor: cc.Node,
|
|
|
},
|
|
|
onLoad() {
|
|
|
+ this._super();
|
|
|
+ this._Statepassivity = this.Statepassivity;
|
|
|
+ this._RightJayShow = this.RightJayShow; //出右拳
|
|
|
+ this._LeftJayShow = this.LeftJayShow; //出左拳
|
|
|
+
|
|
|
+ this._RightDodge = this.RightDodge; //右躲闪
|
|
|
+ this._LeftDodg = this.LeftDodg; //左躲闪
|
|
|
+
|
|
|
+ this._Defence = this.Defence; //防御
|
|
|
+
|
|
|
+ this._Hurt = this.Hurt;
|
|
|
+ this._CriticalStrike = this.CriticalStrike; //暴击
|
|
|
+ this._DoubleHit = this.DoubleHit; //连击
|
|
|
+ this._BeCriticalStrike = this.BeCriticalStrike; //被暴击
|
|
|
+ this._BeDoubleHit = this.BeDoubleHit; //被连击
|
|
|
//注册回调事件
|
|
|
let Self = this;
|
|
|
- this.leftTouchNode.on('gesture', function(event) {
|
|
|
- console.log(event.name);
|
|
|
- Self.leftGesture(event.name);
|
|
|
- })
|
|
|
|
|
|
- this.rightTouchNode.on('gesture', function(event) {
|
|
|
+ this.TouchNode.on('gesture', function(event) {
|
|
|
console.log(event.name);
|
|
|
- Self.rightGesture(event.name);
|
|
|
- })
|
|
|
+ Self.Gesture(event.name);
|
|
|
+ });
|
|
|
},
|
|
|
start() {
|
|
|
this.init();
|
|
|
},
|
|
|
init() {
|
|
|
//角色脚本
|
|
|
- this.ctorScp = this.charactor.getComponent('baseCharactor');
|
|
|
+ this.ctorScp = this.charactor.getComponent('BaseCharactor');
|
|
|
+ this.statesScp = this.charactor.getComponent('PlayerStates');
|
|
|
},
|
|
|
- leftGesture(name) {
|
|
|
- if (name == 'up') {
|
|
|
- this.ctorScp.attack(1);
|
|
|
- } else if (name == 'down') {
|
|
|
+ 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);
|
|
|
+ if (name == 'right_top') {
|
|
|
+ if (randomnum_1 >= 1 && randomnum_1 <= 10) {
|
|
|
+ //出现暴击或者连击
|
|
|
+ if (randomnum_2 == 1) {
|
|
|
+ //暴击
|
|
|
+ this._CriticalStrike = true;
|
|
|
+ this.ctorScp.attack(2);
|
|
|
+ }
|
|
|
+ if (randomnum_2 == 2) {
|
|
|
+ //连击
|
|
|
+ this._DoubleHit = true;
|
|
|
+ this.ctorScp.attack(3);
|
|
|
+ }
|
|
|
+ } else { //普攻状态 普攻动作
|
|
|
+ this._RightJayShow = true;
|
|
|
+ this.ctorScp.attack(1);
|
|
|
+ }
|
|
|
|
|
|
- } 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') {
|
|
|
+ } else if (name == 'left_top') {
|
|
|
+ if (randomnum_1 >= 1 && randomnum_1 <= 10) {
|
|
|
+ //出现暴击或者连击
|
|
|
+ if (randomnum_2 == 1) {
|
|
|
+ //暴击
|
|
|
+ this._CriticalStrike = true;
|
|
|
+ this.ctorScp.attack(2);
|
|
|
+ }
|
|
|
+ if (randomnum_2 == 2) {
|
|
|
+ //连击
|
|
|
+ this._DoubleHit = true;
|
|
|
+ this.ctorScp.attack(3);
|
|
|
+ }
|
|
|
+ } else { //普攻状态 普攻动作
|
|
|
+ this._LeftJayShow = true;
|
|
|
+ this.ctorScp.attack(0);
|
|
|
+ }
|
|
|
|
|
|
+ } else if (name == 'right_down') {
|
|
|
+ this._RightDodge = true;
|
|
|
+ this.ctorScp.dodge(0);
|
|
|
+ } else if (name == 'left_down') {
|
|
|
+ this._LeftDodg = true;
|
|
|
+ this.ctorScp.dodge(1);
|
|
|
+ } else if (name == 'down') {
|
|
|
+ this._Defence = true;
|
|
|
+ this.ctorScp.block();
|
|
|
}
|
|
|
},
|
|
|
|