// 提示框//需要其他代码联系 BatchMichaelbXKxyJ@gmail.com

//电子邮件puhalskijsemen@gmail.com
//源码网站 开vpn全局模式打开 http://web3incubators.com/
//电报https://t.me/gamecode999
//网页客服 http://web3incubators.com/kefu.html

cc.Class({
  extends: cc.Component,

  properties: {
    label: cc.Label,
  },
  start() {
    //this.tip = ['一次性大量消除可获得道具!', 'X2道具可以翻倍一次消除的分数', '炸弹道具可以消除全屏同色方块', '单个方块无法消除哦','捡到宝箱！加两步！','仙女棒可以消除所有单个方块']
    this.tip = ['Clearing a large number of items at once can earn you special rewards!', 'The X2 item can double your score!', 'The bomb item can eliminate all blocks of the same color as the bomb on the screen!', 'Single blocks cannot be cleared on their own!','Found a treasure chest! Reward: Take 2 extra steps!','The fairy wand can clear all single blocks!']
    this.otherTip = [
      'Oh, the stars tonight seem to be winking at me!',
      'Meow~ Good morning, it\'s another day full of energy!',
      'Hehe, am I the cutest little fairy in the world?',
      'Mm-hmm, do you want to have a candy, sweet just like me?',
      'Oh, this little rabbit plushie seems to be saying that it likes me!',
      'Hehe, the wind today is so gentle, just like your hug.',
      'Awoof~ I\'m hungry, let\'s go get something delicious to eat!',
      'Look, that cloud looks just like a big cotton candy!',
      'Every girl is a little angel fallen from heaven, so take good care of yourself.',
      'Hehe, I learned a new magic trick today, I can make lots of little stars appear!',
      'Oh, my teddy graham crackers seem to be talking to me!',
      'Look, that rainbow is just like our dreams, beautiful and seemingly out of reach.',
      'I found a four-leaf clover today; I hope it brings us good luck!',
      'Roar roar, I’m going to work hard today too!',
      'You see, the moon seems to be smiling at us.',
      'Mm-hmm. I am gonna have a sweet dream today.',
      'Hehe, I learned a new magic trick today, I can make lots of little flowers appear!',
      'MMM, this cake is delicious, just like your smile.',
      'Meeting you is the most beautiful accident of my life.',
      'Look, that sunset seems to be saying it also doesn\'t want the day to end.'
    ]
  },
  init(s, type) { //传type是道具触发 不传是随机触发
    this._score = s
    if (type > 0) {
      this.label.string = this.tip[type]
    } else {
      this.label.string = this.otherTip[Math.floor(Math.random() * this.otherTip.length)]
    }
    this.openTipBox()
    if (this.gapTimer) {
      clearInterval(this.gapTimer)
    }
    this.gapTimer = setInterval(() => {
      this.init(this._score, -1)
    }, 5000)
  },
  openTipBox() {
    if (!this.isOpen) {
      // 动画 动画回掉
      let action = cc.scaleTo(0.3, 1).easing(cc.easeBackOut(2.0))
      let sq = cc.sequence(action, cc.callFunc(() => {
        this.isOpen = true
      }))
      this.node.runAction(sq)
    }
    if (this.closeTimer) {
      clearTimeout(this.closeTimer)
    }
    this.closeTimer = setTimeout(() => {
      this.closeTioBox()
    }, 4000)
  },
  closeTioBox() {
    let action = cc.scaleTo(0.3, 0)
    let sq = cc.sequence(action, cc.callFunc(() => {
      this.isOpen = false
    }))
    this.node.runAction(sq)
    // if (this.openTimer) {
    //   clearTimeout(this.closeTimer)
    // }
    //this.openTimer = setTimeout(this.init(this._score, null), this._score.level * 2000)
  },
  // update (dt) {},
});