TopMenu.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { AudioMgr, GameViewType } from "../../main/ViewManage";
  2. import ViewObject from "../../main/ViewObject";
  3. import { ReveData } from "../../util/CHttp";
  4. import RedPoint from "../data/RedPoint";
  5. import Home from "./Home";
  6. import ShopView from "./shop/ShopView";
  7. const { ccclass, property } = cc._decorator;
  8. @ccclass
  9. export default class TopMenu extends ViewObject {
  10. @property(cc.Label)
  11. lbPower: cc.Label = null;
  12. @property(cc.Label)
  13. lbCoin: cc.Label = null;
  14. @property(cc.Label)
  15. lbDiamond: cc.Label = null;
  16. @property(cc.Node)
  17. mEmailNode: cc.Node = null;
  18. home: Home = null;
  19. onEnable() {
  20. this.refresh();
  21. }
  22. refresh() {
  23. let role = this.main.player.role;
  24. this.lbCoin.string = '' + role.money;
  25. this.lbDiamond.string = '' + role.gold;
  26. this.lbPower.string = role.power + '/30';
  27. }
  28. forbidBtn(value: boolean) {
  29. this.lbCoin.node.parent.getComponent(cc.Button).interactable = value;
  30. this.lbDiamond.node.parent.getComponent(cc.Button).interactable = value;
  31. this.lbPower.node.parent.getComponent(cc.Button).interactable = value;
  32. }
  33. /**
  34. * 设置
  35. */
  36. public onclickSet() {
  37. this.main.playerEffectByPath(AudioMgr.click);
  38. this.main.viewManage.loadFunc(GameViewType.tap_set, (viewObject: ViewObject) => {
  39. viewObject.show();
  40. });
  41. }
  42. /**
  43. * 商城
  44. */
  45. public openShop(eventTouch: cc.Event.EventTouch, data: string) {
  46. this.main.playerEffectByPath(AudioMgr.click);
  47. this.main.startLoad();
  48. this.main.viewManage.loadFunc(GameViewType.tap_shop, (viewObject: ViewObject) => {
  49. let shopView = viewObject as ShopView;
  50. shopView.init(Number(data));
  51. shopView.show();
  52. });
  53. }
  54. /**
  55. * 邮件
  56. */
  57. public onclickMail() {
  58. this.main.playerEffectByPath(AudioMgr.click);
  59. this.main.startLoad();
  60. RedPoint.removeRed(this.mEmailNode);
  61. this.main.viewManage.loadFunc(GameViewType.email, (viewObject: ViewObject) => {
  62. viewObject.show();
  63. });
  64. }
  65. }