|
@@ -190,6 +190,7 @@ export class LevelAction extends Component {
|
|
|
originCup.node,
|
|
|
targetNode,
|
|
|
color,
|
|
|
+ undefined,
|
|
|
targetIsTemp
|
|
|
);
|
|
|
|
|
@@ -217,7 +218,43 @@ export class LevelAction extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 添加等待区杯子到调酒区
|
|
|
+ // 新增方法:处理暂存区倒水到调酒区
|
|
|
+ private async handlePourTempCupToOutArea() {
|
|
|
+ const tempCupsComp = this.tempCups.getComponent(TempCups)!;
|
|
|
+ const filledCups = tempCupsComp.getFilledCups();
|
|
|
+
|
|
|
+ for (const tempCup of filledCups) {
|
|
|
+ const originalPos = tempCup.node.position.clone();
|
|
|
+ const colors = tempCup.getColors();
|
|
|
+ let hasProcessed = false; // 标记是否有处理过颜色
|
|
|
+
|
|
|
+ for (const color of colors) {
|
|
|
+ const targetCup = this.findTargetCupInOutArea(color);
|
|
|
+ if (!targetCup) {
|
|
|
+ console.log(`颜色${WaterColors[color]}未找到可用调酒杯`);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ await this.pourAnimation(
|
|
|
+ tempCup.node,
|
|
|
+ targetCup.node,
|
|
|
+ color,
|
|
|
+ originalPos,
|
|
|
+ true
|
|
|
+ );
|
|
|
+
|
|
|
+ const cocktailCup = targetCup.comp;
|
|
|
+ await cocktailCup.addLayer(color);
|
|
|
+ hasProcessed = true; // 标记已处理
|
|
|
+ }
|
|
|
+ // 仅当有处理过颜色时才重置暂存杯
|
|
|
+ if (hasProcessed) {
|
|
|
+ tempCup.reset();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修改原有方法,在添加新杯子后触发暂存区倒水
|
|
|
private async addWaitCupToOutArea() {
|
|
|
// 原有添加逻辑保持不变
|
|
|
const waitCups = this.waitArea.cups;
|
|
@@ -258,12 +295,16 @@ export class LevelAction extends Component {
|
|
|
.by(0.3, { position: new Vec3(80, 0, 0) }, { easing: 'sineOut' })
|
|
|
.start();
|
|
|
});
|
|
|
+
|
|
|
+ // 在添加完成后处理暂存区倒水
|
|
|
+ await this.handlePourTempCupToOutArea();
|
|
|
}
|
|
|
|
|
|
private async pourAnimation(
|
|
|
origin: Node,
|
|
|
target: Node,
|
|
|
color: WaterColors,
|
|
|
+ originalPos?: Vec3,
|
|
|
isTempCup: boolean = false
|
|
|
) {
|
|
|
// 使用正确的坐标转换
|
|
@@ -278,19 +319,29 @@ export class LevelAction extends Component {
|
|
|
localPos.y += 150; // 调酒杯偏移
|
|
|
}
|
|
|
|
|
|
- // 只做单程移动,保留在目标位置
|
|
|
+ // 移动动画到目标位置
|
|
|
await new Promise<void>(resolve => {
|
|
|
tween(origin)
|
|
|
- .to(0.5, { position: localPos }) // 延长动画时间到0.5秒
|
|
|
- .call(() => resolve())
|
|
|
+ .to(0.5, { position: localPos })
|
|
|
+ .call(resolve)
|
|
|
.start();
|
|
|
});
|
|
|
+
|
|
|
+ // 正确应用返回动画逻辑
|
|
|
+ if (isTempCup && originalPos) {
|
|
|
+ await new Promise(resolve => {
|
|
|
+ tween(origin)
|
|
|
+ .to(0.3, { position: originalPos })
|
|
|
+ .call(resolve)
|
|
|
+ .start();
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 新增辅助方法
|
|
|
private hideCurrentWaterLayer(originCup: OriginCup) {
|
|
|
const activeWaters = originCup.waters.children.filter(n => n.active);
|
|
|
- if (activeWaters.length > 0) {
|
|
|
+ if (activeWaters.length >= 0) {
|
|
|
const topIndex = activeWaters.length - 1;
|
|
|
activeWaters[topIndex].active = false;
|
|
|
}
|