const PlayerStateStatic = require('PlayerState');
var BarrierSuperClass = require("BarrierSuper");
cc.Class({
    extends: BarrierSuperClass,

    properties: {
    },

    start() {

    },
    onCollisionEnter: function (other) {
        if (other.node.name === 'PlayerCollisionLine') {
            var PlayerCollisionLine = other.getComponent("PlayerCollisionLine");
            var PlayerStateScript = PlayerCollisionLine.Hero.getComponent("PlayerState");
            PlayerStateScript.CurrentInZoneType = PlayerStateStatic.ZoneType.PerfectLongJumpBand;

            PlayerStateScript.PerfectLongJumpBandCenterTouched = this;


            // //自动跳远
            // this.NodeTouch = cc.find("TouchLayout").getComponent("NodeTouch");
            // if (!PlayerStateScript.BTouchedScreenInTheZone) {
            //     this.NodeTouch.TOUCH_START(true);
            // }

            // cc.log(PlayerStateScript.CurrentInZoneType );
        }
        if (other.node.name === 'LocationLine') {


            //perfect完美提示
            cc.find('UIControl').getComponent('GameUI').hideTimerPerfect(3);
            cc.find('Hero').getComponent('HeroControl').addPerfectGradeAndPlay();

            this.node.opacity = 0;
        }
    },

    onCollisionExit: function (other) {
        if (other.node.name === 'PlayerCollisionLine') {


            var PlayerCollisionLine = other.getComponent("PlayerCollisionLine");
            var HeroControlScript = PlayerCollisionLine.Hero.getComponent("HeroControl");
            var PlayerStateScript = PlayerCollisionLine.Hero.getComponent("PlayerState");


            if(PlayerStateScript.enableTouch){//没有点击时候自动跳远
                PlayerStateScript.enableTouch = false;
                PlayerStateScript.BTouchedScreenInTheZone = true;
                //todo 结束时候自动跳远
                PlayerStateScript.BTouchedScreenInTheZone_jumpLong = true;
                HeroControlScript.HeroLongJump("Hero");
    
                PlayerStateScript.schedule(function () {
                    PlayerStateScript.enableTouch = true;
                }.bind(this), 5, 0);

              
            }

            // if (!PlayerStateScript.BTouchedScreenInTheZone) {
            //     HeroControlScript.Stagger();
            // }


            PlayerStateScript.CurrentInZoneType = PlayerStateStatic.ZoneType.None;
            PlayerStateScript.BTouchedScreenInTheZone = false;
        
        }
    }
});
