| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966 |
- cc.Class({
- extends: cc.Component,
- properties: {
- PlayerDistance: 0,
- LastLoadedLvIndex: 0,
- TargetNum: 720 * 2,
- BgPrefabArray: [],
- AllBgPrefabArray: [],
- BAllSceneLoaded: false,
- PlayerInTheZone: 'None',
- PrePlayerInLvIndex: 0,
- CurrentPlayerInLvIndex: 0,
- FrontEnableLvIndex: 0,
- HasTiped: false,
- HasGetTipPositionX: false,
- TipLocationX: -1,
- SprintStartLinePositionX: 0,
- LongJumpStartLinePositionX: 0,
- HurdleStartLinePositionX: 0,
- JavelinStartLinePositionX: 0,
- RideBikeStartLinePositionX: 0,
- //起点 todo
- SprintStartLine: {//短跑起点
- default: null,
- type: cc.Prefab
- },
- LongJumpStartLine: {//跳远起点
- default: null,
- type: cc.Prefab
- },
- HurdleStartLine: {//跨栏起点
- default: null,
- type: cc.Prefab
- },
- JavelinStartLine: {//标枪起点
- default: null,
- type: cc.Prefab
- },
- BikeStartLine: {//骑车起点
- default: null,
- type: cc.Prefab
- },
- //终点 todo
- FinishLine_Sprint: {//短跑终点线
- default: null,
- type: cc.Prefab
- },
- LongJumpFinishLine: {//跳远终点
- default: null,
- type: cc.Prefab
- },
- FinishLine_Hurdle: {//跨栏终点
- default: null,
- type: cc.Prefab
- },
- JavelinFinishLine: {//标枪终点线
- default: null,
- type: cc.Prefab
- },
- // BikeFinishLine
- FinishLine_Bike: {//骑车终点
- default: null,
- type: cc.Prefab
- },
- // Hero: {
- // default: null,
- // type: cc.Node
- // },
- Canvas: {
- default: null,
- type: cc.Node
- },
- Blank: {//空白
- default: null,
- type: cc.Prefab
- },
- AccelerationBand30InTheMiddle: {//大加居中
- default: null,
- type: cc.Prefab
- },
- Cushion30AndRailingInTheMiddle: {//大缓跨栏居中
- default: null,
- type: cc.Prefab
- },
- JavelinModel: {//标枪模型
- default: null,
- type: cc.Prefab
- },
- LongAccelerationBand10ColumnTheLeftHalf1: {//长10加前半部分
- default: null,
- type: cc.Prefab
- },
- LongAccelerationBand10ColumnTheRightHalf2: {//长10加后半部分
- default: null,
- type: cc.Prefab
- },
- JavelinDistanceFirst: {//标枪计距带起点
- default: null,
- type: cc.Prefab
- },
- JavelinDistanceMiddle: {//标枪计距带中部10M-100M
- default: null,
- type: cc.Prefab
- },
- JavelinDistanceLast: {//标枪计距带尾部110M
- default: null,
- type: cc.Prefab
- },
- Cushion30AndBunker1M: {//沙坑1M
- default: null,
- type: cc.Prefab
- },
- Bunker2to4M: {//沙坑2-4M
- default: null,
- type: cc.Prefab
- },
- Bunker5to7M: {//沙坑5-7M
- default: null,
- type: cc.Prefab
- },
- Bunker8to10M: {//沙坑8-10M
- default: null,
- type: cc.Prefab
- },
- Bunker11M: {//沙坑11M
- default: null,
- type: cc.Prefab
- },
- BikeModelToTheRight: {//自行车模型
- default: null,
- type: cc.Prefab
- },
- TwoAcceleration30s: {//两个大加1
- default: null,
- type: cc.Prefab
- },
- Acceleration30AndAcceleration20: {//两个大加2
- default: null,
- type: cc.Prefab
- },
- Acceleration20ToTheLeft: {//一个大加靠左
- default: null,
- type: cc.Prefab
- },
- LongAccelerationBand7Column: {//长7加1
- default: null,
- type: cc.Prefab
- },
- LongAccelerationBand10ColumnTheLeftHalf3: {//长10带边框1左半部分
- default: null,
- type: cc.Prefab
- },
- LongAccelerationBand10ColumnTheRightHalf4: {//长10带边框1右半部分
- default: null,
- type: cc.Prefab
- },
- LongAccelerationBand10ColumnTheLeftHalf5: {//长10带边框2左大半部分
- default: null,
- type: cc.Prefab
- },
- LongAccelerationBand10ColumnTheRightHalfAndLeftHalf6: {//长10带边框2右半部分及长10带边框3左小半部分
- default: null,
- type: cc.Prefab
- },
- LongAccelerationBand10ColumnTheRightHalf7: {//长10带边框3右半部分
- default: null,
- type: cc.Prefab
- },
- LongAccelerationBand10ColumnTheLeftHalf8: {//长10带边框4左半部分
- default: null,
- type: cc.Prefab
- },
- LongAccelerationBand10ColumnTheRightHalf9: {//长10带边框4右半部分
- default: null,
- type: cc.Prefab
- },
- AccelerationBand20InTheMiddle: {//中加居中
- default: null,
- type: cc.Prefab
- },
- AccelerationBand10InTheMiddle: {//小加居中
- default: null,
- type: cc.Prefab
- },
- JumpDownBike: {//下自行车
- default: null,
- type: cc.Prefab
- },
- JavelinBeginJump: {//标枪起跳
- default: null,
- type: cc.Prefab
- },
- LocationLine: {
- default: null,
- type: cc.Prefab
- },
- YellowBG: {
- default: null,
- type: cc.Prefab
- },
- wriggle_prefab: {
- default: null,
- type: cc.Prefab
- },
- javeBg_prefab: {
- default: null,
- type: cc.Prefab
- },
- JavalinDistance: 0,
- PrefabNumLabel: {
- default: null,
- type: cc.Prefab
- },
- PlayerInLvIndexLabel: {
- default: null,
- type: cc.Prefab
- },
- _GameUI: null,
- _getHero: null,
- _getRivel: null,
- _getJavetempHero: null,
- _getJavetempRivel: null,
- },
- onLoad: function () {
- this._GameUI = cc.find('UIControl').getComponent('GameUI');
- this._getHero = cc.find('Hero');
- this._getRivel = cc.find('Rivel');
- this._getJavetempHero = cc.find('javetemp_Hero');
- this._getJavetempRivel = cc.find('javetemp_Rivel');
- this.TipLocationX = -1;
- this.TargetNum = 720 * 3;
- this.JavalinDistance = 10;
- this.YellowBGArr = [];
- this.arrJavelin = [];
- // this.HasTiped = false;
- // this.testArr(false);
- // var data = {
- // gameLv: 0,
- // startPositionX: 0
- // }
- // this.setStart(data);
- // this.PreLoad();
- // var CameraNode = cc.find("CameraNode");
- // var Hero = cc.find("Hero");
- // CameraNode.parent = Hero;
- // setTimeout(function () {
- // this.onKeyDown();
- // }.bind(this), 5000);
- },
- start() {
- // this.scheduleOnce(function () {
- // 这里的 this 指向 component
- this.testArr(false);
- var data = {
- gameLv: 0,
- startPositionX: 0
- }
- this.setStart(data);
- this.PreLoad();
- // var CameraNode = cc.find("CameraNode");
- // var Hero = cc.find("Hero");
- // CameraNode.parent = Hero;
- // }, 0);
- },
- //可以设置 加载几个项目
- setStart: function (data) {
- // cc.log('就是看下setStart执行几次。。。。。。。。。。。。。');
- if (data.gameLv == 1) {
- // cc.log('跨栏项目初始化!!!!!!!!!!!!!!');
- }
- this.HasGetTipPositionX = false;
- this.TipLocationX = -1;
- this.tempArr = [];
- if (data == null) {
- } else {
- for (var i = 0; i < this.BgPrefabArray.length; i++) {
- if (this.BgPrefabArray[0]) {
- // this.BgPrefabArray[i].destroy();
- this.BgPrefabArray.shift();
- }
- }
- for (var i = 0; i < this.YellowBGArr.length; i++) {
- if (this.YellowBGArr[0]) {
- // this.YellowBGArr[i].destroy();
- this.YellowBGArr.shift();
- }
- }
- setTimeout(function () {
- this.delJaveLin();
- }.bind(this), 5000);
- // for (var i = 0; i < this.AllBgPrefabArray.length; i++) {
- // this.AllBgPrefabArray[i].destroy();
- // }
- // this.BgPrefabArray = [];
- // this.AllBgPrefabArray = [];
- // cc.log("要比赛的是什么",this.BgPrefabArr[0]);
- //
- if (data.gameLv == 0) {
- this.addPushArr(this.BgPrefabArr[0]);
- this.addPushArr(this.BgPrefabArr[1]);
- } else if (data.gameLv == 1) {
- this.addPushArr(this.BgPrefabArr[2]);
- this.addPushArr(this.BgPrefabArr[3]);
- } else if (data.gameLv == 2) {
- this.addPushArr(this.BgPrefabArr[4]);
- }
- }
- // cc.log("要比赛的是什么 1",this.tempArr);
- //
- this.AllBgPrefabArray = this.tempArr;
- // CustomLog("要比赛的是什么 1", this.AllBgPrefabArray);
- // cc.log("要比赛的是什么 2",this.AllBgPrefabArray);
- for (var i = 0; i < 4; i++) {
- this.LastLoadedLvIndex = i + 1;
- var tPrefab = cc.instantiate(this.tempArr[i]);
- tPrefab.parent = this.node;
- tPrefab.setAnchorPoint(0.5, 0.5);
- tPrefab.setLocalZOrder(-i);
- tPrefab.setPosition(data.startPositionX + i * (720), 0);
- // cc.log('prefab name is '+tPrefab.name+' and X is '+tPrefab.position.x);
- // cc.log('name is '+tPrefab.name+' ***************************************for loop');
- this.BgPrefabArray.push(tPrefab);
- // this.AddIndexLabelToPrefab(i*(720));//此为预制体添加数字标签,正式项目可注释
- this.setStartLine(tPrefab);
- }
- },
- addJaveLin: function (javeLin) {
- this.arrJavelin.push(javeLin);
- },
- delJaveLin: function () {
- if (this.arrJavelin&&this.arrJavelin.length != 0) {
- for (var i = 0; i < this.arrJavelin.length; i++) {
- this.arrJavelin[i].destroy();
- }
- }
- },
- addPushArr: function (arr) {
- for (var i = 0; i < arr.length; i++) {
- var node = arr[i];
- this.tempArr.push(node);
- }
- },
- testArr: function (b) {
- this.BgPrefabArr = [];
- //测试在这里修改
- if (b) {
- this.BgPrefabArr[0] = [
- //短跑
- this.Blank,//空白
- this.SprintStartLine,//短跑起点
- // this.AccelerationBand30InTheMiddle,//短跑5个大加
- // this.AccelerationBand30InTheMiddle,
- // this.AccelerationBand30InTheMiddle,
- // this.AccelerationBand30InTheMiddle,
- // this.AccelerationBand30InTheMiddle,
- this.AccelerationBand20InTheMiddle,//3个中加
- this.AccelerationBand20InTheMiddle,
- this.AccelerationBand20InTheMiddle,
- this.FinishLine_Sprint,//终点线
- ];
- this.BgPrefabArr[1] = [
- // 跳远
- this.LongJumpStartLine,//跳远起点
- this.AccelerationBand30InTheMiddle,//4个大加
- this.AccelerationBand30InTheMiddle,
- // this.AccelerationBand30InTheMiddle,
- // this.AccelerationBand30InTheMiddle,
- // this.AccelerationBand20InTheMiddle,//3个中加
- // this.AccelerationBand20InTheMiddle,
- // this.AccelerationBand20InTheMiddle,
- // this.LongAccelerationBand10ColumnTheLeftHalf1,//长10加前半部分
- // this.LongAccelerationBand10ColumnTheRightHalf2,//长10加后半部分
- // this.LongAccelerationBand10ColumnTheLeftHalf1,//长10加前半部分
- // this.LongAccelerationBand10ColumnTheRightHalf2,//长10加后半部分
- this.Cushion30AndBunker1M,//沙坑1M
- this.Bunker2to4M,//沙坑2-4M
- this.Bunker5to7M,//沙坑5-7M
- this.Bunker8to10M,//沙坑8-10M
- this.Bunker11M,//沙坑11M
- this.LongJumpFinishLine,//终点线
- this.Blank,//空白
- ];
- this.BgPrefabArr[2] = [
- // 跨栏
- this.HurdleStartLine,//跨栏起点
- this.Blank,//空白
- this.AccelerationBand30InTheMiddle,//连续4个大加交替4个大缓跨栏
- // this.Cushion30AndRailingInTheMiddle,//连续4个大加交替4个大缓跨栏
- // this.Blank,//空白
- // this.Blank,//空白
- // this.AccelerationBand30InTheMiddle,
- // this.Cushion30AndRailingInTheMiddle,
- // this.Blank,//空白
- // this.AccelerationBand30InTheMiddle,
- // this.Cushion30AndRailingInTheMiddle,
- // this.Blank,//空白
- // this.AccelerationBand30InTheMiddle,
- // this.Cushion30AndRailingInTheMiddle,
- // this.Blank,//空白
- // this.AccelerationBand30InTheMiddle,
- this.Cushion30AndRailingInTheMiddle,
- this.Blank,//空白
- this.FinishLine_Hurdle,//终点线
- this.Blank,//空白
- ];
- this.BgPrefabArr[3] = [
- // 标枪
- this.JavelinStartLine,//标枪起点
- this.JavelinModel,//标枪模型 vvvvv
- this.AccelerationBand30InTheMiddle,//4个大加
- // this.AccelerationBand30InTheMiddle,
- // this.AccelerationBand30InTheMiddle,
- // this.AccelerationBand30InTheMiddle,
- // this.AccelerationBand20InTheMiddle,//3个中加
- // this.AccelerationBand20InTheMiddle,
- // this.AccelerationBand20InTheMiddle,
- // this.LongAccelerationBand10ColumnTheLeftHalf1,//长10加前半部分
- // this.LongAccelerationBand10ColumnTheRightHalf2,//长10加后半部分
- // this.LongAccelerationBand10ColumnTheLeftHalf1,//长10加前半部分
- // this.LongAccelerationBand10ColumnTheRightHalf2,//长10加后半部分
- this.javeBg_prefab,//起跳
- this.JavelinDistanceFirst,//标枪距离计算起点
- this.JavelinDistanceMiddle,//标枪距离计算中间部分共10个
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceLast,//标枪距离计算末尾部分*/
- this.JavelinFinishLine,//终点线
- this.Blank,//空白
- ];
- this.BgPrefabArr[4] = [
- //骑车
- this.BikeStartLine,//骑车起点
- this.BikeModelToTheRight,//自行车模型
- this.TwoAcceleration30s,//3个大加2个中加
- // this.Acceleration30AndAcceleration20,//
- // this.Acceleration20ToTheLeft,//
- this.LongAccelerationBand7Column,//1个长7
- // this.LongAccelerationBand10ColumnTheLeftHalf3,//4个长10
- // this.LongAccelerationBand10ColumnTheRightHalf4,//
- // this.LongAccelerationBand10ColumnTheLeftHalf5,//
- // this.LongAccelerationBand10ColumnTheRightHalfAndLeftHalf6,//
- // this.LongAccelerationBand10ColumnTheRightHalf7,//
- // this.LongAccelerationBand10ColumnTheLeftHalf8,//
- // this.LongAccelerationBand10ColumnTheRightHalf9,//
- this.Blank,//
- this.FinishLine_Bike,//终点线
- this.Blank,//
- this.Blank,//
- this.Blank,//
- ]
- } else {
- this.BgPrefabArr[0] = [
- //短跑
- this.Blank,//空白
- this.SprintStartLine,//短跑起点
- this.AccelerationBand30InTheMiddle,//短跑5个大加
- this.AccelerationBand30InTheMiddle,
- this.AccelerationBand30InTheMiddle,
- this.AccelerationBand30InTheMiddle,
- this.AccelerationBand30InTheMiddle,
- this.AccelerationBand20InTheMiddle,//3个中加
- this.AccelerationBand20InTheMiddle,
- this.AccelerationBand20InTheMiddle,
- this.FinishLine_Sprint,//终点线
- this.Blank,//空白
- ];
- this.BgPrefabArr[1] = [
- // 跳远
- this.LongJumpStartLine,//跳远起点
- this.AccelerationBand30InTheMiddle,//4个大加
- this.AccelerationBand30InTheMiddle,
- this.AccelerationBand30InTheMiddle,
- this.AccelerationBand30InTheMiddle,
- this.AccelerationBand20InTheMiddle,//3个中加
- this.AccelerationBand20InTheMiddle,
- this.AccelerationBand20InTheMiddle,
- this.LongAccelerationBand10ColumnTheLeftHalf1,//长10加前半部分
- this.LongAccelerationBand10ColumnTheRightHalf2,//长10加后半部分
- this.LongAccelerationBand10ColumnTheLeftHalf1,//长10加前半部分
- this.LongAccelerationBand10ColumnTheRightHalf2,//长10加后半部分
- this.Cushion30AndBunker1M,//沙坑1M
- this.Bunker2to4M,//沙坑2-4M
- this.Bunker5to7M,//沙坑5-7M
- this.Bunker8to10M,//沙坑8-10M
- this.Bunker11M,//沙坑11M
- this.LongJumpFinishLine,//终点线
- this.Blank,//空白
- ];
- this.BgPrefabArr[2] = [
- // 跨栏
- this.HurdleStartLine,//跨栏起点
- this.Blank,//空白
- this.AccelerationBand30InTheMiddle,//连续4个大加交替4个大缓跨栏
- this.Cushion30AndRailingInTheMiddle,//连续4个大加交替4个大缓跨栏
- this.Blank,//空白
- this.Blank,//空白
- this.AccelerationBand30InTheMiddle,
- this.Cushion30AndRailingInTheMiddle,
- this.Blank,//空白
- this.AccelerationBand30InTheMiddle,
- this.Cushion30AndRailingInTheMiddle,
- this.Blank,//空白
- this.AccelerationBand30InTheMiddle,
- this.Cushion30AndRailingInTheMiddle,
- this.Blank,//空白
- this.AccelerationBand30InTheMiddle,
- this.Cushion30AndRailingInTheMiddle,
- this.Blank,//空白
- this.FinishLine_Hurdle,//终点线
- this.Blank,//空白
- ];
- this.BgPrefabArr[3] = [
- // 标枪
- this.JavelinStartLine,//标枪起点
- this.JavelinModel,//标枪模型 vvvvv
- this.AccelerationBand30InTheMiddle,//4个大加
- this.AccelerationBand30InTheMiddle,
- this.AccelerationBand30InTheMiddle,
- this.AccelerationBand30InTheMiddle,
- this.AccelerationBand20InTheMiddle,//3个中加
- this.AccelerationBand20InTheMiddle,
- this.AccelerationBand20InTheMiddle,
- this.LongAccelerationBand10ColumnTheLeftHalf1,//长10加前半部分
- this.LongAccelerationBand10ColumnTheRightHalf2,//长10加后半部分
- this.LongAccelerationBand10ColumnTheLeftHalf1,//长10加前半部分
- this.LongAccelerationBand10ColumnTheRightHalf2,//长10加后半部分
- this.javeBg_prefab,//起跳
- this.JavelinDistanceFirst,//标枪距离计算起点
- this.JavelinDistanceMiddle,//标枪距离计算中间部分共10个
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceMiddle,
- this.JavelinDistanceLast,//标枪距离计算末尾部分*/
- this.JavelinFinishLine,//终点线
- this.Blank,//空白
- ];
- this.BgPrefabArr[4] = [
- //骑车
- this.BikeStartLine,//骑车起点
- this.BikeModelToTheRight,//自行车模型
- this.TwoAcceleration30s,//3个大加2个中加
- this.Acceleration30AndAcceleration20,//
- this.Acceleration20ToTheLeft,//
- this.LongAccelerationBand7Column,//1个长7
- this.LongAccelerationBand10ColumnTheLeftHalf3,//4个长10
- this.LongAccelerationBand10ColumnTheRightHalf4,//
- this.LongAccelerationBand10ColumnTheLeftHalf5,//
- this.LongAccelerationBand10ColumnTheRightHalfAndLeftHalf6,//
- this.LongAccelerationBand10ColumnTheRightHalf7,//
- this.LongAccelerationBand10ColumnTheLeftHalf8,//
- this.LongAccelerationBand10ColumnTheRightHalf9,//
- this.Blank,//
- this.FinishLine_Bike,//终点线
- this.Blank,//
- this.Blank,//
- this.Blank,//
- ]
- }
- },
- PreLoad: function () {
- var aPrefab = cc.instantiate(this.YellowBG);//开始时加载一个长加速带的黄色区域,后面再次加载就不会卡
- aPrefab.parent = this.node;
- aPrefab.setPosition(-1000, 1000);
- aPrefab.destroy();
- var aPrefab = cc.instantiate(this._GameUI.UIPKScore);//开始时加载一下PK分数
- aPrefab.parent = this.node;
- aPrefab.setPosition(-1000, 1000);
- aPrefab.destroy();
- // CustomLog("我加载了几次");
- // var bPrefab = cc.instantiate(this.PlayerInLvIndexLabel);//显示更前面的角色的LevelIndex。防止地图未加载。调试时用,正式版则注释掉
- // bPrefab.parent = cc.find('UITop');
- // bPrefab.setPosition(360,0);
- // this.PlayerInLvIndexLabel = bPrefab;
- },
- onKeyDown: function (event) {
- if (event == null) {
- return;
- }
- switch (event.keyCode) {
- case cc.KEY.a:
- cc.log('Press a key');
- var Hero = cc.find('Hero');
- var Rivel = cc.find('Rivel');
- var HeroHeroControl = Hero.getComponent("HeroControl");
- var RivelHeroControl = Rivel.getComponent("HeroControl");
- HeroHeroControl.SetSpeedToZeroAndIdle();
- RivelHeroControl.SetSpeedToZeroAndIdle();
- HeroHeroControl.javelinTag = false;
- RivelHeroControl.javelinTag = false;
- Hero.getChildByName('Player').stopAllActions();
- Rivel.getChildByName('Player').stopAllActions();
- Hero.getChildByName('Player').setPositionY(-132);
- Rivel.getChildByName('Player').setPositionY(-37);
- break;
- }
- },
- SetDistance: function (aPlayerDistance) {
- if (this.PlayerDistance === aPlayerDistance)
- return;
- this.PlayerDistance = aPlayerDistance;
- // console.log('aPlayerDistance =',aPlayerDistance);
- },
- SetLocationLine: function (PlayerCollisionLinePosition) {
- var aPrefab = cc.instantiate(this.LocationLine);
- aPrefab.parent = this.node;
- aPrefab.setPosition(PlayerCollisionLinePosition);
- },
- CreateYellowBG: function (PlayerCollisionLinePosition) {
- var aPrefab = cc.instantiate(this.YellowBG);
- aPrefab.parent = this.node;
- this.YellowBGArr.push(aPrefab);
- // aPrefab.setAnchorPoint(0.5, 0.5);
- aPrefab.setPosition(PlayerCollisionLinePosition);
- return aPrefab;
- },
- displayTimerMiddlePKScore: function (player) {//显示隐藏比分
- if (player.name === 'Hero') {
- var MyScore = this._getHero.getComponent("PlayerState").TerminalPoint;
- var RivalScore = this._getRivel.getComponent("PlayerState").TerminalPoint;
- if (MyScore == 0 && RivalScore == 0) {
- return;
- }
- this._GameUI.displayTimerMiddlePKScore(MyScore, RivalScore, 0);
- }
- },
- sortNumber: function (a, b) {
- return b - a
- },
- update: function (dt) {
- // cc.log(this.BgPrefabArray);
- //var str = '["同意","不同意"]';
- //var str2 = "test";
- //var str3 = "xixixi";
- // var data = { FunctionName: 'PushPlayerToEnterFinishLinePlayersArray' };
- // var value = "{\"id\":\""+json[i].id+"\",\"text\":\""+json[i].text+"\"},"
- // var value = "{"+str2+":"+str3+"}";
- //var value = "{"+str2+":"+str3+"}";
- // var test3 = value.parseJSON();
- // var test = JSON.stringify(value);
- // var test2 = JSON.parse(test.test);
- // cc.log(test3);
- // cc.log(this.StartLinesPositionXJson.LongJump);
- // var str = '0123456StartLine';
- // var SubToStrIndex = str.length-9;
- // cc.log(str.substring(0,SubToStrIndex));
- //cc.log('提示'+this.HasTiped+' 获取位置'+this.HasGetTipPositionX+' 提示位置'+this.TipLocationX+' hero位置'+cc.find('Hero').position.x);
- if (this.HasTiped == false) {
- if (this.TipLocationX != -1) {
- var HeroPositionX = this._getHero.position.x;
- if (HeroPositionX >= this.TipLocationX) {
- //cc.log('执行了###################');
- //cc.log(this.TipLocationX+'****'+HeroPositionX);
- this._GameUI.hideTimerTipOfLongAcceleration(3);//长加速带长按提示
- this.HasTiped = true;
- }
- }
- }
- // cc.log('提示'+this.HasTiped+' 获取位置'+this.HasGetTipPositionX+' 提示位置'+this.TipLocationX+' hero位置'+cc.find('Hero').position.x);
- // cc.log(this.TipLocationX + '=前面是提示位置后面是hero位置=' + cc.find('Hero').position.x);
- if (this.AllBgPrefabArray.length - 1 == this.LastLoadedLvIndex) return;
- var MaxPositionX = 0;
- // var MiniPosiitonX = 0;
- var HeroPositionX = this._getHero.position.x;//cc.find('Hero').position.x;
- var RivelPositionX = this._getRivel.position.x;// cc.find('Rivel').position.x;
- var JavalinHero = this._getJavetempHero;//cc.find('javetemp_Hero');
- var JavalinHeroPositionX = 0;
- var JavalinRivel = this._getJavetempRivel;//cc.find('javetemp_Rivel');
- var JavalinRivelPositionX = 0;
- var arr = [];
- if (JavalinHero != null || JavalinRivel != null) {
- if (JavalinHero != null && JavalinRivel != null) {
- if (JavalinHero.isTag) {
- JavalinHeroPositionX = JavalinHero.position.x;
- arr.push(JavalinHeroPositionX);
- }
- if (JavalinRivel.isTag) {
- JavalinRivelPositionX = JavalinRivel.position.x;
- arr.push(JavalinRivelPositionX);
- }
- arr.push(HeroPositionX);
- arr.push(RivelPositionX);
- }
- else if (JavalinHero != null) {
- if (JavalinHero.isTag) {
- JavalinHeroPositionX = JavalinHero.position.x;
- arr.push(JavalinHeroPositionX);
- }
- arr.push(HeroPositionX);
- arr.push(RivelPositionX);
- }
- else if (JavalinRivel != null) {
- if (JavalinRivel.isTag) {
- JavalinRivelPositionX = JavalinRivel.position.x;
- arr.push(JavalinRivelPositionX);
- }
- arr.push(HeroPositionX);
- arr.push(RivelPositionX);
- }
- //冒泡排序 HeroPositionX RivelPositionX JavalinHeroPositionX JavalinRivelPositionX
- arr.sort(this.sortNumber);
- MaxPositionX = arr[0];
- // MiniPosiitonX = arr[arr.length - 1];
- // CustomLog("现在的数组是","max",MaxPositionX,"min",MiniPosiitonX);
- // CustomLog("现在的数组是","arr",arr.length);
- }
- else {
- if (RivelPositionX - HeroPositionX > 0) {
- MaxPositionX = RivelPositionX;
- // MiniPosiitonX = HeroPositionX;
- }
- else {
- MaxPositionX = HeroPositionX;
- // MiniPosiitonX = RivelPositionX;
- }
- }
- var csPositionX = MaxPositionX + 360;
- this.CurrentPlayerInLvIndex = Math.floor(csPositionX / 720);
- // if(this.PlayerInLvIndexLabel!=null){
- // this.PlayerInLvIndexLabel.getChildByName('label').getComponent(cc.Label).string = this.CurrentPlayerInLvIndex;//设置更前面的角色的levelIndex值,调试用。
- // }
- // cc.log(this.LastLoadedLvIndex-this.CurrentPlayerInLvIndex)
- // cc.log('x=',this.CurrentPlayerInLvIndex-this.PrePlayerInLvIndex)
- // cc.log("last is "+this.LastLoadedLvIndex+' and currentP is '+this.CurrentPlayerInLvIndex+' and PrePlayer is '+this.PrePlayerInLvIndex);
- if (this.LastLoadedLvIndex - this.CurrentPlayerInLvIndex < 2 &&
- this.CurrentPlayerInLvIndex != this.PrePlayerInLvIndex) {
- //汪汪开图
- this.addMap();
- // this.LastLoadedLvIndex++;
- // // CustomLog("这个对象",this.BgPrefabArray[this.BgPrefabArray.length-1]);
- // var LastLvPositionX = this.BgPrefabArray[this.BgPrefabArray.length - 1].position.x;
- // var NewLvPositionX = LastLvPositionX + 720;
- // CustomLog("新创建出来的 放到什么地方了",NewLvPositionX);
- // var tempArr= this.AllBgPrefabArray[this.LastLoadedLvIndex-1];
- // CustomLog("不够了",tempArr);
- // var tPrefab = cc.instantiate(tempArr);
- // // cc.log(this.AllBgPrefabArray[this.LastLoadedLvIndex].name+"======name"+this.LastLoadedLvIndex);
- // tPrefab.parent = this.node;
- // tPrefab.setAnchorPoint(0.5, 0.5);
- // tPrefab.setLocalZOrder(-this.LastLoadedLvIndex);
- // tPrefab.setPosition(NewLvPositionX, 0);
- // // this.BgPrefabArray.shift().destroy();
- // this.BgPrefabArray.push(tPrefab);
- // // cc.log(tPrefab.name+"======name");
- // if (tPrefab.name == 'JavelinDistanceMiddle') {
- // var aLabel = tPrefab.getChildByName("JavelinDistanceNUM");
- // var Labelcomp = aLabel.getComponent(cc.Label);
- // Labelcomp.string = this.JavalinDistance.toString();
- // this.JavalinDistance += 10;
- // }
- // this.AddIndexLabelToPrefab(NewLvPositionX);//此为预制体添加数字标签,正式项目可注释
- }
- this.PrePlayerInLvIndex = this.CurrentPlayerInLvIndex;
- // var MiniPlayerInIndex = Math.floor(MiniPosiitonX/720);
- //
- // // CustomLog("现在的数组是 索引",this.FrontEnableLvIndex);
- // if(MiniPlayerInIndex-this.FrontEnableLvIndex>2)
- // {
- // // cc.log('this.FrontEnableLvIndex='+this.FrontEnableLvIndex);
- // // this.BgPrefabArray.shift().destroy();
- // // CustomLog("删除东西",this.BgPrefabArray[this.FrontEnableLvIndex]);
- // this.BgPrefabArray[this.FrontEnableLvIndex].destroy();
- //
- // // cc.log(this.BgPrefabArray.length);
- // this.FrontEnableLvIndex++;
- //
- //
- // }
- },
- addMap: function () {
- var lastIndex = this.AllBgPrefabArray.length - 1 - this.LastLoadedLvIndex;
- var tempIndex = 0;
- if (lastIndex > 3) {
- tempIndex = 3;
- } else {
- tempIndex = lastIndex;
- }
- for (var i = 0; i < tempIndex; i++) {
- this.LastLoadedLvIndex++;
- // cc.log("现在匹配是多少LastLoadedLvIndex",this.LastLoadedLvIndex);
- // CustomLog("这个对象",this.BgPrefabArray[this.BgPrefabArray.length-1]);
- var LastLvPositionX = this.BgPrefabArray[this.BgPrefabArray.length - 1].position.x;
- // cc.log("现在匹配是多少LastLvPositionX",LastLvPositionX);
- var NewLvPositionX = LastLvPositionX + 720;
- // cc.log("现在匹配是多少NewLvPositionX",NewLvPositionX);
- var tPrefab = cc.instantiate(this.AllBgPrefabArray[this.LastLoadedLvIndex]);
- // cc.log(this.AllBgPrefabArray[this.LastLoadedLvIndex].name+"======name"+this.LastLoadedLvIndex+'.......'+this.HasTiped);
- // cc.log("现在要出来什么",this.CurrentPlayerInLvIndex,i,tPrefab);
- tPrefab.parent = this.node;
- tPrefab.setAnchorPoint(0.5, 0.5);
- tPrefab.setLocalZOrder(-this.LastLoadedLvIndex);
- tPrefab.setPosition(NewLvPositionX, 0);
- if (this.HasTiped == false) {
- if (this.HasGetTipPositionX == false) {
- if (tPrefab.name == 'LongAccelerationBand10ColumnTheLeftHalf1') {
- var tPrefabX = tPrefab.position.x;
- this.TipLocationX = tPrefabX;
- //cc.log(this.TipLocationX+'===============');
- this.HasGetTipPositionX = true;
- }
- }
- }
- var str = tPrefab.name;
- if (str.indexOf("StartLine") != -1) {
- var SubToStrIndex = str.length - 9;
- var StartLineName = str.substring(0, SubToStrIndex);
- var StartLinesPositionX = tPrefab.position.x + 720;
- this.SetStartLinesPositionX(StartLineName, StartLinesPositionX);
- }
- // cc.log("现在要出来什么",this.CurrentPlayerInLvIndex,i,tPrefab,NewLvPositionX);
- // this.BgPrefabArray.shift().destroy();
- this.BgPrefabArray.push(tPrefab);
- // cc.log(tPrefab.name+"===========================================================name");
- if (tPrefab.name == 'JavelinDistanceMiddle') {
- var aLabel = tPrefab.getChildByName("JavelinDistanceNUM");
- var Labelcomp = aLabel.getComponent(cc.Label);
- Labelcomp.string = this.JavalinDistance.toString();
- this.JavalinDistance += 10;
- }
- // this.AddIndexLabelToPrefab(NewLvPositionX);//此为预制体添加数字标签,正式项目可注释
- this.setStartLine(tPrefab);
- }
- },
- SetStartLinesPositionX: function (StartLineName, StartLinesPositionX) {
- // cc.log('name is '+StartLineName+' and x is '+StartLinesPositionX);
- if ('Sprint' == StartLineName) {
- this.SprintStartLinePositionX = StartLinesPositionX;
- } else if ('LongJump' == StartLineName) {
- this.LongJumpStartLinePositionX = StartLinesPositionX;
- } else if ('Hurdle' == StartLineName) {
- this.HurdleStartLinePositionX = StartLinesPositionX;
- } else if ('Javelin' == StartLineName) {
- this.JavelinStartLinePositionX = StartLinesPositionX;
- } else if ('RideBike' == StartLineName) {
- this.RideBikeStartLinePositionX = StartLinesPositionX;
- }
- },
- AddIndexLabelToPrefab: function (NewLvPositionX) {
- /** **/
- var PrefabNumLabelInstance = cc.instantiate(this.PrefabNumLabel);
- PrefabNumLabelInstance.parent = this.node;
- PrefabNumLabelInstance.setAnchorPoint(0, 0.5);
- PrefabNumLabelInstance.setLocalZOrder(1000);
- PrefabNumLabelInstance.setPosition(NewLvPositionX, 0);
- this.BgPrefabArray.push(PrefabNumLabelInstance);
- PrefabNumLabelInstance.getChildByName('MyNumLeft').getComponent(cc.Label).string = 'Left ' + this.LastLoadedLvIndex;
- PrefabNumLabelInstance.getChildByName('MyNumRight').getComponent(cc.Label).string = 'Right ' + this.LastLoadedLvIndex;
- /** **/
- },
- setP: function (tPrefab) {
- if (tPrefab.getChildByName("New Node") != null) {
- if (tPrefab.getChildByName("New Node").getComponent(cc.RigidBody) != null) {
- // CustomLog("gangti",tPrefab);
- tPrefab.getChildByName("New Node").getComponent(cc.RigidBody).syncPosition();
- }
- }
- },
- /**
- * 这个是设置 每一个 项目开头的 位置的方法
- */
- setStartLine: function (node) {
- switch (node.name) {
- case "SprintStartLine":
- case "LongJumpStartLine":
- case "HurdleStartLine":
- case "JavelinStartLine":
- case "BikeStartLine":
- this.tempStartNode = node;
- CustomLog("现在是啥啊", this.tempStartNode.name, node.x);
- break;
- }
- }
- });
|