SuperFindPanel.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. 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. bottom: Node = null
  42. @property(Node)
  43. bottom2: Node = null
  44. _showScale:boolean = false
  45. _gameTime:number = 600
  46. protected start(): void {
  47. this.init()
  48. EventMgr.ins.addEventListener("refreshLevelInfo",this.refreshInfo,this)
  49. EventMgr.ins.addEventListener("restart",this.restartCountDown,this)
  50. EventMgr.ins.addEventListener("win",this.OpenWin,this)
  51. this.restartCountDown()
  52. if(sys.platform == sys.Platform.BYTEDANCE_MINI_GAME)
  53. {
  54. this.bottom.active = false
  55. this.bottom2.active = true
  56. }
  57. }
  58. init()
  59. {
  60. this.refreshInfo()
  61. this.countDownLabel.string = this._gameTime.toString()+"秒"
  62. let bgPath = SuperFind.superFindData.imgPath
  63. let selectSkins:string[] = Skin.getSelectSkinPath()
  64. selectSkins = selectSkins.length > 0?selectSkins:[defaultSkin]
  65. this.lvlContainer.genLvlContent(bgPath,selectSkins,Difficulty.difficutyData.difficutyCount,Difficulty.difficutyData.scales)
  66. }
  67. OpenselDifPanel() {
  68. this.selDifPanel.node.active = true;
  69. this.selDifPanel.init();
  70. }
  71. OpenSelSkinPanel() {
  72. this.selSkinPanel.node.active = true;
  73. this.selSkinPanel.init();
  74. }
  75. OpenSelSkinPanel2() {
  76. this.selSkinPanel2.node.active = true;
  77. this.selSkinPanel2.init();
  78. }
  79. OpenSelMapPanel() {
  80. this.selMapPanel.node.active = true;
  81. this.selMapPanel.init();
  82. }
  83. OpenEditBtns()
  84. {
  85. this.editBtns.active = true
  86. this.lvlContainer.swtichEditMode(true)
  87. this.noEditBtns.active = false
  88. }
  89. OpenAddCountPanel()
  90. {
  91. this.addCountPanel.node.active = true
  92. }
  93. OpenWin()
  94. {
  95. this.win.active = true
  96. }
  97. OpenLose()
  98. {
  99. this.lose.active = true
  100. }
  101. CloseWin()
  102. {
  103. this.win.active = false
  104. }
  105. CloseLose()
  106. {
  107. this.lose.active = false
  108. }
  109. CloseAddCountPanel()
  110. {
  111. this.addCountPanel.node.active = false
  112. }
  113. CloseEditBtns()
  114. {
  115. this.editBtns.active = false
  116. this.lvlContainer.swtichEditMode(false)
  117. this.noEditBtns.active = true
  118. }
  119. CloseSelDifPanel() {
  120. this.selDifPanel.node.active = false;
  121. }
  122. CloseSelSkinPanel() {
  123. this.selSkinPanel.node.active = false;
  124. }
  125. CloseSelMapPanel() {
  126. this.selMapPanel.node.active = false;
  127. }
  128. close()
  129. {
  130. this.node.destroy()
  131. }
  132. onEditFinishClick()
  133. {
  134. this.CloseEditBtns()
  135. }
  136. onRegenerateClick()
  137. {
  138. this.lvlContainer.updateLevel()
  139. }
  140. onHideClick()
  141. {
  142. this.bottom.active = false
  143. this.bottom2.active = true
  144. }
  145. onTipClick()
  146. {
  147. this.lvlContainer.showOneHint()
  148. }
  149. refreshInfo()
  150. {
  151. this.tipLabel.string = SuperFind.superFindData.title
  152. this.tipLabel2.string = SuperFind.superFindData.levelDesc
  153. }
  154. showOrHideScale()
  155. {
  156. this._showScale = !this._showScale
  157. this.lvlContainer.showOrHideScale(this._showScale)
  158. this.showOrHideScaleLabel.string = this._showScale?"隐藏缩放":"显示缩放"
  159. }
  160. countDown() {
  161. this._gameTime--
  162. if (this._gameTime <= 0) {
  163. this.unschedule(this.countDown)
  164. this.countDownLabel.string = "0秒"
  165. this.OpenLose()
  166. return
  167. }
  168. this.countDownLabel.string = this._gameTime.toString() + "秒"
  169. }
  170. restartCountDown()
  171. {
  172. this._gameTime = 600
  173. this.countDownLabel.string = this._gameTime.toString()+"秒"
  174. this.unschedule(this.countDown)
  175. this.schedule(this.countDown,1)
  176. }
  177. }