level_mgr.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const { ccclass, property } = cc._decorator;
  2. import game_constants from "./game_constants";
  3. import global_model from "./global_model";
  4. import level_item from "./level_item"
  5. @ccclass
  6. export default class NewClass extends cc.Component {
  7. @property(cc.Node)
  8. page1: cc.Node = null;
  9. @property(cc.Node)
  10. page2: cc.Node = null;
  11. @property(cc.Node)
  12. page3: cc.Node = null;
  13. @property(cc.Node)
  14. page4: cc.Node = null;
  15. // @property(cc.Node)
  16. // page5: cc.Node = null;
  17. // @property(cc.Node)
  18. // page6: cc.Node = null;
  19. AllLvItems: level_item[] = []
  20. onLoad() {
  21. this.page1.children.forEach(v => {
  22. this.AllLvItems.push(v.getComponent(level_item))
  23. })
  24. this.page2.children.forEach(v => {
  25. this.AllLvItems.push(v.getComponent(level_item))
  26. })
  27. this.page3.children.forEach(v => {
  28. this.AllLvItems.push(v.getComponent(level_item))
  29. })
  30. this.page4.children.forEach(v => {
  31. this.AllLvItems.push(v.getComponent(level_item))
  32. })
  33. // this.page5.children.forEach(v => {
  34. // this.AllLvItems.push(v.getComponent(level_item))
  35. // })
  36. // this.page6.children.forEach(v => {
  37. // this.AllLvItems.push(v.getComponent(level_item))
  38. // })
  39. let currentLv = global_model.game.level
  40. this.AllLvItems.forEach((v, idx) => {
  41. v.initLevelItem(idx + 1, idx + 1 == currentLv, idx + 1 > currentLv)
  42. })
  43. cc.systemEvent.on(game_constants.select_level_clicked, this.closeLvView, this)
  44. }
  45. closeLvView() {
  46. this.node.active = false
  47. }
  48. // update (dt) {}
  49. }