BaseGameStates.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. },
  5. onLoad() {
  6. this.restTime = 12;
  7. this.currentTime = 0;
  8. this.player_name = "";
  9. this.player_gold = 10000;
  10. this.player_energy = 10001;
  11. this.player_sex = 0;
  12. this.game_time = 720; //战斗时间
  13. },
  14. start() {
  15. },
  16. update(dt) {
  17. },
  18. InformationChanges(state, indel, info) {
  19. if (state == "set") {
  20. if (indel == 0) {
  21. this.player_name = info;
  22. }
  23. if (indel == 1) {
  24. this.player_gold = info;
  25. }
  26. if (indel == 2) {
  27. this.player_energy = info;
  28. }
  29. if (indel == 3) {
  30. this.player_sex = info;
  31. }
  32. } else if (state == "get") {
  33. if (indel == 0) {
  34. return this.player_name;
  35. }
  36. if (indel == 1) {
  37. return this.player_gold;
  38. }
  39. if (indel == 2) {
  40. return this.player_energy;
  41. }
  42. if (indel == 3) {
  43. return this.player_sex;
  44. }
  45. }
  46. },
  47. //时间减少
  48. countdown(currentTime) {
  49. currentTime--;
  50. if (currentTime <= 0) {
  51. currentTime = 0;
  52. }
  53. return currentTime;
  54. },
  55. });