CurrentCompanyMax.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. var cityList = require('../data/city');
  2. const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
  3. const CityApi = require('../net/CityMapApi');
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. shining: cc.Node,
  8. nextButton: cc.Node,
  9. nextText: cc.RichText,
  10. },
  11. onLoad() {
  12. this.shining.setScale(0);
  13. let self = this;
  14. let finish = cc.callFunc(() => {
  15. self.shining.runAction(cc.rotateBy(0.8, 100, 100).repeatForever());
  16. }, this);
  17. let scale = cc.sequence(cc.spawn(cc.scaleTo(0.4, 1, 1).easing(cc.easeBackIn()), cc.rotateBy(0.4, 100, 100)), finish);
  18. this.shining.runAction(scale);
  19. let nextCityId = Global.devCityId + 1;
  20. if (nextCityId <= cityList.length) {
  21. this.nextText.string = '<outline color=#1d8610><b>开办新的分公司</b></outline>\n<color=#1d8610><b>下一个城市</b></color>';
  22. } else {
  23. this.nextText.string = '<outline color=#1d8610><b>到达财富的顶端</b>\n</outline><color=#1d8610><b>敬请期待</b></color>';
  24. }
  25. GameEvent.on('next_city_click', this, () => {
  26. let nextCityId = Global.devCityId + 1;
  27. if (nextCityId <= cityList.length) {
  28. CityApi.openNewCity(
  29. (response) => {
  30. Global.devCityId = nextCityId;
  31. GameEvent.fire(GameNotificationKey.ShowCityMap, this, true);
  32. },
  33. (code, msg) => {
  34. console.log(msg);
  35. });
  36. }
  37. this.node.destroy();
  38. });
  39. },
  40. start() {
  41. },
  42. close() {
  43. },
  44. nextCity: _.debounce(() => {
  45. GameEvent.fire('next_city_click');
  46. }, 1000, true),
  47. // update (dt) {},
  48. onDestroy() {
  49. GameEvent.off('next_city_click', this);
  50. }
  51. });