|
|
@@ -58,6 +58,18 @@ export class EnemyController extends BaseSingleton {
|
|
|
@property({ type: Node, tooltip: '拖拽 BottomFence 节点到这里' })
|
|
|
public bottomFenceNode: Node = null;
|
|
|
|
|
|
+ @property({
|
|
|
+ type: Node,
|
|
|
+ tooltip: '拖拽 Line5 节点到这里 (Canvas/GameLevelUI/enemyContainer/Line5)'
|
|
|
+ })
|
|
|
+ public line5Node: Node = null;
|
|
|
+
|
|
|
+ @property({
|
|
|
+ type: Node,
|
|
|
+ tooltip: '拖拽 Line6 节点到这里 (Canvas/GameLevelUI/enemyContainer/Line6)'
|
|
|
+ })
|
|
|
+ public line6Node: Node = null;
|
|
|
+
|
|
|
// 关卡配置管理器节点
|
|
|
@property({
|
|
|
type: Node,
|
|
|
@@ -667,22 +679,47 @@ export class EnemyController extends BaseSingleton {
|
|
|
let driftWorldX = spawnWorldX;
|
|
|
let driftWorldY = spawnWorldY;
|
|
|
|
|
|
- // 获取屏幕边界(Canvas边界)
|
|
|
- const canvas = find('Canvas');
|
|
|
- if (canvas) {
|
|
|
- const canvasUI = canvas.getComponent(UITransform);
|
|
|
- if (canvasUI) {
|
|
|
- const screenHeight = canvasUI.height;
|
|
|
- const canvasWorldPos = canvas.worldPosition;
|
|
|
-
|
|
|
- if (fromTop) {
|
|
|
- // 从Line1生成,漂移到屏幕上边界位置-30px
|
|
|
- const screenTop = canvasWorldPos.y + screenHeight / 2;
|
|
|
- driftWorldY = screenTop - 30;
|
|
|
- } else {
|
|
|
- // 从Line2生成,漂移到屏幕下边界位置+30px
|
|
|
- const screenBottom = canvasWorldPos.y - screenHeight / 2;
|
|
|
- driftWorldY = screenBottom + 30;
|
|
|
+ // 获取漂移目标线节点
|
|
|
+ let targetLineNode: Node = null;
|
|
|
+ if (fromTop) {
|
|
|
+ // 从Line1生成,漂移到Line5
|
|
|
+ targetLineNode = this.line5Node || enemyContainer.getChildByName('Line5');
|
|
|
+ console.log(`[EnemyController] 从Line1生成敌人,查找Line5节点: this.line5Node=${!!this.line5Node}, 通过名称查找=${!!enemyContainer.getChildByName('Line5')}`);
|
|
|
+ } else {
|
|
|
+ // 从Line2生成,漂移到Line6
|
|
|
+ targetLineNode = this.line6Node || enemyContainer.getChildByName('Line6');
|
|
|
+ console.log(`[EnemyController] 从Line2生成敌人,查找Line6节点: this.line6Node=${!!this.line6Node}, 通过名称查找=${!!enemyContainer.getChildByName('Line6')}`);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (targetLineNode && targetLineNode.isValid) {
|
|
|
+ // 使用目标线的Y坐标作为漂移目标
|
|
|
+ driftWorldY = targetLineNode.worldPosition.y;
|
|
|
+ console.log(`[EnemyController] 使用新逻辑:目标线节点找到`);
|
|
|
+ console.log(`[EnemyController] 节点名称: ${targetLineNode.name}`);
|
|
|
+ console.log(`[EnemyController] 本地坐标Y: ${targetLineNode.position.y}`);
|
|
|
+ console.log(`[EnemyController] 世界坐标Y: ${targetLineNode.worldPosition.y}`);
|
|
|
+ console.log(`[EnemyController] 漂移目标Y坐标: ${driftWorldY}`);
|
|
|
+ } else {
|
|
|
+ console.log(`[EnemyController] 目标线节点未找到或无效,使用旧逻辑(屏幕边界)`);
|
|
|
+ // 如果找不到目标线节点,回退到原来的屏幕边界逻辑
|
|
|
+ const canvas = find('Canvas');
|
|
|
+ if (canvas) {
|
|
|
+ const canvasUI = canvas.getComponent(UITransform);
|
|
|
+ if (canvasUI) {
|
|
|
+ const screenHeight = canvasUI.height;
|
|
|
+ const canvasWorldPos = canvas.worldPosition;
|
|
|
+
|
|
|
+ if (fromTop) {
|
|
|
+ // 从Line1生成,漂移到屏幕上边界位置-30px
|
|
|
+ const screenTop = canvasWorldPos.y + screenHeight / 2;
|
|
|
+ driftWorldY = screenTop - 30;
|
|
|
+ console.log(`[EnemyController] 旧逻辑:从Line1漂移到屏幕上边界,Y坐标: ${driftWorldY}`);
|
|
|
+ } else {
|
|
|
+ // 从Line2生成,漂移到屏幕下边界位置+30px
|
|
|
+ const screenBottom = canvasWorldPos.y - screenHeight / 2;
|
|
|
+ driftWorldY = screenBottom + 30;
|
|
|
+ console.log(`[EnemyController] 旧逻辑:从Line2漂移到屏幕下边界,Y坐标: ${driftWorldY}`);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|