TempTipsNode.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { _decorator, Node, Tween, tween, v3 } from 'cc';
  2. import { NodeEx } from '../../framework/pool/NodeEx';
  3. import { TipsPool } from '../common/Pool';
  4. import { GameConf } from '../data/GameConf';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('TempTipsNode')
  7. export class TempTipsNode extends NodeEx {
  8. protected onLoad() {
  9. this.Node.fuck_01.active = false;
  10. this.Node.fuck_02.active = false;
  11. this.Node.fuck_03.active = false;
  12. this.Node.fuck_04.active = false;
  13. }
  14. protected onDestroy() {
  15. //如果该组件有事件自行取消注释
  16. //Framework.event.removeEvent(this);
  17. super.onDestroy();
  18. }
  19. //节点被放入池中时调用
  20. unuse() {
  21. Tween.stopAllByTarget(this.node);
  22. this.node.setPosition(0, 0);
  23. this.Node.fuck_01.active = false;
  24. this.Node.fuck_02.active = false;
  25. this.Node.fuck_03.active = false;
  26. this.Node.fuck_04.active = false;
  27. }
  28. //节点从池中取出时调用
  29. reuse(type: GameConf.TipsType, value: number) {
  30. value = Math.floor(value);
  31. this.Node.fuck_01.active = false;
  32. this.Node.fuck_02.active = false;
  33. this.Node.fuck_03.active = false;
  34. this.Node.fuck_04.active = false;
  35. if (type == GameConf.TipsType.cost) {
  36. this.Node.fuck_03.active = true;
  37. this.Label.fuck_03.string = value + "%";
  38. } else if (type == GameConf.TipsType.select) {
  39. this.Node.fuck_04.active = true;
  40. this.Label.fuck_04.string = "+" + value + "%";
  41. } else if (type == GameConf.TipsType.settle) {
  42. this.Node.fuck_02.active = true;
  43. this.Label.fuck_02.string = "+" + value + "%";
  44. } else if (type == GameConf.TipsType.visit) {
  45. this.Node.fuck_01.active = true;
  46. this.Label.fuck_01.string = "+" + value + "%";
  47. }
  48. this._runAction();
  49. }
  50. private _runAction() {
  51. Tween.stopAllByTarget(this.node);
  52. tween(this.node).by(1.5, { position: v3(0, 150) }).call(() => {
  53. TipsPool.putNode(this);
  54. }).start();
  55. }
  56. }