SuperFindPanel.ts 4.3 KB

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