MoneySaveItem.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { RecordTYPE } from "../datas/CommonData";
  2. import GameM from "../manager/GameM";
  3. import LogUtil from "../utils/LogUtil";
  4. const { ccclass, property } = cc._decorator;
  5. @ccclass
  6. export default class MoneySaveItem extends cc.Component {
  7. @property(cc.Label)
  8. labDes: cc.Label = null;
  9. @property(cc.Label)
  10. labTime: cc.Label = null;
  11. @property(cc.Label)
  12. labAdd: cc.Label = null;
  13. @property(cc.Label)
  14. labelTotal: cc.Label = null;
  15. @property(cc.Node)
  16. readyTixianBtn: cc.Node = null;
  17. @property(cc.Label)
  18. sourceType: cc.Label = null;
  19. @property(cc.Label)
  20. yuanlabel: cc.Label = null;
  21. num: number
  22. tixian: boolean
  23. data:any
  24. callback: Function = null
  25. nodePos = [cc.v3(54,-63),cc.v3(313,57),cc.v3(572,-67),cc.v3(862,-67)]
  26. // LIFE-CYCLE CALLBACKS:
  27. // onLoad () {}
  28. start() {
  29. }
  30. init(data,tixian, callback: Function,index) {
  31. this.callback = callback
  32. this.tixian = tixian
  33. this.data = data
  34. this.labAdd.string = (this.data.amount * 0.01).toFixed(2)+""
  35. // this.yuanlabel.string = "元"
  36. if(this.data.cashType == 1){
  37. this.sourceType.string = "武将升级"
  38. this.sourceType.node.parent .active = true
  39. }else if(this.data.cashType == 2){
  40. this.sourceType.string = "每日提现"
  41. this.sourceType.node.parent .active = true
  42. }else{
  43. this.sourceType.node.parent .active = false
  44. }
  45. // if(!this.tixian){
  46. // this.node.runAction(cc.repeatForever(cc.sequence(cc.spawn(cc.fadeTo(1,255),cc.scaleTo(1,1)),cc.spawn(cc.fadeTo(0.5,100),cc.scaleTo(0.5,0.6)))))
  47. // }
  48. let x = this.node.x
  49. this.node.y = - this.node.height * 0.5 * 1.5
  50. this.node.getChildByName("Hand").active = false
  51. if(index == 1){
  52. this.node.y = -200
  53. if(!tixian){
  54. this.node.getChildByName("Hand").active = true
  55. }
  56. this.node.position = this.nodePos[0]
  57. }else if(index == 2){
  58. // this.node.y = 0
  59. this.node.position = this.nodePos[1]
  60. }else if(index == 3){
  61. // this.node.y = -200
  62. this.node.position = this.nodePos[2]
  63. }else{
  64. this.node.position = this.nodePos[3]
  65. }
  66. let y = this.node.y
  67. LogUtil.logV("moneySaveItem", x + " : " + y)
  68. let downAction = cc.moveTo(2, cc.v2(x, y - 10))
  69. let upAction = cc.moveBy(0.5, cc.v2(x, y))
  70. // this.node.runAction(cc.repeatForever(cc.sequence(downAction,upAction)))
  71. let delayTime = Math.random()
  72. this.scheduleOnce(() => {
  73. this.node.runAction(cc.repeatForever(cc.sequence(cc.moveTo(1.5, cc.v2(this.node.x, y - 5)), cc.moveTo(1.2, cc.v2(this.node.x, this.node.y + 5)))))
  74. }, delayTime)
  75. }
  76. clickAdd() {
  77. if (this.tixian) {
  78. // return
  79. }
  80. // this.node.destroy()
  81. this.unscheduleAllCallbacks()
  82. this.node.getChildByName("Hand").active = false
  83. if (this.callback) {
  84. this.callback(this.data, this.node)
  85. }
  86. }
  87. // update (dt) {}
  88. }