SuperFindPanel.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 { clearSuperFindAllData, defaultSkin, Difficulty, LocalDataMgr, Skin, SuperFind} from '../../script/Manager/LocalDataMgr';
  7. import EventMgr from '../../script/Manager/EventMgr';
  8. import { AddCountPanel } from './AddCountPanel';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('SuperFindPanel')
  11. export class SuperFindPanel extends Component {
  12. @property(SelectDifficultyPanel)
  13. selDifPanel: SelectDifficultyPanel = null
  14. @property(SelectSkinPanel)
  15. selSkinPanel: SelectSkinPanel = null
  16. @property(SelectSkinPanel)
  17. selSkinPanel2: SelectSkinPanel = null
  18. @property(SelectMapPanel)
  19. selMapPanel: SelectMapPanel = null
  20. @property(LevelContainer)
  21. lvlContainer: LevelContainer = null
  22. @property(AddCountPanel)
  23. addCountPanel:AddCountPanel = null
  24. @property(Node)
  25. win:Node = null
  26. @property(Node)
  27. lose:Node = null
  28. @property(Node)
  29. editBtns:Node = null
  30. @property(Node)
  31. noEditBtns:Node = null
  32. @property(Label)
  33. tipLabel: Label = null
  34. @property(Label)
  35. tipLabel2: Label = null
  36. @property(Label)
  37. showOrHideScaleLabel: Label = null
  38. @property(Label)
  39. countDownLabel: Label = null
  40. @property(Node)
  41. showGmBtn:Node = null
  42. @property(Node)
  43. bottom: Node = null
  44. @property(Node)
  45. bottom2: Node = null
  46. _showScale:boolean = false
  47. _gameTime:number = 600
  48. protected start(): void {
  49. this.init()
  50. EventMgr.ins.addEventListener("refreshLevelInfo",this.refreshInfo,this)
  51. EventMgr.ins.addEventListener("restart",this.restartCountDown,this)
  52. EventMgr.ins.addEventListener("win",this.OpenWin,this)
  53. this.restartCountDown()
  54. if(sys.platform == sys.Platform.BYTEDANCE_MINI_GAME)
  55. {
  56. this.bottom.active = false
  57. this.bottom2.active = true
  58. }
  59. }
  60. init()
  61. {
  62. this.refreshInfo()
  63. this.countDownLabel.string = this._gameTime.toString()+"秒"
  64. let bgPath = SuperFind.superFindData.imgPath
  65. let selectSkins:string[] = Skin.getSelectSkinPath()
  66. selectSkins = selectSkins.length > 0?selectSkins:[defaultSkin]
  67. this.lvlContainer.genLvlContent(bgPath,selectSkins,Difficulty.difficutyData.difficutyCount,Difficulty.difficutyData.scales)
  68. }
  69. OpenselDifPanel() {
  70. this.selDifPanel.node.active = true;
  71. this.selDifPanel.init();
  72. }
  73. OpenSelSkinPanel() {
  74. this.selSkinPanel.node.active = true;
  75. this.selSkinPanel.init();
  76. }
  77. OpenSelSkinPanel2() {
  78. this.selSkinPanel2.node.active = true;
  79. this.selSkinPanel2.init();
  80. }
  81. OpenSelMapPanel() {
  82. this.selMapPanel.node.active = true;
  83. this.selMapPanel.init();
  84. }
  85. OpenEditBtns()
  86. {
  87. this.editBtns.active = true
  88. this.lvlContainer.swtichEditMode(true)
  89. this.noEditBtns.active = false
  90. }
  91. OpenAddCountPanel()
  92. {
  93. this.addCountPanel.node.active = true
  94. }
  95. OpenWin()
  96. {
  97. this.win.active = true
  98. }
  99. OpenLose()
  100. {
  101. this.lose.active = true
  102. }
  103. CloseWin()
  104. {
  105. this.win.active = false
  106. }
  107. CloseLose()
  108. {
  109. this.lose.active = false
  110. }
  111. CloseAddCountPanel()
  112. {
  113. this.addCountPanel.node.active = false
  114. }
  115. CloseEditBtns()
  116. {
  117. this.editBtns.active = false
  118. this.lvlContainer.swtichEditMode(false)
  119. this.noEditBtns.active = true
  120. }
  121. CloseSelDifPanel() {
  122. this.selDifPanel.node.active = false;
  123. }
  124. CloseSelSkinPanel() {
  125. this.selSkinPanel.node.active = false;
  126. }
  127. CloseSelMapPanel() {
  128. this.selMapPanel.node.active = false;
  129. }
  130. close()
  131. {
  132. this.node.destroy()
  133. EventMgr.ins.dispatchEvent("show_gm_btn")
  134. }
  135. onEditFinishClick()
  136. {
  137. this.CloseEditBtns()
  138. }
  139. onRegenerateClick()
  140. {
  141. this.lvlContainer.updateLevel()
  142. }
  143. onHideClick()
  144. {
  145. this.bottom.active = false
  146. this.bottom2.active = true
  147. this.showGmBtn.active = true
  148. }
  149. onShowGmClick()
  150. {
  151. this.bottom.active = true
  152. this.bottom2.active = false
  153. this.showGmBtn.active = false
  154. }
  155. onTipClick()
  156. {
  157. this.lvlContainer.showOneHint()
  158. }
  159. refreshInfo()
  160. {
  161. this.tipLabel.string = SuperFind.superFindData.title
  162. this.tipLabel2.string = SuperFind.superFindData.levelDesc
  163. }
  164. showOrHideScale()
  165. {
  166. this._showScale = !this._showScale
  167. this.lvlContainer.showOrHideScale(this._showScale)
  168. this.showOrHideScaleLabel.string = this._showScale?"隐藏缩放":"显示缩放"
  169. }
  170. countDown() {
  171. this._gameTime--
  172. if (this._gameTime <= 0) {
  173. this.unschedule(this.countDown)
  174. this.countDownLabel.string = "0秒"
  175. this.OpenLose()
  176. return
  177. }
  178. this.countDownLabel.string = this._gameTime.toString() + "秒"
  179. }
  180. restartCountDown()
  181. {
  182. this._gameTime = 600
  183. this.countDownLabel.string = this._gameTime.toString()+"秒"
  184. this.unschedule(this.countDown)
  185. this.schedule(this.countDown,1)
  186. }
  187. }