SuperFindPanel.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import { _decorator, Component, Label, Node, Prefab } from 'cc';
  2. import { SelectDifficultyPanel } from './SelectDifficultyPanel';
  3. import { SelectSkinPanel } from './SelectSkinPanel';
  4. import { SelectMapPanel } from './SelectMapPanel';
  5. import { LevelContainer } from './LevelContainer';
  6. import { defaultSkin, Difficulty, Skin, SuperFind} from '../../script/Manager/LocalDataMgr';
  7. import EventMgr from '../../script/Manager/EventMgr';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('SuperFindPanel')
  10. export class SuperFindPanel extends Component {
  11. @property(SelectDifficultyPanel)
  12. selDifPanel: SelectDifficultyPanel = null
  13. @property(SelectSkinPanel)
  14. selSkinPanel: SelectSkinPanel = null
  15. @property(SelectMapPanel)
  16. selMapPanel: SelectMapPanel = null
  17. @property(LevelContainer)
  18. lvlContainer: LevelContainer = null
  19. @property(Node)
  20. editBtns:Node = null
  21. @property(Node)
  22. noEditBtns:Node = null
  23. @property(Label)
  24. tipLabel: Label = null
  25. @property(Label)
  26. tipLabel2: Label = null
  27. @property(Label)
  28. showOrHideScaleLabel: Label = null
  29. @property(Label)
  30. countDownLabel: Label = null
  31. @property(Node)
  32. bottom: Node = null
  33. _showScale:boolean = false
  34. _gameTime:number = 600
  35. protected start(): void {
  36. this.init()
  37. EventMgr.ins.addEventListener("refreshLevelInfo",this.refreshInfo,this)
  38. this.restartCountDown()
  39. }
  40. init()
  41. {
  42. this.refreshInfo()
  43. this.countDownLabel.string = this._gameTime.toString()+"秒"
  44. let bgPath = SuperFind.superFindData.imgPath
  45. let selectSkins:string[] = Skin.getSelectSkinPath()
  46. selectSkins = selectSkins.length > 0?selectSkins:[defaultSkin]
  47. this.lvlContainer.genLvlContent(bgPath,selectSkins,Difficulty.difficutyData.difficutyCount,Difficulty.difficutyData.scales)
  48. }
  49. OpenselDifPanel() {
  50. this.selDifPanel.node.active = true;
  51. this.selDifPanel.init();
  52. }
  53. OpenSelSkinPanel() {
  54. this.selSkinPanel.node.active = true;
  55. this.selSkinPanel.init();
  56. }
  57. OpenSelMapPanel() {
  58. this.selMapPanel.node.active = true;
  59. this.selMapPanel.init();
  60. }
  61. OpenEditBtns()
  62. {
  63. this.editBtns.active = true
  64. this.lvlContainer.swtichEditMode(true)
  65. this.noEditBtns.active = false
  66. }
  67. CloseEditBtns()
  68. {
  69. this.editBtns.active = false
  70. this.lvlContainer.swtichEditMode(false)
  71. this.noEditBtns.active = true
  72. }
  73. CloseSelDifPanel() {
  74. this.selDifPanel.node.active = false;
  75. }
  76. CloseSelSkinPanel() {
  77. this.selSkinPanel.node.active = false;
  78. }
  79. CloseSelMapPanel() {
  80. this.selMapPanel.node.active = false;
  81. }
  82. close()
  83. {
  84. this.node.destroy()
  85. }
  86. onEditFinishClick()
  87. {
  88. this.CloseEditBtns()
  89. }
  90. onRegenerateClick()
  91. {
  92. this.lvlContainer.updateLevel()
  93. }
  94. onHideClick()
  95. {
  96. this.bottom.active = false
  97. }
  98. onTipClick()
  99. {
  100. this.lvlContainer.showOneHint()
  101. }
  102. refreshInfo()
  103. {
  104. this.tipLabel.string = SuperFind.superFindData.title
  105. this.tipLabel2.string = SuperFind.superFindData.levelDesc
  106. }
  107. showOrHideScale()
  108. {
  109. this._showScale = !this._showScale
  110. this.lvlContainer.showOrHideScale(this._showScale)
  111. this.showOrHideScaleLabel.string = this._showScale?"隐藏缩放":"显示缩放"
  112. }
  113. countDown() {
  114. this._gameTime--
  115. if (this._gameTime <= 0) {
  116. this.unschedule(this.countDown)
  117. this.countDownLabel.string = "0秒"
  118. return
  119. }
  120. this.countDownLabel.string = this._gameTime.toString() + "秒"
  121. }
  122. restartCountDown()
  123. {
  124. this._gameTime = 600
  125. this.countDownLabel.string = this._gameTime.toString()+"秒"
  126. this.unschedule(this.countDown)
  127. this.schedule(this.countDown,1)
  128. }
  129. }