OriginCup.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { _decorator, CCInteger, Component, Enum, Node, tween, Vec3 } from 'cc';
  2. import { CupHeight } from '../TakeGobletGlobalInstance';
  3. import { LevelAction } from '../LevelAction';
  4. import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDispatcher';
  5. import { GameEvent } from '../Enum/GameEvent';
  6. const { ccclass, property, executeInEditMode } = _decorator;
  7. /** 原浆酒杯组件脚本*/
  8. @ccclass('OriginCup')
  9. @executeInEditMode
  10. export class OriginCup extends Component {
  11. @property({ type: Enum(CupHeight), displayName: '杯高度' })
  12. cupHeight: CupHeight = CupHeight.Two
  13. @property(Node)
  14. waters: Node = null!; //水节点
  15. start() {
  16. this.node.on(Node.EventType.TOUCH_END, () => {
  17. EventDispatcher.instance.emit(GameEvent.EVENT_CLICK_ORIGIN_CUP, this);
  18. });
  19. }
  20. update(deltaTime: number) {
  21. }
  22. destroyOriginCup() {
  23. const id = this.node.uuid;
  24. console.log('销毁原浆杯id : ', id);
  25. tween(this.node)
  26. .to(0.3, { scale: Vec3.ZERO })
  27. .call(() => {
  28. EventDispatcher.instance.emit(GameEvent.EVENT_ORIGIN_CUP_DESTROYED, id);
  29. this.node.destroy();
  30. })
  31. .start();
  32. }
  33. }