NodeLevel.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import hallScene from "../../hallScene";
  2. import { App } from "../../Manager/App";
  3. const {ccclass, property} = cc._decorator;
  4. @ccclass
  5. export default class NodeLevel extends cc.Component {
  6. labelDiamond: cc.Label[] = [];
  7. key: cc.Node[] = [];
  8. star: cc.Node[] = [];
  9. @property(cc.Label)
  10. labelExp: cc.Label = null;
  11. @property(cc.Button)
  12. btnStart:cc.Button = null;
  13. onLoad () {
  14. for (let i = 0; i < 3; i++) {
  15. this.labelDiamond[i] = this.node.getChildByName("LabelRewardDiamond" + i).getComponent(cc.Label);
  16. this.key[i] = this.node.getChildByName("key" + i);
  17. this.star[i] = this.node.getChildByName("star" + i);
  18. }
  19. this.btnStart.node.on("click", this.clickGameStart.bind(this), this);
  20. }
  21. start(){
  22. this.findPlayerLevel();
  23. }
  24. findPlayerLevel(){
  25. let curlevel = App.DataManager.PlayLevel;
  26. this.freshLevelNum(curlevel);
  27. }
  28. freshLevelNum(index: number){
  29. App.DataManager.PlayLevel = index;
  30. this.labelExp.string = "Level " + index + "_" + App.DataManager.PassProgress[index];
  31. for (let i = 0; i < this.labelDiamond.length; i++) {
  32. this.star[i].active = App.DataManager.PassProgress[index] >= i + 1;
  33. this.key[i].active = App.DataManager.keyPos[index - 1] == i + 1;
  34. this.labelDiamond[i].string = App.DataManager.diamondNum[index - 1][i] + "";
  35. }
  36. }
  37. clickGameStart(){
  38. hallScene.instance.StartGame(App.DataManager.PlayLevel);
  39. }
  40. // update (dt) {}
  41. }