BaseGameStates.js 1.3 KB

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