mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-30 00:31:29 +08:00
fix(scenes) 种田系统测试,添加按钮等
This commit is contained in:
1 parent
ce4e04740a
commit
761a9338ba
19 files changed
+1248
-86
No files matched your search
+36
-7
@@ -143,20 +143,28 @@ export class InputSystem {
|
||||
// 如果点中了物品,不执行后续操作,避免触发移动
|
||||
this.selectionStart = null;
|
||||
this.dragStart = null;
|
||||
} else if (this.enabledModes.selection && !this.isCameraLocked()) {
|
||||
// 如果没有点中单位,且框选功能启用,且相机未锁定,开始框选操作
|
||||
} else if (this.enabledModes.selection && !this.isCameraLocked() && !this.isInPlantingMode()) {
|
||||
// 如果没有点中单位,且框选功能启用,且相机未锁定,且不在种植模式,开始框选操作
|
||||
// 存储框选开始时的世界坐标
|
||||
this.selectionStart = { x: worldX, y: worldY };
|
||||
// 没有点中单位,清除dragStart
|
||||
this.dragStart = null;
|
||||
} else if (this.isInPlantingMode()) {
|
||||
// 如果处于种植模式,不执行任何选择或框选操作
|
||||
this.selectionStart = null;
|
||||
this.dragStart = null;
|
||||
}
|
||||
} else if (pointer.rightButtonDown() && this.enabledModes.mouse) {
|
||||
// 如果是右键按下且鼠标模式启用,发送移动到指定点的事件
|
||||
} else if (pointer.rightButtonDown() && this.enabledModes.mouse && !this.isInPlantingMode()) {
|
||||
// 如果是右键按下且鼠标模式启用,且不在种植模式,发送移动到指定点的事件
|
||||
const worldX = pointer.worldX;
|
||||
const worldY = pointer.worldY;
|
||||
this.scene.events.emit('move-to-point', worldX, worldY);
|
||||
// 右键点击,清除dragStart
|
||||
this.dragStart = null;
|
||||
} else if (pointer.rightButtonDown() && this.isInPlantingMode()) {
|
||||
// 如果处于种植模式,右键点击不执行任何操作
|
||||
this.dragStart = null;
|
||||
this.selectionStart = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +227,7 @@ export class InputSystem {
|
||||
const dragDistance = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
// 如果拖动距离超过阈值(10像素),视为拖动操作
|
||||
if (dragDistance > 10 && this.enabledModes.mouse) {
|
||||
if (dragDistance > 10 && this.enabledModes.mouse && !this.isInPlantingMode()) {
|
||||
// 发送移动到指定点的事件,让单位移动到释放位置
|
||||
this.scene.events.emit('move-to-point', currentWorldX, currentWorldY);
|
||||
}
|
||||
@@ -242,8 +250,8 @@ export class InputSystem {
|
||||
);
|
||||
|
||||
// 如果框选区域太小(宽度和高度都小于10像素),视为点击地面移动
|
||||
if (rect.width < 10 && rect.height < 10 && this.enabledModes.mouse) {
|
||||
// 发送移动到指定点的事件(仅在鼠标模式启用时)
|
||||
if (rect.width < 10 && rect.height < 10 && this.enabledModes.mouse && !this.isInPlantingMode()) {
|
||||
// 发送移动到指定点的事件(仅在鼠标模式启用时,且不在种植模式下)
|
||||
this.scene.events.emit('move-to-point', pointer.worldX, pointer.worldY);
|
||||
} else {
|
||||
// 否则执行框选操作
|
||||
@@ -290,6 +298,15 @@ export class InputSystem {
|
||||
* @returns {boolean} - 如果鼠标在UI元素上返回true,否则返回false
|
||||
*/
|
||||
isMouseOnUI(pointer) {
|
||||
// 检查是否点击在作物详情面板上
|
||||
if (this.scene.cropDetailsPanel) {
|
||||
const detailsRect = this.scene.cropDetailsPanel.getBounds();
|
||||
if (pointer.x >= detailsRect.x && pointer.x <= detailsRect.right &&
|
||||
pointer.y >= detailsRect.y && pointer.y <= detailsRect.bottom) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return this.isMouseOnMiniMap(pointer) ||
|
||||
this.isMouseOnJoystick(pointer) ||
|
||||
this.isMouseOnSidebar(pointer) ||
|
||||
@@ -297,6 +314,18 @@ export class InputSystem {
|
||||
this.isMouseOnItemListUI(pointer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前是否处于种植或收获模式
|
||||
* @returns {boolean} - 如果处于种植或收获模式返回true,否则返回false
|
||||
*/
|
||||
isInPlantingMode() {
|
||||
// 检查场景是否处于种植模式,或者是否有取消种植按钮,或者是否显示作物详情面板
|
||||
// 这样可以确保点击取消种植按钮或收获按钮时,不会触发角色移动
|
||||
return this.scene.isPlantingMode ||
|
||||
(this.scene.cancelPlantingButton && this.scene.cancelPlantingButton.active) ||
|
||||
(this.scene.cropDetailsPanel && this.scene.cropDetailsPanel.visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查鼠标是否在物品列表菜单上
|
||||
* @param {Phaser.Input.Pointer} pointer - 指针事件对象
|
||||
|
||||
Reference in new issue
Block a user