修了很多bug和增加功能,优化不少问题

This commit is contained in:
2026-02-28 06:59:22 +08:00
parent 508a40bba0
commit e11cc1da7a
345 changed files with 173803 additions and 69332 deletions
@@ -36,6 +36,8 @@ public class GfxController : MonoBehaviour
public GameObject explosionFX;
public GameObject k_o_fx;
public GameObject koFatherObject;
public float koFxScale = 1f;
public int koFxSortingOrder = 31;
[Header("Explosion Effect Settings")]
[Tooltip("当单次伤害超过敌人最大生命值的百分比时触发爆炸 (0.2 = 20%)")]
@@ -117,8 +119,6 @@ public class GfxController : MonoBehaviour
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);
@@ -153,6 +153,37 @@ public class GfxController : MonoBehaviour
/// <param name="damageInfo">可选:传入伤害信息以判断是否触发爆炸特效 (damage, maxHealth)</param>
public void PlayHitFX(GameObject target, GameObject parent = null, bool isEnemy = false, Vector3? customWorldPos = null, float? scaleOverride = null, (float damage, float maxHealth)? damageInfo = null)
{
// --- Check if the target ally slot is active before playing VFX ---
if (!isEnemy && teamUIController.Instance != null)
{
int slot = -1;
var ally = target.GetComponent<AllyCombatant>();
if (ally != null) slot = ally.slotIndex;
else
{
string n = target.name.ToLower();
if (n.Contains("ally_01")) slot = 0;
else if (n.Contains("ally_02")) slot = 1;
else if (n.Contains("ally_03")) slot = 2;
else if (n.Contains("ally_04")) slot = 3;
else if (n.Contains("ally_05")) slot = 4;
}
if (slot != -1)
{
bool isActive = false;
switch (slot)
{
case 0: isActive = teamUIController.Instance.isAlly01_active; break;
case 1: isActive = teamUIController.Instance.isAlly02_active; break;
case 2: isActive = teamUIController.Instance.isAlly03_active; break;
case 3: isActive = teamUIController.Instance.isAlly04_active; break;
case 4: isActive = teamUIController.Instance.isAlly05_active; break;
}
if (!isActive) return; // Skip VFX for inactive ally
}
}
// Determine which FX prefab to use (Hit or Explosion)
GameObject fxPrefab = hitFX;
bool isExplosion = false;
@@ -390,6 +421,42 @@ public class GfxController : MonoBehaviour
{
if (source == null || target == null) return;
// --- Check if the source or target ally slot is active before playing VFX ---
if (teamUIController.Instance != null)
{
// Check source
var sourceAlly = source.GetComponent<AllyCombatant>();
if (sourceAlly != null)
{
bool isActive = false;
switch (sourceAlly.slotIndex)
{
case 0: isActive = teamUIController.Instance.isAlly01_active; break;
case 1: isActive = teamUIController.Instance.isAlly02_active; break;
case 2: isActive = teamUIController.Instance.isAlly03_active; break;
case 3: isActive = teamUIController.Instance.isAlly04_active; break;
case 4: isActive = teamUIController.Instance.isAlly05_active; break;
}
if (!isActive) { onComplete?.Invoke(target.transform.position); return; }
}
// Check target
var targetAlly = target.GetComponent<AllyCombatant>();
if (targetAlly != null)
{
bool isActive = false;
switch (targetAlly.slotIndex)
{
case 0: isActive = teamUIController.Instance.isAlly01_active; break;
case 1: isActive = teamUIController.Instance.isAlly02_active; break;
case 2: isActive = teamUIController.Instance.isAlly03_active; break;
case 3: isActive = teamUIController.Instance.isAlly04_active; break;
case 4: isActive = teamUIController.Instance.isAlly05_active; break;
}
if (!isActive) { onComplete?.Invoke(target.transform.position); return; }
}
}
GameObject prefab = allySkillProjectilePrefab != null ? allySkillProjectilePrefab : projectileFX;
if (prefab == null)
{
@@ -747,6 +814,18 @@ public class GfxController : MonoBehaviour
}
}
// 应用层级 Order In Layer
Renderer[] renderers = fx.GetComponentsInChildren<Renderer>(true);
foreach (var r in renderers)
{
r.sortingOrder = koFxSortingOrder;
}
Canvas[] canvases = fx.GetComponentsInChildren<Canvas>(true);
foreach (var c in canvases)
{
c.sortingOrder = koFxSortingOrder;
}
// 动画播放完后销毁
Destroy(fx, 3.0f);
}
@@ -763,6 +842,25 @@ public class GfxController : MonoBehaviour
return false;
}
// --- Check if the target ally slot is active before playing VFX ---
if (teamUIController.Instance != null)
{
bool isActive = false;
switch (allySlotIndex)
{
case 0: isActive = teamUIController.Instance.isAlly01_active; break;
case 1: isActive = teamUIController.Instance.isAlly02_active; break;
case 2: isActive = teamUIController.Instance.isAlly03_active; break;
case 3: isActive = teamUIController.Instance.isAlly04_active; break;
case 4: isActive = teamUIController.Instance.isAlly05_active; break;
}
if (!isActive)
{
// If inactive, skip VFX and return false so SkillBuilder applies immediate (but blocked) damage
return false;
}
}
GameObject targetAllyObj = GetAllyObject(allySlotIndex);
if (targetAllyObj == null)
{