GameConfig.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. BDebug: {
  5. default: true,
  6. serializable: true,
  7. },
  8. },
  9. onLoad () {
  10. this.Host = 'https://www.9527fun.cn/Idol/';
  11. this.ActionPower = 0;
  12. this.Golden = 0;
  13. this.Diamond = 0;
  14. this.Fans=0;
  15. this.FavorableImpression=0;
  16. //Course
  17. this.TalentTotalTime = 0;
  18. this.MakeUpTotalTime = 0;
  19. this.EloquenceTotalTime = 0;
  20. this.FashionTotalTime = 0;
  21. this.DanceTotalTime = 0;
  22. //Event
  23. this.VarietyShowTotalTime = 0;
  24. this.InterviewTotalTime = 0;
  25. this.MovieTotalTime = 0;
  26. this.HangOutTotalTime = 0;
  27. this.GirlAnimations = ['Idle'];
  28. },
  29. GetGameConfig(CallBack)
  30. {
  31. let URL = this.Host+'GameConfig/GetGameConfig';
  32. let XHR = new XMLHttpRequest();
  33. XHR.onreadystatechange = function () {
  34. if (XHR.readyState == 4 && (XHR.status >= 200 && XHR.status < 400)) {
  35. let response = XHR.responseText;
  36. // console.log(response);
  37. let ResultJson = JSON.parse(response);
  38. // console.log(ResultJson);
  39. // Game
  40. let GameConfig = ResultJson.GameConfig;
  41. // console.log(GameConfig);
  42. this.ActionPower = GameConfig.ActionPower;
  43. this.Coin = GameConfig.Coin;
  44. this.Diamond = GameConfig.Diamond;
  45. this.Fans=GameConfig.Fans;
  46. this.FavorableImpression=GameConfig.FavorableImpression;
  47. // Course
  48. let CourseConfig = ResultJson.CourseConfig;
  49. // console.log(CourseConfig);
  50. this.TalentTotalTime = CourseConfig.TalentTotalTime;
  51. this.MakeUpTotalTime = CourseConfig.MakeUpTotalTime;
  52. this.EloquenceTotalTime = CourseConfig.EloquenceTotalTime;
  53. this.FashionTotalTime = CourseConfig.FashionTotalTime;
  54. this.DanceTotalTime = CourseConfig.DanceTotalTime;
  55. //Event
  56. let EventConfig = ResultJson.EventConfig;
  57. this.VarietyShowTotalTime = EventConfig.VarietyShowTotalTime;
  58. this.InterviewTotalTime = EventConfig.InterviewTotalTime;
  59. this.MovieTotalTime = EventConfig.MovieTotalTime;
  60. this.HangOutTotalTime = EventConfig.HangOutTotalTime;
  61. CallBack();
  62. }
  63. }.bind(this);
  64. XHR.open("GET", URL, true);
  65. XHR.setRequestHeader("Content-Type" , "application/json");
  66. XHR.send();
  67. }
  68. });