BuildingView.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. Env: {
  5. default: null,
  6. type: cc.Node,
  7. },
  8. Labour: {
  9. default: null,
  10. type: cc.Node,
  11. },
  12. Shop: {
  13. default: null,
  14. type: cc.Node,
  15. },
  16. SpeBuilding: {
  17. default: null,
  18. type: cc.Node,
  19. },
  20. EvnBtn: {
  21. default: null,
  22. type: cc.Node,
  23. },
  24. LabourBtn: {
  25. default: null,
  26. type: cc.Node,
  27. },
  28. ShopBtn: {
  29. default: null,
  30. type: cc.Node,
  31. },
  32. SpeBuildingBtn: {
  33. default: null,
  34. type: cc.Node,
  35. },
  36. Normal_Sprite: cc.SpriteFrame,
  37. Selecteded_Sprite: cc.SpriteFrame,
  38. SelectedFrame:cc.Node,
  39. Building00:cc.Node,
  40. Building10:cc.Node,
  41. Building20:cc.Node,
  42. Building30:cc.Node,
  43. ManageUI:cc.Node,
  44. },
  45. HiddenAll() {
  46. if (this.Env.active)
  47. this.Env.active = false;
  48. if (this.Labour.active)
  49. this.Labour.active = false;
  50. if (this.Shop.active)
  51. this.Shop.active = false;
  52. if (this.SpeBuilding.active)
  53. this.SpeBuilding.active = false;
  54. },
  55. //切换建筑的面板
  56. onSwitchBuildingContent(event, index) {
  57. // if (task.taskCursor == 7) {
  58. // return;
  59. // }
  60. this.EvnBtn.setScale(1);
  61. this.LabourBtn.setScale(1);
  62. this.ShopBtn.setScale(1);
  63. this.SpeBuildingBtn.setScale(1);
  64. this.EvnBtn.getComponent(cc.Sprite).spriteFrame =this.Selecteded_Sprite;
  65. this.LabourBtn.getComponent(cc.Sprite).spriteFrame =this.Selecteded_Sprite;
  66. this.ShopBtn.getComponent(cc.Sprite).spriteFrame =this.Selecteded_Sprite;
  67. this.SpeBuildingBtn.getComponent(cc.Sprite).spriteFrame =this.Selecteded_Sprite;
  68. // var ClickedBtnNode = event.target;
  69. // ClickedBtnNode.setScale(1.3);
  70. // ClickedBtnNode.getComponent(cc.Sprite).spriteFrame =this.Normal_Sprite;
  71. this.HiddenAll();
  72. //面板设置index
  73. //环境
  74. if ('0' == index) {
  75. // this._className.string = '环境';
  76. this.Env.active = true;
  77. this.EvnBtn.getComponent(cc.Sprite).spriteFrame = this.Normal_Sprite;
  78. this.SelectedFrame.parent = this.Building00;
  79. this.ManageUI.getComponent('ManageUI').onSetButtonInfo(this.Building00.getComponent('Content_Button').Name, this.Building00.getComponent('Content_Button').Price, this.Building00.getComponent('Content_Button').Synopsis);
  80. }
  81. //劳动
  82. else if ('1' == index) {
  83. // this._className.string = '劳动';
  84. this.Labour.active = true;
  85. this.LabourBtn.getComponent(cc.Sprite).spriteFrame = this.Normal_Sprite;
  86. this.SelectedFrame.parent = this.Building10;
  87. this.ManageUI.getComponent('ManageUI').onSetButtonInfo(this.Building10.getComponent('Content_Button').Name, this.Building10.getComponent('Content_Button').Price, this.Building10.getComponent('Content_Button').Synopsis);
  88. }
  89. //商铺
  90. else if ('2' == index) {
  91. // this._className.string = '商店';
  92. this.Shop.active = true;
  93. this.ShopBtn.getComponent(cc.Sprite).spriteFrame = this.Normal_Sprite;
  94. this.SelectedFrame.parent = this.Building20;
  95. this.ManageUI.getComponent('ManageUI').onSetButtonInfo(this.Building20.getComponent('Content_Button').Name, this.Building20.getComponent('Content_Button').Price, this.Building20.getComponent('Content_Button').Synopsis);
  96. } else if ('3' == index) {
  97. // this._className.string = '商店';
  98. this.SpeBuilding.active = true;
  99. this.SpeBuildingBtn.getComponent(cc.Sprite).spriteFrame = this.Normal_Sprite;
  100. this.SelectedFrame.parent = this.Building30;
  101. this.ManageUI.getComponent('ManageUI').onSetButtonInfo(this.Building30.getComponent('Content_Button').Name, this.Building30.getComponent('Content_Button').Price, this.Building30.getComponent('Content_Button').Synopsis);
  102. }
  103. }
  104. });