让人绝望的bug,存档

This commit is contained in:
2025-05-08 22:08:01 +08:00
parent ac545da1bd
commit a44a80edee
2 changed files with 4699 additions and 67 deletions
File diff suppressed because it is too large Load Diff
@@ -42,6 +42,8 @@ public class LakeLineDrawer : ImmediateModeShapeDrawer
public Color targetFillColor = Color.red; // 目标点实体颜色
public Color targetWireColor = Color.white; // 目标点线框颜色
public float wireScale = 1.05f; // 线框相对于实体的大小比例
public float targetColorInfluenceRange = 5f; // 目标点颜色影响范围
public float targetColorInfluenceStrength = 1f; // 目标点颜色影响强度
[Header("可视区域")]
public float visibleAreaSize = 20f;
@@ -121,10 +123,6 @@ public class LakeLineDrawer : ImmediateModeShapeDrawer
public Vector2 gridPosition; // 网格位置(0到pointCount-1
public TargetType type;
public Color color = Color.white;
[Range(1f, 10f)]
public float range = 2f; // 目标的影响范围
[Range(0f, 1f)]
public float shapeInfluence = 0.5f; // 形状影响程度
[HideInInspector]
public float visibility = 0f; // 可见度
[HideInInspector]
@@ -459,6 +457,11 @@ public class LakeLineDrawer : ImmediateModeShapeDrawer
if (CheckObstacleCollision(ripple.position, spread, currentTime))
return;
// 计算当前点与所有目标的距离,找到最近的目标
float minTargetDist = float.MaxValue;
Color nearestTargetColor = Color.white;
float nearestTargetInfluence = 0f;
foreach (var target in targetPoints)
{
float step = fieldSize / (pointCount - 1);
@@ -472,17 +475,23 @@ public class LakeLineDrawer : ImmediateModeShapeDrawer
float targetSpreadFactor = Mathf.Exp(-Mathf.Pow((targetDist - spread) / (maxRadius * 0.3f), 2f) * rippleSharpness * (1f - t * 0.5f));
float targetInfluence = targetDistanceFactor * targetSpreadFactor;
if (targetInfluence > maxTargetInfluence)
// 更新最近的目标信息
if (targetInfluence > nearestTargetInfluence)
{
maxTargetInfluence = targetInfluence;
targetColor = target.color;
shapeDistortion = targetInfluence * target.shapeInfluence * fadeCurve;
nearestTargetInfluence = targetInfluence;
nearestTargetColor = target.color;
minTargetDist = targetDist;
}
// 如果涟漪触碰到目标,触发目标效果
if (!isTargetTrigger && targetDist < 0.5f && target.lastTriggerTime < currentTime - targetTriggerDuration)
// 检查涟漪是否触碰到目标
if (!isTargetTrigger && targetDist < 0.5f && target.lastTriggerTime < currentTime - targetTriggerDuration)
{
// 确保目标点之前没有被触发过
if (target.lastTriggerTime <= 0)
{
target.lastTriggerTime = currentTime;
target.isFound = true;
target.visibility = 0.2f; // 初始可见度
targetTriggerRipples.Add(new Ripple
{
position = new Vector2(targetX, targetZ),
@@ -499,6 +508,14 @@ public class LakeLineDrawer : ImmediateModeShapeDrawer
}
}
}
// 根据最近目标的影响程度,计算颜色过渡
if (nearestTargetInfluence > 0)
{
// 使用目标影响程度来混合颜色,并考虑涟漪的衰减
float colorBlend = nearestTargetInfluence * (1f - fadeT) * targetColorInfluenceStrength;
targetColor = Color.Lerp(targetColor, nearestTargetColor, colorBlend);
}
}
private bool CheckObstacleCollision(Vector2 ripplePos, float spread, float currentTime)
@@ -628,16 +645,7 @@ public class LakeLineDrawer : ImmediateModeShapeDrawer
float baseHeight = GetHeight(x, z, time);
RippleResult ripple = GetRippleEffect(x, z, Time.time);
// 应用形状扭曲
float shapeOffset = 0f;
if (ripple.shapeDistortion > 0)
{
// 使用正弦波创建扭曲效果
float angle = Mathf.Atan2(z - fieldOffset.y, x - fieldOffset.x);
shapeOffset = Mathf.Sin(angle * 4f + time * 2f) * ripple.shapeDistortion;
}
float finalY = baseHeight + ripple.heightOffset + shapeOffset;
float finalY = baseHeight + ripple.heightOffset;
// 创建点的坐标
Vector3 pos = new Vector3(x, finalY, z);
@@ -994,17 +1002,25 @@ public class LakeLineDrawer : ImmediateModeShapeDrawer
private void UpdateTargetVisibility()
{
float currentTime = Time.time;
foreach (var target in targetPoints)
{
// 如果目标已经被触发过
if (target.lastTriggerTime > 0)
{
// 更新可见度
target.visibility = Mathf.Min(1f, target.visibility + Time.deltaTime * targetFadeInSpeed);
// 更新大小
float targetScale = 1f + (targetMaxScale - 1f) * Mathf.Sin(Time.time * targetScaleSpeed);
float targetScale = 1f + (targetMaxScale - 1f) * Mathf.Sin(currentTime * targetScaleSpeed);
target.scale = Mathf.Lerp(target.scale, targetScale, Time.deltaTime * targetScaleSpeed);
}
else
{
// 如果从未被触发过,确保保持不可见
target.visibility = 0f;
target.scale = 1f;
}
}
}
@@ -1086,10 +1102,6 @@ public class LakeLineDrawer : ImmediateModeShapeDrawer
float z = -halfField + target.gridPosition.y * step + fieldOffset.y;
float height = GetHeight(x, z, time);
// 绘制目标范围
Gizmos.color = new Color(target.color.r, target.color.g, target.color.b, 0.1f);
Gizmos.DrawWireSphere(new Vector3(x, height, z), target.range);
// 绘制目标点
Gizmos.color = target.color;
Gizmos.DrawSphere(new Vector3(x, height + targetHeightOffset, z), targetSize * 0.5f);