| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- const PlayerStateStatic = require('PlayerState');
- cc.Class({
- extends: cc.Component,
- properties: {
- },
- start : function () {
- this.NodeTouch = cc.find("TouchLayout").getComponent("NodeTouch");
- },
- myRandom : function(num){
- if (num>Math.floor(Math.random()*100)) {
- return true;
- }else{
- return false;
- }
- },
- Enters :function (other,node) {
- var name = node.node.parent.parent.name;
- var PlayerStateScript = node.node.parent.parent.getComponent("PlayerState");
- var HeroControlScript = node.node.parent.parent.getComponent("HeroControl");
- //完美加速
- if (PlayerStateScript.CurrentInZoneType==PlayerStateStatic.ZoneType.AccelerationBandCenter) {
- // cc.log("调用了 ai 完美加速");
- if (this.myRandom(50)) {
- this.NodeTouch.TOUCH_START(true);
- }
- // player.getComponent("Charactor").setOnTouchListener(event);
- }
- //右面加速
- else if(PlayerStateScript.CurrentInZoneType===PlayerStateStatic.ZoneType.BehindAccelerationBand)
- {
- if (!PlayerStateScript.BTouchedScreenInTheZone) {
- if (this.myRandom(50)) {
- this.NodeTouch.TOUCH_START(true);
- }
- }
- }
- //长加速带
- else if(PlayerStateScript.CurrentInZoneType===PlayerStateStatic.ZoneType.FrontLongAccelerationBand)
- {
- this.NodeTouch.TOUCH_START(true);
- setTimeout(function () {
- this.NodeTouch.TOUCH_END(true);
- }.bind(this),200);
- }
- //跳远
- else if(PlayerStateScript.CurrentInZoneType===PlayerStateStatic.ZoneType.FrontLongJumpBand)//Hurdle
- {
- // cc.log("现在动作","跳远");
- // CustomLog("现在跳远",bHero);
- if (!PlayerStateScript.BTouchedScreenInTheZone) {
- this.NodeTouch.TOUCH_START(true);
- }
- }
- else if(PlayerStateScript.CurrentInZoneType===PlayerStateStatic.ZoneType.PreHurdleBand)//Hurdle
- {
- // cc.log("跨栏",name);
- if (!PlayerStateScript.BTouchedScreenInTheZone) {
- if (this.myRandom(100)) {
- this.NodeTouch.TOUCH_START(true);
- }
- }
- }
- else if(PlayerStateScript.CurrentInZoneType===PlayerStateStatic.ZoneType.PerfectHurdleBand)//Hurdle
- {
- if (!PlayerStateScript.BTouchedScreenInTheZone) {
- if (this.myRandom(50)) {
- this.NodeTouch.TOUCH_START(true);
- }
- }
- }
- }
- });
|