const PlayerStateStatic = require('PlayerState'); const GameStatesStatic = require('GameStates'); cc.Class({ extends: cc.Component, properties: { Index: 0, BEnterCollision: false, HeroPro: null, PlayerStatePro: null, PlayerControlPro: null, GameStatePro: null, }, start() { this.HeroPro = cc.find("Hero"); this.PlayerStatePro = this.HeroPro.getComponent('PlayerState'); this.PlayerControlPro = this.HeroPro.getComponent('HeroControl'); this.GameStatePro = cc.find('Canvas').getComponent('GameStates'); this.inputLongJumpTag = false; }, onCollisionEnter: function (other) { // cc.log("状态 进入",other); this.BEnterCollision = true; if (!this.PlayerStatePro.TouchControlEnableTouch) { // cc.log("状态 禁用点击了之后"); return; } if (other.node.name === 'LeftColl' || other.node.name === 'LeftAccelerationBand30LeftColl' || other.node.name === 'RightAccelerationBand30LeftColl') //AccelerationBand { this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.FrontAccelerationBand); this.PlayerStatePro.BTouchedScreenInTheZone = true; // this.PlayerControlPro.resetPerfectGrade();//非完美点击,则重置perfectGrade this.PlayerControlPro.playAudioByName("ClickNormal"); // console.log("当前游戏状态 ",other.node.name, this.GameStatePro.CurrentProgress== GameStatesStatic.GameProgress.LongJump); if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.Javelin) { // cc.log("我现在是标枪项目 点的 加速", this.GameStatePro.CurrentProgress); this.PlayerControlPro.javeCount += 7; } if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//跳远 this.PlayerControlPro.longJumpCount += 0.7; // console.log("LeftColl==", cc.find('Hero').getComponent('HeroControl').longJumpCount); } // cc.log("我跳远",other.node.name,this.GameStatePro.CurrentProgress,this.PlayerControlPro.longJumpCount); } else if (other.node.name === 'AccelerationBandCenter' || other.node.name === 'LeftAccelerationBand30AccelerationBandCenter' || other.node.name === 'RightAccelerationBand30AccelerationBandCenter') { this.PlayerStatePro.BTouchedScreenInTheZone = true; this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.AccelerationBandCenter); var Player = this.HeroPro.getChildByName('Player'); Player.getComponent("Charactor").setOnTouchListener(event); //perfect完美提示 cc.find('UIControl').getComponent('GameUI').hideTimerPerfect(3); this.PlayerControlPro.addPerfectGradeAndPlay(); // console.log("当前游戏状态 ",other.node.name, this.GameStatePro.CurrentProgress== GameStatesStatic.GameProgress.LongJump); if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.Javelin) { // cc.log("我现在是标枪项目 点的 完美加速", this.GameStatePro.CurrentProgress); this.PlayerControlPro.javeCount += 10.5; } if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//跳远 this.PlayerControlPro.longJumpCount += 0.9; // console.log("Left!==", cc.find('Hero').getComponent('HeroControl').longJumpCount); } // cc.log("我跳远",other.node.name,this.GameStatePro.CurrentProgress,this.PlayerControlPro.longJumpCount); } else if (other.node.name === 'RightColl' || other.node.name === 'LeftAccelerationBand30RightColl' || other.node.name === 'RightAccelerationBand30RightColl') { this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.BehindAccelerationBand); this.PlayerStatePro.BTouchedScreenInTheZone = true; // this.PlayerControlPro.resetPerfectGrade();//非完美点击,则重置perfectGrade this.PlayerControlPro.playAudioByName("ClickNormal"); // console.log("当前游戏状态 ",other.node.name, this.GameStatePro.CurrentProgress== GameStatesStatic.GameProgress.LongJump); if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.Javelin) { // cc.log("我现在是标枪项目 点的 加速", this.GameStatePro.CurrentProgress); this.PlayerControlPro.javeCount += 7; } if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//跳远 this.PlayerControlPro.longJumpCount += 0.7; // console.log("RightColl==", cc.find('Hero').getComponent('HeroControl').longJumpCount); } // cc.log("我跳远",other.node.name,this.GameStatePro.CurrentProgress,this.PlayerControlPro.longJumpCount); } else if (other.node.name === 'PreLongJumpBand') { if (this.PlayerStatePro.BTouchedScreenInTheZone_jumpLong) { return; } // cc.log("进来 1",this.PlayerStatePro.BTouchedScreenInTheZone_jumpLong); // console.log("当前游戏状态 PreLongJumpBand", this.GameStatePro.CurrentProgress== GameStatesStatic.GameProgress.LongJump); if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//最后一个跳远点,蓝色区域 this.PlayerControlPro.longJumpCount += 0.7; // console.log("PreLongJumpBand!==", cc.find('Hero').getComponent('HeroControl').longJumpCount); } this.PlayerStatePro.enableTouch = false; this.PlayerStatePro.BTouchedScreenInTheZone = true; //todo 自己写的管理跳远是否点击过的 this.PlayerStatePro.BTouchedScreenInTheZone_jumpLong = true; this.PlayerControlPro.takeOffDistance = other.node.parent.getChildByName("NodeTouchControl").convertToWorldSpaceAR(cc.Vec2.ZERO).x - this.PlayerControlPro.node.convertToWorldSpaceAR(cc.Vec2.ZERO).x; this.PlayerControlPro.HeroLongJump("Hero"); // this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.FrontLongJumpBand); this.PlayerStatePro.schedule(function () { this.PlayerStatePro.enableTouch = true; }.bind(this), 5, 0); // console.log("self = ",this.PlayerControlPro.node.convertToWorldSpaceAR(cc.Vec2.ZERO).x, other.node.parent.getChildByName("NodeTouchControl").convertToWorldSpaceAR(cc.Vec2.ZERO).x); } else if (other.node.name === 'BunkerAccelerationBandCenter') { if (this.PlayerStatePro.BTouchedScreenInTheZone_jumpLong) { return; } // cc.log("进来 2",this.PlayerStatePro.BTouchedScreenInTheZone_jumpLong); // console.log("当前游戏状态 BunkerAccelerationBandCenter", this.GameStatePro.CurrentProgress== GameStatesStatic.GameProgress.LongJump); if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//最后一个跳远点,黄色区域 this.PlayerControlPro.longJumpCount += 0.9; // console.log("最后一个跳远点,黄色区域 ==", cc.find('Hero').getComponent('HeroControl').longJumpCount); } this.PlayerStatePro.enableTouch = false; this.PlayerStatePro.BTouchedScreenInTheZone = true; // cc.log("现在开始跳远"); //todo 自己写的管理跳远是否点击过的 this.PlayerStatePro.BTouchedScreenInTheZone_jumpLong = true; this.PlayerControlPro.HeroLongJump("Hero"); // this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.PerfectLongJumpBand); this.PlayerStatePro.schedule(function () { this.PlayerStatePro.enableTouch = true; }.bind(this), 5, 0); } else if (other.node.name === 'PreHurdleBand') { // this.PlayerControlPro.resetPerfectGrade(); this.PlayerStatePro.enableTouch = false; this.PlayerStatePro.TouchControlEnableTouch = false; this.PlayerStatePro.BTouchedScreenInTheZone = true; this.PlayerControlPro.HeroJump(function () { this.PlayerStatePro.TouchControlEnableTouch = true; }.bind(this)); this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.PreHurdleBand); this.PlayerStatePro.schedule(function () { //卧倒 this.PlayerStatePro.Barrier.getComponent("Barrier").Shake(); // var Hero = cc.find("Hero"); var NetworkSocket = this.HeroPro.getComponent('NetworkSocket'); var data = { FunctionName: 'ShakeBarrier', ParentName: this.PlayerStatePro.Railing.parent.name, ObjName: this.PlayerStatePro.Railing.name, PositionX: this.PlayerStatePro.Railing.convertToWorldSpaceAR(cc.Vec2.ZERO).x }; NetworkSocket.sendSyncData(JSON.stringify(data)); }.bind(this), 0.2, 0); this.PlayerStatePro.schedule(function () { this.PlayerStatePro.enableTouch = true; }.bind(this), 0.5, 0); } else if (other.node.name === 'PerfectHurdleBand') { // cc.log("现在动作","跨栏"); this.PlayerStatePro.enableTouch = false; this.PlayerStatePro.BTouchedScreenInTheZone = true; this.PlayerControlPro.HeroJump(function () { this.PlayerStatePro.TouchControlEnableTouch = true; }.bind(this)); this.PlayerControlPro.SpeedUp(PlayerStateStatic.ColliderSpeedUpPoint.PerfectHurdleBand); this.PlayerStatePro.schedule(function () { this.PlayerStatePro.enableTouch = true; }.bind(this), 0.5, 0); } // var PlayerState = cc.find("Hero").getComponent("PlayerState"); this.PlayerStatePro.TouchControlEnableTouch = false; if (other.node.name === 'LongAccelerationLeftColl' || other.node.name == "LongAccelerationRightColl") { // this.PlayerControlPro.resetPerfectGrade();//非完美点击,则重置perfectGrade // var PlayerState = cc.find("Hero").getComponent("PlayerState"); this.PlayerStatePro.TouchControlEnableTouch = true; // cc.log("删除",other.node.name); this.node.destroy(); } //todo 你想说的话 // cc.log("状态 禁用点击"); }, // onCollisionStay: function (other) { // // console.log('on collision stay'); // }, // onCollisionExit: function (other) { // // cc.log("状态 出去",other); // }, update(dt) { this.Index++; if (!this.BEnterCollision && 2 == this.Index) { // var Hero = cc.find("Hero"); // var this.PlayerControlPro = Hero.getComponent('HeroControl'); // this.PlayerControlPro.Stagger(); this.PlayerControlPro.Stagger(); } }, });