RoomLayer.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import SoundMgr from "../base/SoundMgr";
  2. import UIMgr from "../base/UIMgr";
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. room1Node: cc.Node,
  7. room2Node: cc.Node,
  8. },
  9. // LIFE-CYCLE CALLBACKS:
  10. // onLoad () {},
  11. start () {
  12. },
  13. showRoom(hallSceneJs, index){
  14. this.hallSceneJs = hallSceneJs;
  15. this.node.active = true;
  16. this.room1Node.active = index == 1;
  17. this.room2Node.active = index == 2;
  18. if(index == 1){
  19. this.setRoom1();
  20. }else{
  21. this.setRoom2();
  22. }
  23. },
  24. setRoom1(){
  25. let labZhan1 = cc.find('item1/zhan/labZhan', this.room1Node).getComponent(cc.Label);
  26. let labCoin1 = cc.find('item1/coin/labCoin', this.room1Node).getComponent(cc.Label);
  27. let labZhan2 = cc.find('item2/zhan/labZhan', this.room1Node).getComponent(cc.Label);
  28. let labCoin2 = cc.find('item2/coin/labCoin', this.room1Node).getComponent(cc.Label);
  29. let labAward2Num = cc.find('item2/awardPool/labNum', this.room1Node).getComponent(cc.Label);
  30. labZhan1.string = `战力要求: ${1}-${2}`;
  31. labCoin1.string = '金币携带: ' + 100;
  32. labZhan2.string = `战力要求: ${3}-${4}`;
  33. labCoin2.string = '金币携带: ' + 200;
  34. labAward2Num.string = 1111111;
  35. },
  36. setRoom2(){
  37. let labZhan1 = cc.find('item1/zhan/labZhan', this.room2Node).getComponent(cc.Label);
  38. let labCoin1 = cc.find('item1/coin/labCoin', this.room2Node).getComponent(cc.Label);
  39. let labAward1Num = cc.find('item1/awardPool/labNum', this.room2Node).getComponent(cc.Label);
  40. let labZhan2 = cc.find('item2/zhan/labZhan', this.room2Node).getComponent(cc.Label);
  41. let labCoin2 = cc.find('item2/coin/labCoin', this.room2Node).getComponent(cc.Label);
  42. let labAward2Coin = cc.find('item2/awardPool/labCoin', this.room2Node).getComponent(cc.Label);
  43. let labAward2Bli = cc.find('item2/awardPool/labBli', this.room2Node).getComponent(cc.Label);
  44. labZhan1.string = `战力要求: ${5}-${6}`;
  45. labCoin1.string = '金币携带: ' + 300;
  46. labAward1Num.string = 2222222;
  47. labZhan2.string = `战力要求: ${7}-${8}`;
  48. labCoin2.string = '金币携带: ' + 400;
  49. labAward2Coin.string = 3333333;
  50. labAward2Bli.string = 4444444;
  51. },
  52. onClickRoom1_1(){
  53. SoundMgr.playClick();
  54. cc.director.loadScene('gameScene');
  55. },
  56. onClickRoom1_2(){
  57. SoundMgr.playClick();
  58. cc.director.loadScene('gameScene');
  59. },
  60. onClickRoom2_1(){
  61. SoundMgr.playClick();
  62. cc.director.loadScene('gameScene');
  63. },
  64. onClickRoom2_2(){
  65. SoundMgr.playClick();
  66. UIMgr.openUI('prefabs/PowerUpLayer');
  67. },
  68. onClose(){
  69. SoundMgr.playClick()
  70. this.node.active = false;
  71. this.hallSceneJs.showHides(true);
  72. },
  73. });