PutBallLevelDisplay.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import DataMgr from "../../data/DataMgr";
  2. import ui_PutBallLevelDisplay from "../../fgui/res/game/ui_PutBallLevelDisplay";
  3. import { xGame } from "../../xGame";
  4. import UILevelProp from "../UILevelProp";
  5. export default class PutBallLevelDisplay {
  6. public ui: ui_PutBallLevelDisplay;
  7. public index: number = 0;
  8. public data: any;
  9. constructor(ui: ui_PutBallLevelDisplay, index) {
  10. this.ui = ui;
  11. this.index = index;
  12. this.ui.onClick(this, this.clickSelf);
  13. this.updateSelf();
  14. this.ui.levelTxt.text = (this.index + 1) + "";
  15. this.ui.challenge.levelTxt.text = (this.index + 1) + "";
  16. this.ui.special.levelTxt.text = (this.index + 1) + "";
  17. }
  18. updateSelf() {
  19. let level = this.index + 1;
  20. this.data = DataMgr.getPlaceBallLevel(level);
  21. //console.log("zh:lev this.data","level="+level,this.data);
  22. this.ui.starNode.c1.selectedIndex = this.data.star;
  23. let isChallenge = cfgTable.placeballData[level].type;
  24. //
  25. if (this.data.isCur) {
  26. //当前关卡,未通关
  27. if (isChallenge) {
  28. this.ui.c1.selectedIndex = 5;
  29. }
  30. else {
  31. this.ui.c1.selectedIndex = 2;
  32. }
  33. }
  34. else {
  35. if (this.data.play) {
  36. //已经通关
  37. if (this.data.star == 3) {
  38. this.ui.c1.selectedIndex = 0;
  39. }
  40. else {
  41. this.ui.c1.selectedIndex = 1;
  42. }
  43. }
  44. else {
  45. //未通过,未解锁
  46. if (isChallenge) {
  47. this.ui.c1.selectedIndex = 4;
  48. }
  49. else {
  50. this.ui.c1.selectedIndex = 3;
  51. }
  52. }
  53. }
  54. }
  55. clickSelf() {
  56. if (!this.data.play) return;
  57. xGame.soundMgr.playSound(xGame.common.btnClickStr);
  58. xGame.uiMgr.Show(UILevelProp, this.index + 1);
  59. }
  60. }