OriginCup.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { _decorator, 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. @property({ type: Number, tooltip: "水层数量" })
  16. waterLayers: number = 5; // 改为可配置项
  17. start() {
  18. this.node.on(Node.EventType.TOUCH_END, () => {
  19. EventDispatcher.instance.emit(GameEvent.EVENT_CLICK_ORIGIN_CUP, this);
  20. });
  21. }
  22. update(deltaTime: number) {
  23. }
  24. destroyOriginCup() {
  25. // 在销毁前记录位置
  26. const id = this.node.uuid;
  27. tween(this.node)
  28. .to(0.3, { scale: Vec3.ZERO })
  29. .call(() => {
  30. EventDispatcher.instance.emit(GameEvent.EVENT_ORIGIN_CUP_DESTROYED, id);
  31. this.node.destroy();
  32. })
  33. .start();
  34. }
  35. }