gameplay所有基本功能都装了,加入了全局警告。加入飘字等各种东西。
This commit is contained in:
@@ -66,7 +66,7 @@ public class GfxController : MonoBehaviour
|
||||
public float allyFxTransparency = 1f;
|
||||
public int allyFxSortingOrder = 10;
|
||||
|
||||
[Header("Projectile Settings")]
|
||||
[Header("Ally Attack Projectile")]
|
||||
public float projectileDuration = 0.5f;
|
||||
public AnimationCurve projectileSpeedCurve = AnimationCurve.Linear(0, 0, 1, 1);
|
||||
[Range(0f, 1f)]
|
||||
@@ -74,6 +74,13 @@ public class GfxController : MonoBehaviour
|
||||
public float projectileScale = 1f;
|
||||
[Tooltip("弹道颜色控制 (影响 Trail 和 Particle)")]
|
||||
public Gradient projectileColor;
|
||||
[Tooltip("弹道到达终点时的随机偏移范围 - X轴")]
|
||||
public float projectileRandomOffsetX = 0f;
|
||||
[Tooltip("弹道到达终点时的随机偏移范围 - Y轴")]
|
||||
public float projectileRandomOffsetY = 0f;
|
||||
[Tooltip("弹道到达终点时的随机偏移范围 - Z轴")]
|
||||
public float projectileRandomOffsetZ = 0f;
|
||||
public int projectileSortingOrder = 10;
|
||||
|
||||
[Header("敌人攻击控件")]
|
||||
[Tooltip("Miss时敌人攻击角色的弹道特效")]
|
||||
@@ -91,15 +98,28 @@ public class GfxController : MonoBehaviour
|
||||
[Tooltip("Miss弹道速度曲线")]
|
||||
public AnimationCurve enemyAttackSpeedCurve = AnimationCurve.Linear(0, 0, 1, 1);
|
||||
|
||||
public float koFxScale = 1f;
|
||||
[Tooltip("弹道到达终点时的随机偏移范围 - X轴")]
|
||||
public float projectileRandomOffsetX = 0f;
|
||||
[Tooltip("弹道到达终点时的随机偏移范围 - Y轴")]
|
||||
public float projectileRandomOffsetY = 0f;
|
||||
[Tooltip("弹道到达终点时的随机偏移范围 - Z轴")]
|
||||
public float projectileRandomOffsetZ = 0f;
|
||||
public int projectileSortingOrder = 10;
|
||||
[Header("Ally Skill Projectile")]
|
||||
[Tooltip("友军技能释放的弹道特效")]
|
||||
public GameObject allySkillProjectilePrefab;
|
||||
[Tooltip("友军技能弹道颜色控制")]
|
||||
public Gradient allySkillProjectileColor;
|
||||
[Tooltip("友军技能弹道移动时间")]
|
||||
public float allySkillProjectileDuration = 0.5f;
|
||||
[Tooltip("友军技能弹道缩放")]
|
||||
public float allySkillProjectileScale = 1.0f;
|
||||
[Tooltip("友军技能弹道层级")]
|
||||
public int allySkillProjectileSortingOrder = 15;
|
||||
[Tooltip("友军技能弹道速度曲线")]
|
||||
public AnimationCurve allySkillSpeedCurve = AnimationCurve.Linear(0, 0, 1, 1);
|
||||
[Tooltip("友军技能弹道到达时的随机偏移范围 - X轴")]
|
||||
public float allySkillRandomOffsetX = 0f;
|
||||
[Tooltip("友军技能弹道到达时的随机偏移范围 - Y轴")]
|
||||
public float allySkillRandomOffsetY = 0f;
|
||||
[Tooltip("友军技能弹道到达时的随机偏移范围 - Z轴")]
|
||||
public float allySkillRandomOffsetZ = 0f;
|
||||
|
||||
public float koFxScale = 1f;
|
||||
|
||||
[Header("Enemy Hurt Shake Settings")]
|
||||
public Vector3 hitShakeAmplitude = new Vector3(10f, 10f, 0f);
|
||||
public Vector3 hitShakeFrequency = new Vector3(20f, 20f, 0f);
|
||||
@@ -352,6 +372,52 @@ public class GfxController : MonoBehaviour
|
||||
StartCoroutine(MoveProjectileCoroutine(projectile, startTransform, endTransform, targetRandomOffset, onComplete));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 触发友军技能弹道:从施法者飞向目标友军
|
||||
/// </summary>
|
||||
public void PlayAllySkillProjectile(GameObject source, GameObject target, Action<Vector3> onComplete = null)
|
||||
{
|
||||
if (source == null || target == null) return;
|
||||
|
||||
GameObject prefab = allySkillProjectilePrefab != null ? allySkillProjectilePrefab : projectileFX;
|
||||
if (prefab == null)
|
||||
{
|
||||
Debug.LogWarning("[GfxController] allySkillProjectilePrefab 未分配且无默认 projectileFX!");
|
||||
onComplete?.Invoke(target.transform.position);
|
||||
return;
|
||||
}
|
||||
|
||||
// 核心修正:将逻辑物体映射到 UI 挂载点
|
||||
GameObject visualSource = ResolveGfxMountPoint(source);
|
||||
GameObject visualTarget = ResolveGfxMountPoint(target);
|
||||
|
||||
Transform startTransform = visualSource != null ? visualSource.transform : source.transform;
|
||||
Transform endTransform = visualTarget != null ? visualTarget.transform : target.transform;
|
||||
|
||||
GameObject projectile = Instantiate(prefab, startTransform.position, Quaternion.identity);
|
||||
projectile.transform.SetParent(this.transform, true);
|
||||
projectile.transform.localScale = Vector3.one * allySkillProjectileScale;
|
||||
|
||||
// 应用层级(复用 projectileTransparency)
|
||||
ApplyTransparencyAndRender(projectile, projectileTransparency, allySkillProjectileSortingOrder);
|
||||
|
||||
// 应用颜色
|
||||
ApplyColorToEffect(projectile, allySkillProjectileColor);
|
||||
|
||||
// 计算随机偏移
|
||||
Vector3 targetRandomOffset = Vector3.zero;
|
||||
if (allySkillRandomOffsetX > 0f || allySkillRandomOffsetY > 0f || allySkillRandomOffsetZ > 0f)
|
||||
{
|
||||
targetRandomOffset = new Vector3(
|
||||
UnityEngine.Random.Range(-allySkillRandomOffsetX, allySkillRandomOffsetX),
|
||||
UnityEngine.Random.Range(-allySkillRandomOffsetY, allySkillRandomOffsetY),
|
||||
UnityEngine.Random.Range(-allySkillRandomOffsetZ, allySkillRandomOffsetZ)
|
||||
);
|
||||
}
|
||||
|
||||
StartCoroutine(MoveAllySkillProjectileCoroutine(projectile, startTransform, endTransform, targetRandomOffset, onComplete));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将逻辑战斗物体(Ally/Enemy)映射到 GfxController 中定义的 UI 挂载点
|
||||
/// </summary>
|
||||
@@ -442,6 +508,64 @@ public class GfxController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator MoveAllySkillProjectileCoroutine(GameObject projectile, Transform start, Transform end, Vector3 targetOffset, Action<Vector3> onComplete)
|
||||
{
|
||||
float elapsed = 0f;
|
||||
Vector3 startPos = start.position;
|
||||
Vector3 lastEndPos = startPos;
|
||||
|
||||
while (elapsed < allySkillProjectileDuration)
|
||||
{
|
||||
if (projectile == null)
|
||||
{
|
||||
onComplete?.Invoke(lastEndPos);
|
||||
yield break;
|
||||
}
|
||||
|
||||
elapsed += Time.deltaTime;
|
||||
float normalizedTime = Mathf.Clamp01(elapsed / allySkillProjectileDuration);
|
||||
|
||||
// 使用动画曲线计算插值比例
|
||||
float t = allySkillSpeedCurve.Evaluate(normalizedTime);
|
||||
|
||||
// 如果目标还在,更新目标位置(支持动态移动的目标)
|
||||
Vector3 currentEndPos = end != null ? end.position + targetOffset : projectile.transform.position;
|
||||
lastEndPos = currentEndPos;
|
||||
|
||||
projectile.transform.position = Vector3.Lerp(startPos, currentEndPos, t);
|
||||
|
||||
// 可选:让拖尾朝向移动方向
|
||||
if (t > 0)
|
||||
{
|
||||
Vector3 direction = currentEndPos - startPos;
|
||||
if (direction != Vector3.zero)
|
||||
{
|
||||
projectile.transform.rotation = Quaternion.LookRotation(Vector3.forward, direction);
|
||||
}
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// 到达终点,触发回调并传回终点坐标
|
||||
onComplete?.Invoke(lastEndPos);
|
||||
|
||||
// 到达后销毁
|
||||
if (projectile != null)
|
||||
{
|
||||
ParticleSystem[] ps = projectile.GetComponentsInChildren<ParticleSystem>();
|
||||
if (ps.Length > 0)
|
||||
{
|
||||
foreach (var p in ps) p.Stop(true, ParticleSystemStopBehavior.StopEmitting);
|
||||
Destroy(projectile, 1.0f); // 给一点时间让残余粒子消失
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(projectile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 为特效物体及其子物体中的 TrailRenderer 和 ParticleSystem 应用颜色渐变
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user