SuperFindPanel.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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(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. }
  44. init()
  45. {
  46. this.refreshInfo()
  47. this.countDownLabel.string = this._gameTime.toString()+"秒"
  48. let bgPath = SuperFind.superFindData.imgPath
  49. let selectSkins:string[] = Skin.getSelectSkinPath()
  50. selectSkins = selectSkins.length > 0?selectSkins:[defaultSkin]
  51. this.lvlContainer.genLvlContent(bgPath,selectSkins,Difficulty.difficutyData.difficutyCount,Difficulty.difficutyData.scales)
  52. }
  53. OpenselDifPanel() {
  54. this.selDifPanel.node.active = true;
  55. this.selDifPanel.init();
  56. }
  57. OpenSelSkinPanel() {
  58. this.selSkinPanel.node.active = true;
  59. this.selSkinPanel.init();
  60. }
  61. OpenSelSkinPanel2() {
  62. this.selSkinPanel2.node.active = true;
  63. this.selSkinPanel2.init();
  64. }
  65. OpenSelMapPanel() {
  66. this.selMapPanel.node.active = true;
  67. this.selMapPanel.init();
  68. }
  69. OpenEditBtns()
  70. {
  71. this.editBtns.active = true
  72. this.lvlContainer.swtichEditMode(true)
  73. this.noEditBtns.active = false
  74. }
  75. CloseEditBtns()
  76. {
  77. this.editBtns.active = false
  78. this.lvlContainer.swtichEditMode(false)
  79. this.noEditBtns.active = true
  80. }
  81. CloseSelDifPanel() {
  82. this.selDifPanel.node.active = false;
  83. }
  84. CloseSelSkinPanel() {
  85. this.selSkinPanel.node.active = false;
  86. }
  87. CloseSelMapPanel() {
  88. this.selMapPanel.node.active = false;
  89. }
  90. close()
  91. {
  92. this.node.destroy()
  93. }
  94. onEditFinishClick()
  95. {
  96. this.CloseEditBtns()
  97. }
  98. onRegenerateClick()
  99. {
  100. this.lvlContainer.updateLevel()
  101. }
  102. onHideClick()
  103. {
  104. this.bottom.active = false
  105. this.bottom2.active = true
  106. }
  107. onTipClick()
  108. {
  109. this.lvlContainer.showOneHint()
  110. }
  111. refreshInfo()
  112. {
  113. this.tipLabel.string = SuperFind.superFindData.title
  114. this.tipLabel2.string = SuperFind.superFindData.levelDesc
  115. }
  116. showOrHideScale()
  117. {
  118. this._showScale = !this._showScale
  119. this.lvlContainer.showOrHideScale(this._showScale)
  120. this.showOrHideScaleLabel.string = this._showScale?"隐藏缩放":"显示缩放"
  121. }
  122. countDown() {
  123. this._gameTime--
  124. if (this._gameTime <= 0) {
  125. this.unschedule(this.countDown)
  126. this.countDownLabel.string = "0秒"
  127. return
  128. }
  129. this.countDownLabel.string = this._gameTime.toString() + "秒"
  130. }
  131. restartCountDown()
  132. {
  133. this._gameTime = 600
  134. this.countDownLabel.string = this._gameTime.toString()+"秒"
  135. this.unschedule(this.countDown)
  136. this.schedule(this.countDown,1)
  137. }
  138. }