GameMode.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. let aLib = require("Library");
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. GameStates: {
  6. default: null,
  7. type: cc.Node,
  8. serializable: true,
  9. },
  10. PlayerControllerNode: {
  11. default: null,
  12. type: cc.Node,
  13. serializable: true,
  14. },
  15. MapNode: {
  16. default: null,
  17. type: cc.Node,
  18. serializable: true,
  19. },
  20. TimeLabelNode: {
  21. default: null,
  22. type: cc.Node,
  23. serializable: true,
  24. },
  25. StartButtonNode: {
  26. default: null,
  27. type: cc.Node,
  28. serializable: true,
  29. },
  30. TenSecondChallengeBG: {
  31. default: null,
  32. type: cc.Node,
  33. serializable: true,
  34. },
  35. ReadyGo: {
  36. default: null,
  37. type: cc.Node,
  38. serializable: true,
  39. },
  40. },
  41. onLoad () {
  42. this.GameStatesScp = this.GameStates.getComponent('GameStates');
  43. this.PlayerControllerScp = this.PlayerControllerNode.getComponent('PlayerController');
  44. this.MapScp = this.MapNode.getComponent('Map');
  45. this.TimeLabelScp = this.TimeLabelNode.getComponent('CountDown');
  46. this.ReadyGoScp = this.ReadyGo.getComponent('ReadyGo');
  47. },
  48. start()
  49. {
  50. this.TimeLabelScp.InitTime(this.GameStatesScp.totalTime);
  51. },
  52. StarGame(target,param)
  53. {
  54. if(this.GameStatesScp.progress != this.GameStatesScp.progressTag.default) return;
  55. this.GameStatesScp.progress = this.GameStatesScp.progressTag.ready; //1 ready to start
  56. this.PlayerControllerScp.Reset();
  57. this.MapScp.Reset();
  58. this.TimeLabelScp.InitTime(this.GameStatesScp.totalTime);
  59. if(!this.ReadyGo.active)
  60. {
  61. this.ReadyGo.active = true;
  62. }
  63. this.ReadyGoScp.Play(function(){
  64. this.GameStatesScp.progress = this.GameStatesScp.progressTag.start;//2 start
  65. this.TimeLabelScp.CountDown(function(){
  66. this.GameStatesScp.progress = this.GameStatesScp.progressTag.result;
  67. this.GameStatesScp.PunchTimes = 0;
  68. this.StartButtonNode.active = true;
  69. this.TenSecondChallengeBG.active = true;
  70. this.scheduleOnce(function(){
  71. this.GameStatesScp.progress = this.GameStatesScp.progressTag.default;
  72. }.bind(this),1);
  73. }.bind(this));
  74. }.bind(this));
  75. this.StartButtonNode.active = false;
  76. this.TenSecondChallengeBG.active = false;
  77. }
  78. });