SuperFindPanel.ts 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. import { mainscene } from '../../script/mainscene';
  10. import PlatformService from '../../script/Platform/PlatformService';
  11. const { ccclass, property } = _decorator;
  12. @ccclass('SuperFindPanel')
  13. export class SuperFindPanel extends Component {
  14. @property(SelectDifficultyPanel)
  15. selDifPanel: SelectDifficultyPanel = null
  16. @property(SelectSkinPanel)
  17. selSkinPanel: SelectSkinPanel = null
  18. @property(SelectSkinPanel)
  19. selSkinPanel2: SelectSkinPanel = null
  20. @property(SelectMapPanel)
  21. selMapPanel: SelectMapPanel = null
  22. @property(LevelContainer)
  23. lvlContainer: LevelContainer = null
  24. @property(AddCountPanel)
  25. addCountPanel:AddCountPanel = null
  26. @property(Node)
  27. win:Node = null
  28. @property(Node)
  29. lose:Node = null
  30. @property(Node)
  31. editBtns:Node = null
  32. @property(Node)
  33. noEditBtns:Node = null
  34. @property(Label)
  35. tipLabel: Label = null
  36. @property(Label)
  37. tipLabel2: Label = null
  38. @property(Label)
  39. showOrHideScaleLabel: Label = null
  40. @property(Label)
  41. countDownLabel: Label = null
  42. @property(Node)
  43. showGmBtn:Node = null
  44. @property(Node)
  45. bottom: Node = null
  46. @property(Node)
  47. bottom2: Node = null
  48. _showScale:boolean = false
  49. _gameTime:number = 600
  50. protected start(): void {
  51. this.init()
  52. EventMgr.ins.addEventListener("refreshLevelInfo",this.refreshInfo,this)
  53. EventMgr.ins.addEventListener("restart",this.restartCountDown,this)
  54. EventMgr.ins.addEventListener("win",this.OpenWin,this)
  55. this.restartCountDown()
  56. if(sys.platform == sys.Platform.BYTEDANCE_MINI_GAME)
  57. {
  58. this.bottom.active = false
  59. this.bottom2.active = true
  60. }
  61. }
  62. init()
  63. {
  64. this.refreshInfo()
  65. this.countDownLabel.string = this._gameTime.toString()+"秒"
  66. let bgPath = SuperFind.superFindData.imgPath
  67. let selectSkins:string[] = Skin.getSelectSkinPath()
  68. selectSkins = selectSkins.length > 0?selectSkins:[defaultSkin]
  69. this.lvlContainer.genLvlContent(bgPath,selectSkins,Difficulty.difficutyData.difficutyCount,Difficulty.difficutyData.scales)
  70. }
  71. OpenselDifPanel() {
  72. this.selDifPanel.node.active = true;
  73. this.selDifPanel.init();
  74. }
  75. OpenSelSkinPanel() {
  76. this.selSkinPanel.node.active = true;
  77. this.selSkinPanel.init();
  78. }
  79. OpenSelSkinPanel2() {
  80. this.selSkinPanel2.node.active = true;
  81. this.selSkinPanel2.init();
  82. }
  83. OpenSelMapPanel() {
  84. this.selMapPanel.node.active = true;
  85. this.selMapPanel.init();
  86. }
  87. OpenEditBtns()
  88. {
  89. this.editBtns.active = true
  90. this.lvlContainer.swtichEditMode(true)
  91. this.noEditBtns.active = false
  92. }
  93. OpenAddCountPanel()
  94. {
  95. this.addCountPanel.node.active = true
  96. }
  97. OpenWin()
  98. {
  99. this.win.active = true
  100. }
  101. OpenLose()
  102. {
  103. this.lose.active = true
  104. }
  105. CloseWin()
  106. {
  107. this.win.active = false
  108. }
  109. CloseLose()
  110. {
  111. this.lose.active = false
  112. }
  113. CloseAddCountPanel()
  114. {
  115. this.addCountPanel.node.active = false
  116. }
  117. CloseEditBtns()
  118. {
  119. this.editBtns.active = false
  120. this.lvlContainer.swtichEditMode(false)
  121. this.noEditBtns.active = true
  122. }
  123. CloseSelDifPanel() {
  124. this.selDifPanel.node.active = false;
  125. }
  126. CloseSelSkinPanel() {
  127. this.selSkinPanel.node.active = false;
  128. }
  129. CloseSelMapPanel() {
  130. this.selMapPanel.node.active = false;
  131. }
  132. close()
  133. {
  134. this.node.destroy()
  135. EventMgr.ins.dispatchEvent("show_gm_btn")
  136. }
  137. onEditFinishClick()
  138. {
  139. this.CloseEditBtns()
  140. }
  141. onRegenerateClick()
  142. {
  143. this.lvlContainer.updateLevel()
  144. }
  145. onHideClick()
  146. {
  147. this.bottom.active = false
  148. this.bottom2.active = true
  149. this.showGmBtn.active = true
  150. }
  151. onShowGmClick()
  152. {
  153. this.bottom.active = true
  154. this.bottom2.active = false
  155. this.showGmBtn.active = false
  156. }
  157. onTipClick()
  158. {
  159. if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform) {
  160. mainscene.instance.ge.track(
  161. "ad_show", //追踪事件的名称
  162. {
  163. version: "123",
  164. ad_position: "小熊提示",
  165. level_id: SuperFind.superFindData.currentBgKey
  166. } //需要上传的事件属性
  167. );
  168. }
  169. PlatformService.getInstance().platformApi.loadAndShowVideoAd(() => {
  170. // PlatformService.getInstance().platformApi.reportAnalytics("tips", {
  171. // level: this.data.title
  172. // })
  173. if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform) {
  174. mainscene.instance.ge.track(
  175. "ad_showend", //追踪事件的名称
  176. {
  177. version: "123",
  178. ad_position: "小熊提示",
  179. level_id: SuperFind.superFindData.currentBgKey
  180. } //需要上传的事件属性
  181. );
  182. this.lvlContainer.showOneHint()
  183. }
  184. })
  185. }
  186. refreshInfo()
  187. {
  188. this.tipLabel.string = SuperFind.superFindData.title
  189. this.tipLabel2.string = SuperFind.superFindData.levelDesc
  190. }
  191. showOrHideScale()
  192. {
  193. this._showScale = !this._showScale
  194. this.lvlContainer.showOrHideScale(this._showScale)
  195. this.showOrHideScaleLabel.string = this._showScale?"隐藏缩放":"显示缩放"
  196. }
  197. countDown() {
  198. this._gameTime--
  199. if (this._gameTime <= 0) {
  200. this.unschedule(this.countDown)
  201. this.countDownLabel.string = "0秒"
  202. this.OpenLose()
  203. return
  204. }
  205. this.countDownLabel.string = this._gameTime.toString() + "秒"
  206. }
  207. restartCountDown()
  208. {
  209. this._gameTime = 600
  210. this.countDownLabel.string = this._gameTime.toString()+"秒"
  211. this.unschedule(this.countDown)
  212. this.schedule(this.countDown,1)
  213. }
  214. addTime()
  215. {
  216. this._gameTime += 60
  217. this.countDownLabel.string = this._gameTime.toString() + "秒"
  218. this.unschedule(this.countDown)
  219. this.schedule(this.countDown, 1)
  220. }
  221. OnClickShare() {
  222. PlatformService.getInstance().platformApi.recordedGameScreenStop()
  223. PlatformService.getInstance().platformApi.shareRecordedGameScreen()
  224. }
  225. OnClickAddtime() {
  226. if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform ) {
  227. mainscene.instance.ge.track(
  228. "ad_show", //追踪事件的名称
  229. {
  230. version: "123",
  231. ad_position: "小熊结算时加时",
  232. level_id: SuperFind.superFindData.currentBgKey
  233. } //需要上传的事件属性
  234. );
  235. }
  236. PlatformService.getInstance().platformApi.loadAndShowVideoAd(() => {
  237. if (sys.Platform.BYTEDANCE_MINI_GAME == sys.platform) {
  238. mainscene.instance.ge.track(
  239. "ad_showend", //追踪事件的名称
  240. {
  241. version: "123",
  242. ad_position: "小熊结算时加时",
  243. level_id: SuperFind.superFindData.currentBgKey
  244. } //需要上传的事件属性
  245. );
  246. this.addTime()
  247. }
  248. })
  249. }
  250. }