优化技能CD配置
This commit is contained in:
@@ -174,7 +174,7 @@ namespace GameFramework
|
||||
float sprintCD = cdField != null ? (float)cdField.GetValue(_playerController) : 1f;
|
||||
float lastRoll = lastField != null ? (float)lastField.GetValue(_playerController) : -999f;
|
||||
float remaining = Mathf.Max(0f, (lastRoll + sprintCD) - Time.time);
|
||||
UpdateSkillCD(skillSprintCD, remaining, sprintCD);
|
||||
UpdateSkillCD(skillSprintCD, skillSprintIcon, remaining, sprintCD);
|
||||
}
|
||||
|
||||
// 摇铃 CD(从 EchoSystem 读取 cooldown + _lastEchoTime)
|
||||
@@ -187,7 +187,7 @@ namespace GameFramework
|
||||
float bellCD = cdField != null ? (float)cdField.GetValue(_echoSystem) : 2f;
|
||||
float lastTime = lastField != null ? (float)lastField.GetValue(_echoSystem) : -999f;
|
||||
float remaining = Mathf.Max(0f, (lastTime + bellCD) - Time.time);
|
||||
UpdateSkillCD(skillBellCD, remaining, bellCD);
|
||||
UpdateSkillCD(skillBellCD, skillBellIcon, remaining, bellCD);
|
||||
}
|
||||
|
||||
// 灵灯 CD(从 SpiritLanternSystem 读取)
|
||||
@@ -197,27 +197,44 @@ namespace GameFramework
|
||||
var cdField = typeof(SpiritLanternSystem).GetField("cooldown",
|
||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
float maxCD = cdField != null ? (float)cdField.GetValue(_lanternSystem) : 3f;
|
||||
UpdateSkillCD(skillLanternCD, remaining, maxCD);
|
||||
UpdateSkillCD(skillLanternCD, skillLanternIcon, remaining, maxCD);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新单个技能CD遮罩。
|
||||
/// fillAmount = 1 表示CD中(完全遮挡),0 表示就绪(无遮挡)。
|
||||
/// CD 时图标变灰,就绪时恢复。
|
||||
/// </summary>
|
||||
private void UpdateSkillCD(Image cdImage, float remaining, float total)
|
||||
{
|
||||
UpdateSkillCD(cdImage, null, remaining, total);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新单个技能CD遮罩 + 图标去色。
|
||||
/// </summary>
|
||||
private void UpdateSkillCD(Image cdImage, Image iconImage, float remaining, float total)
|
||||
{
|
||||
if (cdImage == null) return;
|
||||
|
||||
if (total <= 0f || remaining <= 0f)
|
||||
{
|
||||
cdImage.fillAmount = 0f;
|
||||
cdImage.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
bool onCooldown = total > 0f && remaining > 0f;
|
||||
|
||||
if (onCooldown)
|
||||
{
|
||||
cdImage.gameObject.SetActive(true);
|
||||
cdImage.fillAmount = remaining / total;
|
||||
// CD 中图标变灰
|
||||
if (iconImage != null)
|
||||
iconImage.color = new Color(0.4f, 0.4f, 0.4f, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
cdImage.fillAmount = 0f;
|
||||
cdImage.gameObject.SetActive(false);
|
||||
// CD 就绪图标恢复原色
|
||||
if (iconImage != null)
|
||||
iconImage.color = Color.white;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,10 +59,10 @@ Material:
|
||||
- _DecalMeshDepthBias: 0
|
||||
- _DecalMeshViewBias: 0
|
||||
- _DrawOrder: 0
|
||||
- _FadeAlpha: 1
|
||||
- _FadeAlpha: 0.9602355
|
||||
- _RippleAmplitude: 0.0412
|
||||
- _RippleFrequency: 10.5
|
||||
- _RippleIntensity: -0
|
||||
- _RippleIntensity: 0.6882374
|
||||
- _RippleSpeed: 3
|
||||
- _Shininess: 0.2
|
||||
- _Stencil: 0
|
||||
|
||||
Reference in New Issue
Block a user