level_mgr.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. {
  22. this.page1.children.forEach(v=>
  23. {
  24. this.AllLvItems.push(v.getComponent(level_item))
  25. })
  26. this.page2.children.forEach(v=>
  27. {
  28. this.AllLvItems.push(v.getComponent(level_item))
  29. })
  30. this.page3.children.forEach(v=>
  31. {
  32. this.AllLvItems.push(v.getComponent(level_item))
  33. })
  34. this.page4.children.forEach(v=>
  35. {
  36. this.AllLvItems.push(v.getComponent(level_item))
  37. })
  38. this.page5.children.forEach(v=>
  39. {
  40. this.AllLvItems.push(v.getComponent(level_item))
  41. })
  42. this.page6.children.forEach(v=>
  43. {
  44. this.AllLvItems.push(v.getComponent(level_item))
  45. })
  46. let currentLv=global_model.game.level
  47. this.AllLvItems.forEach((v,idx)=>{
  48. v.initLevelItem(idx+1,idx+1 == currentLv ,idx+1>currentLv)
  49. })
  50. cc.systemEvent.on(game_constants.select_level_clicked,this.closeLvView,this)
  51. }
  52. closeLvView()
  53. {
  54. this.node.active=false
  55. }
  56. // update (dt) {}
  57. }