Content_seed.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. goodsSeedInfo: {
  23. default: null,
  24. tooltip: '设定一个背包种子信息',
  25. },
  26. seedSpriteFrame: {
  27. default: null,
  28. type: cc.SpriteFrame,
  29. tooltip: '当前生出工具的提示',
  30. },
  31. fruitSpriteFrame: {
  32. default: null,
  33. type: cc.SpriteFrame,
  34. tooltip: '当前生出工具的提示',
  35. },
  36. myIndex: -1,
  37. },
  38. start() {
  39. this.StoreViewScp =
  40. this.node.parent.parent.parent.parent.parent.getComponent('StoreView')
  41. // console.log('11111111111=',this.StoreViewScp);
  42. },
  43. onCreateSeed() {
  44. let seedTemp = cc.instantiate(this.SeedPrefab)
  45. // console.log(seedTemp);
  46. //获取对应的信息,设置不同的种子
  47. let _ManageSeedNode = seedTemp.getComponent('ManageSeedNode')
  48. _ManageSeedNode.seedName = this.Name
  49. _ManageSeedNode.seedType = this.seedType
  50. _ManageSeedNode.goodsSeedInfo = this.goodsSeedInfo
  51. _ManageSeedNode.seedSprite.spriteFrame = this.seedSpriteFrame
  52. _ManageSeedNode.fruitSpriteFrame = this.fruitSpriteFrame
  53. _ManageSeedNode.upTarget = this.node
  54. let tempPos = this.SpawnPoint.convertToNodeSpace(
  55. GlobalD.game.MainCamera.node
  56. )
  57. let CanvasPos = GlobalD.game.Canvas.position
  58. seedTemp.setPosition(tempPos.x + CanvasPos.x, tempPos.y + CanvasPos.y)
  59. seedTemp.parent = this.SpawnPoint
  60. //收起菜单
  61. GlobalD.game._ManageUIScript.onButtonEvent_Building_Close()
  62. },
  63. onPayCNTPopView() {
  64. this.StoreViewScp.onPayCNTPopView(this.myIndex)
  65. },
  66. onPaySNBPopView() {
  67. this.StoreViewScp.onPaySNBPopView(this.myIndex)
  68. },
  69. })