FightTips.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { _decorator, Component, Node, Animation } from 'cc';
  2. import { DataSystem } from '../core/data/DataSystem';
  3. import { UserData } from '../data/UserData';
  4. const { ccclass, property } = _decorator;
  5. /**
  6. * 切磋气泡
  7. */
  8. @ccclass('FightTips')
  9. export class FightTips extends Component {
  10. @property({ type: Node, tooltip: "气泡节点" }) tipNode: Node;
  11. @property({ type: Animation, tooltip: "气泡节点" }) ani: Animation;
  12. @property({ tooltip: "切磋解锁等级" }) opencampLv = 6;
  13. @property({ tooltip: "特效播放次数" }) playTimes = 6;
  14. private times = 0;
  15. start() {
  16. this.setData();
  17. }
  18. update() {
  19. DataSystem.watch(UserData, 'campLv') && this.setData();
  20. if (this.times == this.playTimes) {
  21. this.node.destroy();
  22. }
  23. }
  24. private setData() {
  25. if (DataSystem.getData(UserData).campLv >= this.opencampLv) {
  26. this.ani && this.ani.play();
  27. }
  28. }
  29. private playComplete() {
  30. this.times++;
  31. if (this.times < this.playTimes) {
  32. this.ani.play();
  33. }
  34. }
  35. }