分辨率和UI问题修复

This commit is contained in:
2025-09-08 18:00:46 +08:00
parent be91190c47
commit b07a2efc25
10 changed files with 52 additions and 1646 deletions
@@ -6,7 +6,7 @@ namespace AibisDream.FixSystem
{
public class CableSystem : MonoBehaviour
{
private const string CABLE_RETRACTED_KEY = "$global.cableRetracted";
private const string CableRetractedKey = "$global.cableRetracted";
#region
@@ -59,8 +59,7 @@ namespace AibisDream.FixSystem
DialogController.OnDialogueStart -= HandleDialogueStart;
DialogController.OnDialogueComplete -= HandleDialogueComplete;
}
private void InitComponentRefs()
{
PlugRef = transform.Find("Plug").GetComponent<Plug>();
@@ -86,7 +85,7 @@ namespace AibisDream.FixSystem
private void LoadCableState()
{
if (StorageSystem.Instance.TryGetValue(CABLE_RETRACTED_KEY, out bool savedRetractedState))
if (StorageSystem.Instance.TryGetValue(CableRetractedKey, out bool savedRetractedState))
{
if (isCableRetracted)
{
@@ -108,7 +107,7 @@ namespace AibisDream.FixSystem
private void SaveCableState()
{
Debug.Log("Save cableRetractedstate" + isCableRetracted);
StorageSystem.Instance.SetValue(CABLE_RETRACTED_KEY, isCableRetracted);
StorageSystem.Instance.SetValue(CableRetractedKey, isCableRetracted);
}
private void Update()
@@ -150,6 +149,7 @@ namespace AibisDream.FixSystem
private void HandleDialogueComplete()
{
Debug.Log("Dialog End");
isInDialog = false;
}
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Shapes;
using UnityEngine;
using UnityEngine.Rendering.Universal;
using UnityEngine.VFX;
@@ -94,10 +93,7 @@ public class GearFollower : MonoBehaviour
private Vector3 targetPosition = Vector3.zero;
private bool isInTractionMode = false;
private bool isDrillSfxPlaying = false; // 标记音效是否已播放
void Start()
{
}
public void Init(SpriteRenderer targetSpriteRenderer)
{
SpriteRenderer gearRenderer = GetComponent<SpriteRenderer>();
@@ -145,10 +141,7 @@ public class GearFollower : MonoBehaviour
sparkVFX.Stop();
}
}
void Update()
{
}
public void GearUpdate()
{
// 获取鼠标在屏幕上的位置
@@ -156,16 +149,7 @@ public class GearFollower : MonoBehaviour
// 将屏幕坐标转换为世界坐标
Vector3 mouseWorldPos = mainCamera.ScreenToWorldPoint(new Vector3(mouseScreenPos.x, mouseScreenPos.y, -mainCamera.transform.position.z));
mouseWorldPos.z = 0; // 确保z坐标为0
Debug.Log($"鼠标屏幕坐标: {mouseScreenPos}");
Debug.Log($"鼠标世界坐标: {mouseWorldPos}");
Debug.Log($"齿轮当前位置: {transform.position}");
if (targetSpriteRenderer != null)
{
Debug.Log($"目标精灵位置: {targetSpriteRenderer.transform.position}");
Debug.Log($"目标精灵边界: {targetSpriteRenderer.bounds}");
}
if (Input.GetMouseButton(0))
{
transform.Rotate(Vector3.forward, -360f * Time.deltaTime);
@@ -311,17 +295,13 @@ public class GearFollower : MonoBehaviour
worldPoint1 = ClampPosition(worldPoint1, spriteWorldPos, maxScale);
worldPoint2 = ClampPosition(worldPoint2, spriteWorldPos, maxScale);
Debug.Log($"点 {i} 局部坐标: {localPoint1} -> 世界坐标: {worldPoint1}");
// 计算相对于精灵中心点的缩放
Vector3 scaledPoint1 = spriteWorldPos + (worldPoint1 - spriteWorldPos) * edgePointsScale;
Vector3 scaledPoint2 = spriteWorldPos + (worldPoint2 - spriteWorldPos) * edgePointsScale;
// 确保缩放后的点也在合理范围内
scaledPoint1 = ClampPosition(scaledPoint1, spriteWorldPos, maxScale);
scaledPoint2 = ClampPosition(scaledPoint2, spriteWorldPos, maxScale);
Debug.Log($"点 {i} 缩放后世界坐标: {scaledPoint1}");
scaledPoint2 = ClampPosition(scaledPoint2, spriteWorldPos, maxScale); ;
float segmentLength = Vector3.Distance(scaledPoint1, scaledPoint2);
int steps = Mathf.Max(1, Mathf.CeilToInt(segmentLength / desiredSegmentLength));
@@ -384,11 +364,9 @@ public class GearFollower : MonoBehaviour
Vector2 prev = edgePoints[WrapIndex(currentEdgeIndex - 1)];
Vector2 next = edgePoints[WrapIndex(currentEdgeIndex + 1)];
Debug.Log($"前一个点: {prev}, 后一个点: {next}");
float distToPrev = Vector2.Distance(mousePos, prev);
float distToNext = Vector2.Distance(mousePos, next);
Debug.Log($"到前一个点距离: {distToPrev}, 到后一个点距离: {distToNext}");
tractionDirection = (distToNext < distToPrev) ? 1 : -1;
@@ -555,9 +533,6 @@ public class GearFollower : MonoBehaviour
{
visiblePoints.Add(timedPoint.position);
}
else
{
}
}
cutLineRenderer.positionCount = visiblePoints.Count;
@@ -640,7 +615,6 @@ public class GearFollower : MonoBehaviour
{
totalEdgeLength += Vector2.Distance(edgePoints[i], edgePoints[i + 1]);
}
Debug.Log($"计算总边缘长度: {totalEdgeLength}");
}
private void UpdateCutProgress(Vector2 from, Vector2 to)
@@ -654,7 +628,6 @@ public class GearFollower : MonoBehaviour
// 计算切割进度
float progress = cutLength / totalEdgeLength;
Debug.Log($"当前切割长度: {cutLength}, 总长度: {totalEdgeLength}, 进度: {progress * 100}%");
// 更新切割进度
var cuttingManager = FixSystemCenter.SystemDic.Get<CuttingManager>();
@@ -926,11 +899,6 @@ public class GearFollower : MonoBehaviour
// 停止音效的辅助方法
private void StopDrillSfxIfPlaying()
{
var audioManager = AibisDream.Kit.AudioManager.Instance;
if (audioManager != null)
{
audioManager.StopSfx("event:/FollowInput/drill");
}
AudioManager.Instance?.StopSfx("event:/FollowInput/drill");
}
}