OriginCup.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. const originalPos = this.node.position.clone();
  26. tween(this.node)
  27. .to(0.3, { scale: Vec3.ZERO })
  28. .call(() => {
  29. this.node.destroy();
  30. EventDispatcher.instance.emit(GameEvent.EVENT_ORIGIN_CUP_DESTROYED, this.node.uuid);
  31. })
  32. .start();
  33. }
  34. }