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

    },
    onCollisionEnter: function (other) {

        if(other.node.name === 'PlayerCollisionLine')
        {
            var PlayerCollisionLine = other.getComponent("PlayerCollisionLine");
            var PlayerStateScript = PlayerCollisionLine.node.parent.parent.getComponent("PlayerState");

            PlayerStateScript.CurrentInZoneType = PlayerStateStatic.ZoneType.BehindAccelerationBand;
            // cc.log(PlayerStateScript.CurrentInZoneType );
        }
        if(other.node.name === 'PlayerCollisionLine_ai')
        {
            // cc.log(PlayerStateScript.CurrentInZoneType );
        }
    },
    onCollisionStay: function (other) {
        // console.log('on collision stay');
    },
    onCollisionExit: function (other) {

        if(other.node.name === 'PlayerCollisionLine')
        {
            var PlayerState = other.node.parent.parent.getComponent("PlayerState");
            PlayerState.TouchControlEnableTouch = true;
            // if (other.node.parent.parent.name == "Hero") {
            //     var PlayerState = other.node.parent.parent.getComponent("PlayerState");
            //     PlayerState.TouchControlEnableTouch = true;
            //     // cc.log("状态 可以点击");
            // }

            // cc.log("我出去了吗",other.node.name);
            var PlayerCollisionLine = other.getComponent("PlayerCollisionLine");
            var HeroControlScript = PlayerCollisionLine.node.parent.parent.getComponent("HeroControl");
            var PlayerStateScript = PlayerCollisionLine.node.parent.parent.getComponent("PlayerState");

            // console.log('Stagger == ',PlayerStateScript.BTouchedScreenInTheZone);
            if(!PlayerStateScript.BTouchedScreenInTheZone)
            {
                HeroControlScript.Stagger();
                // console.log('Stagger!!');
            }
            PlayerStateScript.CurrentInZoneType = PlayerStateStatic.ZoneType.None;
            PlayerStateScript.BTouchedScreenInTheZone = false;
        }

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