|
@@ -1,5 +1,4 @@
|
|
import { _decorator, BoxCollider2D, Button, CircleCollider2D, Collider2D, Component, find, instantiate, Node, NodeEventType, tween, view, Vec3, mat4, UITransform } from 'cc';
|
|
import { _decorator, BoxCollider2D, Button, CircleCollider2D, Collider2D, Component, find, instantiate, Node, NodeEventType, tween, view, Vec3, mat4, UITransform } from 'cc';
|
|
-import { resLoader, ResLoader } from '../../core_tgx/base/ResLoader';
|
|
|
|
import { CupHeight, TakeGobletGlobalInstance, WaterColorLog, WaterColors } from './TakeGobletGlobalInstance';
|
|
import { CupHeight, TakeGobletGlobalInstance, WaterColorLog, WaterColors } from './TakeGobletGlobalInstance';
|
|
import { OutArea } from './Component/OutArea';
|
|
import { OutArea } from './Component/OutArea';
|
|
import { WaitArea } from './Component/WaitArea';
|
|
import { WaitArea } from './Component/WaitArea';
|
|
@@ -13,6 +12,7 @@ import { TempCups } from './Component/TempCups';
|
|
import { tgxUIMgr, tgxUITips } from '../../core_tgx/tgx';
|
|
import { tgxUIMgr, tgxUITips } from '../../core_tgx/tgx';
|
|
import { LevelManager } from './Manager/LevelMgr';
|
|
import { LevelManager } from './Manager/LevelMgr';
|
|
import { UI_BattleResult } from '../../scripts/UIDef';
|
|
import { UI_BattleResult } from '../../scripts/UIDef';
|
|
|
|
+import { OriginArea } from './Component/OriginArea';
|
|
const { ccclass, property } = _decorator;
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('LevelAction')
|
|
@ccclass('LevelAction')
|
|
@@ -28,7 +28,7 @@ export class LevelAction extends Component {
|
|
tempCups: Node = null!; //临时杯
|
|
tempCups: Node = null!; //临时杯
|
|
|
|
|
|
@property(Node)
|
|
@property(Node)
|
|
- goblets: Node = null!; //原浆区
|
|
|
|
|
|
+ originArea: Node = null!; //原浆区
|
|
|
|
|
|
private originCupPositions = new Map<string, Vec3>(); // 改用唯一ID记录
|
|
private originCupPositions = new Map<string, Vec3>(); // 改用唯一ID记录
|
|
private isProcessing = false; // 添加状态锁
|
|
private isProcessing = false; // 添加状态锁
|
|
@@ -138,7 +138,7 @@ export class LevelAction extends Component {
|
|
return comp ? comp.cupColor : WaterColors.Blue;
|
|
return comp ? comp.cupColor : WaterColors.Blue;
|
|
});
|
|
});
|
|
|
|
|
|
- this.goblets.children.forEach(originCupNode => {
|
|
|
|
|
|
+ this.originArea.children.forEach(originCupNode => {
|
|
const originCup = originCupNode.getComponent(OriginCup)!;
|
|
const originCup = originCupNode.getComponent(OriginCup)!;
|
|
const waters = originCup.waters.children;
|
|
const waters = originCup.waters.children;
|
|
|
|
|
|
@@ -257,7 +257,7 @@ export class LevelAction extends Component {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // 新增方法:处理暂存区倒水到调酒区
|
|
|
|
|
|
+ //处理暂存区倒水到调酒区
|
|
private async handlePourTempCupToOutArea() {
|
|
private async handlePourTempCupToOutArea() {
|
|
if (this.isProcessing) return;
|
|
if (this.isProcessing) return;
|
|
this.isProcessing = true;
|
|
this.isProcessing = true;
|
|
@@ -355,6 +355,7 @@ export class LevelAction extends Component {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //倒水移动动画
|
|
private async pourAnimation(
|
|
private async pourAnimation(
|
|
origin: Node,
|
|
origin: Node,
|
|
target: Node,
|
|
target: Node,
|
|
@@ -382,7 +383,7 @@ export class LevelAction extends Component {
|
|
.start();
|
|
.start();
|
|
});
|
|
});
|
|
|
|
|
|
- // 正确应用返回动画逻辑
|
|
|
|
|
|
+ // 返回到暂存区初始位置
|
|
if (isTempCup && originalPos) {
|
|
if (isTempCup && originalPos) {
|
|
await new Promise(resolve => {
|
|
await new Promise(resolve => {
|
|
tween(origin)
|
|
tween(origin)
|
|
@@ -393,7 +394,7 @@ export class LevelAction extends Component {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // 新增辅助方法
|
|
|
|
|
|
+ //隐藏原浆杯当前水层
|
|
private hideCurrentWaterLayer(originCup: OriginCup) {
|
|
private hideCurrentWaterLayer(originCup: OriginCup) {
|
|
const activeWaters = originCup.waters.children.filter(n => n.active);
|
|
const activeWaters = originCup.waters.children.filter(n => n.active);
|
|
if (activeWaters.length >= 0) {
|
|
if (activeWaters.length >= 0) {
|
|
@@ -417,8 +418,8 @@ export class LevelAction extends Component {
|
|
const uiTransform = this.node.getComponent(UITransform)!;
|
|
const uiTransform = this.node.getComponent(UITransform)!;
|
|
newCup.setPosition(-uiTransform.width / 2, 0, 0);
|
|
newCup.setPosition(-uiTransform.width / 2, 0, 0);
|
|
newCup.getComponent(OriginCup)!.cupHeight = height;
|
|
newCup.getComponent(OriginCup)!.cupHeight = height;
|
|
|
|
+ this.originArea.addChild(newCup);
|
|
this.setupOriginCupColors(newCup, colors);
|
|
this.setupOriginCupColors(newCup, colors);
|
|
- this.goblets.addChild(newCup);
|
|
|
|
|
|
|
|
// 记录新杯子的初始位置
|
|
// 记录新杯子的初始位置
|
|
this.originCupPositions.set(newCup.uuid, targetPos);
|
|
this.originCupPositions.set(newCup.uuid, targetPos);
|
|
@@ -445,16 +446,19 @@ export class LevelAction extends Component {
|
|
private setupOriginCupColors(cupNode: Node, colors: WaterColors[]) {
|
|
private setupOriginCupColors(cupNode: Node, colors: WaterColors[]) {
|
|
const originCup = cupNode.getComponent(OriginCup)!;
|
|
const originCup = cupNode.getComponent(OriginCup)!;
|
|
const waters = originCup.waters.children;
|
|
const waters = originCup.waters.children;
|
|
-
|
|
|
|
// console.log(`新创建原浆杯,高度: ${originCup.cupHeight}`);
|
|
// console.log(`新创建原浆杯,高度: ${originCup.cupHeight}`);
|
|
|
|
+ const markCount = this.originArea.getComponent(OriginArea)?.getTotalMarkCount();
|
|
const waterCount = originCup.cupHeight;
|
|
const waterCount = originCup.cupHeight;
|
|
for (let i = 0; i < waterCount; i++) {
|
|
for (let i = 0; i < waterCount; i++) {
|
|
const waterNode = waters[i];
|
|
const waterNode = waters[i];
|
|
if (!waterNode) continue;
|
|
if (!waterNode) continue;
|
|
|
|
|
|
const water = waterNode.getComponent(Water)!;
|
|
const water = waterNode.getComponent(Water)!;
|
|
|
|
+ const mark = TakeGobletGlobalInstance.instance.refreshQuestionWater(markCount);
|
|
water.color = colors[Math.floor(Math.random() * colors.length)];
|
|
water.color = colors[Math.floor(Math.random() * colors.length)];
|
|
waterNode.active = true;
|
|
waterNode.active = true;
|
|
|
|
+ // console.log('mark: ', mark);
|
|
|
|
+ water.setMark(mark);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|