GameStates.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. const GameProgress = cc.Enum ({
  2. default:0,
  3. Race:1,
  4. LongJump:2,
  5. Hurdle:3,
  6. RideBike:4,
  7. Javelin:5,
  8. });
  9. cc.Class({
  10. extends: cc.Component,
  11. properties: {
  12. CurrentTime:0,
  13. CurrentProgress: {
  14. default : GameProgress.Race,
  15. type : cc.Enum(GameProgress)
  16. },
  17. HostName:'',
  18. BWaitingToConnect:false,
  19. bConnect:false,
  20. bReadyToRun:false,
  21. BStartGame:false,
  22. myRandomc : [],
  23. EnterStartLinePlayersArray:[],
  24. EnterFinishLinePlayersArray:[],
  25. EndLinePositionX:0,
  26. StartLinePositionX:0,
  27. ReadyToRunDuration:2,
  28. bPreTransport:false,
  29. bStopAllAnimationAndSchedule:false,
  30. bSyncPositionXRange:20,
  31. strCureentLevel:'Sprint',
  32. //是不是机器人
  33. isRobot:false,
  34. startTime:0,
  35. endTime:0,
  36. playTime:0,
  37. dtTime:0,
  38. textNode:null,
  39. bHasStartGame:false,
  40. bHasEndGame:false,
  41. uploadValue:0,//记录当前上传的值
  42. //slam todo
  43. getHero:null,
  44. getRivel:null,
  45. getHeroControl:null,
  46. getRivelControl:null,
  47. getLevel:null,
  48. getLevelControl:null,
  49. },
  50. onLoad(){
  51. this.getHero = cc.find('Hero');
  52. this.getRivel = cc.find('Rivel');
  53. this.getHeroControl = this.getHero.getComponent("HeroControl");
  54. this.getRivelControl = this.getRivel.getComponent("HeroControl");
  55. this.getLevel = cc.find("Level");
  56. this.getLevelControl = this.getLevel.getComponent('LevelControl');
  57. },
  58. start () {
  59. this.bConnect=false;
  60. this.bReadyToRun=false;
  61. this.myRandomc = [];
  62. this.StartLinePositionX = 0;
  63. this.bStopAllAnimationAndSchedule = false;
  64. this.isRobot = false;
  65. this.textNode = cc.find('test').getComponent(cc.Label);
  66. },
  67. update : function (dt) {
  68. if(this.bHasStartGame && !this.bHasEndGame){
  69. this.dtTime += dt;
  70. }
  71. // cc.log('CurrentProgress='+this.CurrentProgress);
  72. // this.textNode.string = Math.floor(this.dtTime*1000).toString();
  73. // cc.log(this.dtTime);
  74. },
  75. getMyRandomc : function () {
  76. return this.myRandomc;
  77. }
  78. });
  79. var myRandomcs = {
  80. myRandomc : []
  81. }
  82. module.exports = {
  83. GameProgress : cc.Enum(GameProgress),
  84. myRandomc :myRandomcs.myRandomc
  85. };