| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- cc.Class({
- extends: require("BasePlayerController"),
- properties: {
- TouchNode: cc.Node,
- charactor: cc.Node,
- AiController: 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.TouchNode.on('gesture', function(event) {
- console.log(event.name);
- Self.Gesture(event.name);
- });
- },
- start() {
- this.init();
- },
- init() {
- //角色脚本
- this.ctorScp = this.charactor.getComponent('Charactor');
- this.AiControScp = this.AiController.getComponent('AiPlayerController');
- //this.statesScp = this.charactor.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);
- if (name == 'right_top') {
- if (randomnum_1 >= 1 && randomnum_1 <= 10) {
- //出现暴击或者连击
- if (randomnum_2 == 1) {
- //暴击
- this._CriticalStrike = true;
- this.ctorScp.attack(2);
- this.AiControScp.ondefense_Ai(1, 1); //左右拳,击打类型
- }
- if (randomnum_2 == 2) {
- //连击
- this._DoubleHit = true;
- this.ctorScp.attack(4);
- this.AiControScp.ondefense_Ai(1, 2); //左右拳,击打类型
- }
- } else { //普攻状态 普攻动作
- this._RightJayShow = true;
- this.ctorScp.attack(0);
- this.AiControScp.ondefense_Ai(1, 0); //左右拳,击打类型
- }
- } else if (name == 'left_top') {
- if (randomnum_1 >= 1 && randomnum_1 <= 10) {
- //出现暴击或者连击
- if (randomnum_2 == 1) {
- //暴击
- this._CriticalStrike = true;
- this.ctorScp.attack(3);
- this.AiControScp.ondefense_Ai(-1, 1); //左右拳,击打类型
- }
- if (randomnum_2 == 2) {
- //连击
- this._DoubleHit = true;
- this.ctorScp.attack(5);
- this.AiControScp.ondefense_Ai(-1, 2); //左右拳,击打类型
- }
- } else { //普攻状态 普攻动作
- this._LeftJayShow = true;
- this.ctorScp.attack(1);
- this.AiControScp.ondefense_Ai(-1, 0); //左右拳,击打类型
- }
- } else if (name == 'right_down') {
- this._RightDodge = true;
- this.AiControScp._Statepassivity = false;
- this.ctorScp.dodge(0);
- } else if (name == 'left_down') {
- this._LeftDodg = true;
- this.AiControScp._Statepassivity = false;
- this.ctorScp.dodge(1);
- } else if (name == 'down') {
- this._Defence = true;
- this.AiControScp._Statepassivity = false;
- this.ctorScp.block();
- }
- },
- // update (dt) {},
- });
|