123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import { _decorator, Component, Enum, Node, tween, Vec3 } from 'cc';
- import { CupHeight } from '../TakeGobletGlobalInstance';
- import { LevelAction } from '../LevelAction';
- import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDispatcher';
- import { GameEvent } from '../Enum/GameEvent';
- const { ccclass, property, executeInEditMode } = _decorator;
- /** 原浆酒杯组件脚本*/
- @ccclass('OriginCup')
- @executeInEditMode
- export class OriginCup extends Component {
- @property({ type: Enum(CupHeight), displayName: '杯高度' })
- cupHeight: CupHeight = CupHeight.Two
- @property(Node)
- waters: Node = null!; //水节点
- @property({ type: Number, tooltip: "水层数量" })
- waterLayers: number = 5; // 改为可配置项
- start() {
- this.node.on(Node.EventType.TOUCH_END, () => {
- EventDispatcher.instance.emit(GameEvent.EVENT_CLICK_ORIGIN_CUP, this);
- });
- }
- update(deltaTime: number) {
- }
- destroyOriginCup() {
- // 在销毁前记录位置
- const id = this.node.uuid;
- tween(this.node)
- .to(0.3, { scale: Vec3.ZERO })
- .call(() => {
- EventDispatcher.instance.emit(GameEvent.EVENT_ORIGIN_CUP_DESTROYED, id);
- this.node.destroy();
- })
- .start();
- }
- }
|