(client) feat:支持定义实体的碰撞体大小和偏移;建筑支持定义实体建筑和瓦片建筑,建筑支持指定按钮回调;添加存档管理器;Dev支持设置是否暂停;实体允许定义事件组;添加基地界面 (#57)

Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com>
Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/57
This commit is contained in:
2025-09-28 15:02:57 +08:00
parent 87a8abe86c
commit aff747be17
232 changed files with 39203 additions and 4161 deletions

View File

@@ -47,8 +47,11 @@ namespace CameraControl
}
}
public Vector3 Position => CurrentCamera.transform.position;
private int dimensionId; // 当前摄像机控制器关注的维度索引
private string[] dimensionList; // 维度名称列表
private string[] dimensionList=>Program.Instance.Dimensions; // 维度名称列表
private Dimension currentDimension;
/// <summary>
/// MonoSingleton 的 OnStart 方法,在单例首次创建并激活时调用,早于普通的 Start 方法。
@@ -57,6 +60,7 @@ namespace CameraControl
protected override void OnStart()
{
Program.Instance.OnFocusedDimensionChanged += Init;
Clock.AddTick(this);
}
/// <summary>
@@ -66,6 +70,7 @@ namespace CameraControl
private void OnDestroy()
{
Program.Instance.OnFocusedDimensionChanged -= Init;
}
@@ -76,8 +81,6 @@ namespace CameraControl
/// <param name="obj">当前聚焦的维度对象。</param>
private void Init(Dimension obj)
{
dimensionList = Program.Instance.Dimensions;
if (!CurrentCamera) // 如果摄像机仍未找到,记录错误并返回
{
Debug.LogError("[CameraControl] 未找到摄像机!摄像机控制功能将无法完全初始化。");
@@ -87,12 +90,11 @@ namespace CameraControl
// 处理 obj 为 null 的情况 - 此时 dimensionList 已更新
if (!obj)
{
Debug.LogWarning("[CameraControl] Init方法在聚焦维度为空时调用。维度列表已更新但摄像机状态未基于特定维度设置。");
return;
}
// 根据当前聚焦维度同步 CameraControl 内部的 dimensionId
int focusedIndex = System.Array.IndexOf(dimensionList, obj.name);
var focusedIndex = System.Array.IndexOf(dimensionList, obj.name);
if (focusedIndex != -1)
{
dimensionId = focusedIndex;
@@ -102,26 +104,24 @@ namespace CameraControl
Debug.LogWarning($"[CameraControl] 聚焦维度 '{obj.name}' 未在维度列表中找到。回退到ID 0。");
dimensionId = 0; // 找不到时,回退到第一个维度,避免数组越界
}
// 设置摄像机位置到当前聚焦维度的位置
if (Program.Instance.FocusedDimension != null)
CurrentCamera.transform.position = new Vector3(obj.cameraPosition.x, obj.cameraPosition.y, -10f);
if(currentDimension)
{
CurrentCamera.transform.position = Program.Instance.FocusedDimension.cameraPosition;
}
else
{
Debug.LogWarning("[CameraControl] 尝试设置摄像机位置时,聚焦维度为空。摄像机位置未明确根据维度更新。");
currentDimension.OnDimensionLoaded-=DimensionLoaded;
}
currentDimension = obj;
currentDimension.OnDimensionLoaded+=DimensionLoaded;
}
/// <summary>
/// 调用带参数的 Init 方法,使用 Program.Instance 中当前聚焦的维度。
/// </summary>
private void Init()
private void DimensionLoaded(Dimension obj)
{
Init(Program.Instance.FocusedDimension);
if (obj == Program.Instance.FocusedDimension)
{
CurrentCamera.transform.position = new Vector3(obj.cameraPosition.x, obj.cameraPosition.y, -10f);
}
}
/// <summary>
/// 切换到下一个维度。
/// 会保存当前摄像机位置到当前维度,然后加载下一个维度的摄像机位置。
@@ -185,7 +185,6 @@ namespace CameraControl
Debug.LogWarning($"[CameraControl] 维度ID {id} 超出范围或维度列表为空,无法设置聚焦维度。");
return;
}
Program.Instance.SetFocusedDimension(dimensionList[id]);
}
@@ -242,7 +241,7 @@ namespace CameraControl
/// </summary>
private void HandleMiddleMouseDrag()
{
if (!CurrentCamera) return; // 确保相机存在
if (!Program.Instance.CanMoveCamera) return;
// 开始拖拽:检测鼠标中键按下
if (Input.GetMouseButtonDown(2)) // 鼠标中键