|
@@ -197,7 +197,7 @@ export class LevelAction extends Component {
|
|
|
tempCupComp.fill(color);
|
|
|
} else {
|
|
|
const cocktailCup = targetNode.getComponent(CocktailCup)!;
|
|
|
- cocktailCup.addLayer(color);
|
|
|
+ await cocktailCup.addLayer(color); // 等待添加水层流程完成
|
|
|
}
|
|
|
|
|
|
this.hideCurrentWaterLayer(originCup);
|
|
@@ -217,21 +217,17 @@ export class LevelAction extends Component {
|
|
|
|
|
|
// 添加等待区杯子到调酒区
|
|
|
private async addWaitCupToOutArea() {
|
|
|
- // 获取等待区杯子(保持原始顺序)
|
|
|
+ // 原有添加逻辑保持不变
|
|
|
const waitCups = this.waitArea.cups;
|
|
|
const outCups = this.outArea.getCups();
|
|
|
-
|
|
|
- // 根据调酒区状态决定添加数量
|
|
|
const needAddCount = outCups.length === 0 ? 2 : 1;
|
|
|
|
|
|
- // 获取需要移动的杯子(从右往左取)
|
|
|
const movingCups: Node[] = [];
|
|
|
for (let i = 0; i < needAddCount; i++) {
|
|
|
if (waitCups.length === 0) break;
|
|
|
movingCups.push(waitCups.pop()!);
|
|
|
}
|
|
|
|
|
|
- // 创建新杯子并设置位置
|
|
|
const newCups: Node[] = [];
|
|
|
for (const cup of movingCups) {
|
|
|
const comp = cup.getComponent(CocktailCup)!;
|
|
@@ -239,32 +235,23 @@ export class LevelAction extends Component {
|
|
|
const newCup = instantiate(prefab);
|
|
|
const newComp = newCup.getComponent(CocktailCup)!;
|
|
|
|
|
|
- // 保持原属性
|
|
|
newComp.cupColor = comp.cupColor;
|
|
|
newComp.reset();
|
|
|
|
|
|
- // 设置初始位置
|
|
|
const targetX = outCups.length === 0 ?
|
|
|
(newCups.length === 0 ? -125 : -45) :
|
|
|
-45;
|
|
|
newCup.setPosition(new Vec3(targetX, 0, 0));
|
|
|
|
|
|
newCups.push(newCup);
|
|
|
- cup.destroy(); // 销毁原杯子
|
|
|
+ cup.destroy();
|
|
|
}
|
|
|
|
|
|
- // 添加新杯子到调酒区
|
|
|
const outNodes = this.outArea.node.getChildByName('OutNodes')!;
|
|
|
newCups.forEach(cup => cup.setParent(outNodes));
|
|
|
|
|
|
- // 所有杯子向右平移80
|
|
|
- this.outArea.getCups().forEach(cup => {
|
|
|
- tween(cup)
|
|
|
- .by(0.3, { position: new Vec3(80, 0, 0) }, { easing: 'sineOut' })
|
|
|
- .start();
|
|
|
- });
|
|
|
-
|
|
|
- this.waitArea.getCups().forEach(cup => {
|
|
|
+ // 执行统一平移
|
|
|
+ this.outArea.getCups().concat(this.waitArea.getCups()).forEach(cup => {
|
|
|
tween(cup)
|
|
|
.by(0.3, { position: new Vec3(80, 0, 0) }, { easing: 'sineOut' })
|
|
|
.start();
|