| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- 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');
- },
- 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;
- } else if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//跳远
- this.PlayerControlPro.longJumpCount += 0.7;
- // console.log("LeftColl==", cc.find('Hero').getComponent('HeroControl').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;
- } else if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//跳远
- this.PlayerControlPro.longJumpCount += 0.9;
- console.log("Left!==", cc.find('Hero').getComponent('HeroControl').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;
- } else if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//跳远
- this.PlayerControlPro.longJumpCount += 0.7;
- console.log("RightColl==", cc.find('Hero').getComponent('HeroControl').longJumpCount);
- }
- }
- else if (other.node.name === 'PreLongJumpBand') {
- // 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), 0.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') {
- // console.log("当前游戏状态 BunkerAccelerationBandCenter", this.GameStatePro.CurrentProgress== GameStatesStatic.GameProgress.LongJump);
- if (this.GameStatePro.CurrentProgress == GameStatesStatic.GameProgress.LongJump) {//最后一个跳远点,黄色区域
- this.PlayerControlPro.longJumpCount += 0.9;
- // console.log("BunkerAccelerationBandCenter!==", cc.find('Hero').getComponent('HeroControl').longJumpCount);
- }
- this.PlayerStatePro.enableTouch = false;
- this.PlayerStatePro.BTouchedScreenInTheZone = true;
- //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), 0.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;
- 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();
- }
- },
- });
|