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. },
  13. start() {
  14. },
  15. update(dt) {
  16. },
  17. InformationChanges(state, indel, info) {
  18. if (state == "set") {
  19. if (indel == 0) {
  20. this.player_name = info;
  21. }
  22. if (indel == 1) {
  23. this.player_gold = info;
  24. }
  25. if (indel == 2) {
  26. this.player_energy = info;
  27. }
  28. if (indel == 3) {
  29. this.player_sex = info;
  30. }
  31. } else if (state == "get") {
  32. if (indel == 0) {
  33. return this.player_name;
  34. }
  35. if (indel == 1) {
  36. return this.player_gold;
  37. }
  38. if (indel == 2) {
  39. return this.player_energy;
  40. }
  41. if (indel == 3) {
  42. return this.player_sex;
  43. }
  44. }
  45. },
  46. //时间减少
  47. countdown(currentTime) {
  48. currentTime--;
  49. if (currentTime <= 0) {
  50. currentTime = 0;
  51. }
  52. return currentTime;
  53. },
  54. });