Content_seed.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. var reGameStates = require('GameStates')
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. Name: {
  6. default: '种子',
  7. tooltip: '种子名字,这里和Content_button差不多。主要用于种子',
  8. },
  9. SeedPrefab: {
  10. default: null,
  11. type: cc.Prefab,
  12. },
  13. SpawnPoint: {
  14. default: null,
  15. type: cc.Node,
  16. },
  17. seedType: {
  18. default: reGameStates.SeedType.Normal,
  19. type: cc.Enum(reGameStates.SeedType),
  20. serializable: true,
  21. },
  22. //商城类型
  23. mallType: { default: 0, tooltip: "类型,默认0是种子" },
  24. goodsSeedInfo: {
  25. default: null,
  26. tooltip: '设定一个背包种子信息',
  27. },
  28. seedSpriteFrame: {
  29. default: null,
  30. type: cc.SpriteFrame,
  31. tooltip: '种子',
  32. },
  33. fruitSpriteFrame: {
  34. default: null,
  35. type: cc.SpriteFrame,
  36. tooltip: '果实',
  37. },
  38. myIndex: -1,
  39. plantButtonText: {
  40. default: null,
  41. type:cc.Label,
  42. tooltip: '按钮文字修改',
  43. },
  44. },
  45. start() {
  46. this.StoreViewScp = cc.find("Canvas/UICamera/StoreContainer/StoreView").getComponent('StoreView')
  47. // console.log('11111111111=',this.StoreViewScp);
  48. },
  49. onUpdatePlantButtonText(){
  50. //修改文字
  51. this.plantButtonText.string = 0 === this.mallType?"种植":"养殖";
  52. },
  53. onCreateSeed() {
  54. let seedTemp = cc.instantiate(this.SeedPrefab)
  55. // console.log(seedTemp);
  56. //获取对应的信息,设置不同的种子
  57. let _ManageSeedNode = seedTemp.getComponent('ManageSeedNode')
  58. _ManageSeedNode.seedName = this.Name
  59. _ManageSeedNode.seedType = this.seedType
  60. _ManageSeedNode.goodsSeedInfo = this.goodsSeedInfo
  61. _ManageSeedNode.seedSprite.spriteFrame = this.seedSpriteFrame
  62. _ManageSeedNode.fruitSpriteFrame = this.fruitSpriteFrame
  63. _ManageSeedNode.upTarget = this.node;
  64. _ManageSeedNode.mallType = this.mallType;
  65. let tempPos = this.SpawnPoint.convertToNodeSpace(
  66. GlobalD.game.MainCamera.node
  67. )
  68. let CanvasPos = GlobalD.game.Canvas.position
  69. seedTemp.setPosition(tempPos.x + CanvasPos.x, tempPos.y + CanvasPos.y)
  70. seedTemp.parent = this.SpawnPoint
  71. //收起菜单
  72. GlobalD.game._ManageUIScript.onButtonEvent_Building_Close()
  73. },
  74. onPayCNTPopView() {
  75. this.StoreViewScp.onPayCNTPopView(this.myIndex)
  76. },
  77. onPaySNBPopView() {
  78. this.StoreViewScp.onPaySNBPopView(this.myIndex)
  79. },
  80. })