feat: 移除自适应性能相关配置并调整动画控制器 移除了Unity自适应性能(Adaptive Performance)的相关配置文件, 包括Adaptive Performance文件夹及其子目录中的所有配置文件, 同时移除了移动通知(NotificationSettings)相关配置, 以及第一章第一关(level_chapter1_level1)的关卡配置文件, 还删除了多个材质文件如AdjustableGlowOrb、AdjustableGlowOrbHalo 和Arena相关材质。另外微调了base-人类士兵.controller中状态机 的位置坐标,将x坐标从320调整为330。 ```
128 lines
3.0 KiB
C#
128 lines
3.0 KiB
C#
using UnityEngine;
|
|
|
|
public class StatusEffectController : MonoBehaviour
|
|
{
|
|
[Header("通用眩晕显示")]
|
|
[SerializeField] private bool showStunIndicator = true;
|
|
[SerializeField] private float indicatorHeight = 0.35f;
|
|
[SerializeField] private GameObject stunIndicatorPrefab;
|
|
|
|
private Animator animator;
|
|
private float stunnedRemaining;
|
|
private float animatorSpeedBeforeStun = 1f;
|
|
private GameObject stunIndicator;
|
|
private Transform indicatorTransform;
|
|
|
|
public bool IsStunned => stunnedRemaining > 0f;
|
|
public float StunnedRemaining => Mathf.Max(0f, stunnedRemaining);
|
|
|
|
private void Awake()
|
|
{
|
|
animator = GetComponent<Animator>();
|
|
}
|
|
|
|
public void ApplyStun(float duration)
|
|
{
|
|
if (duration <= 0f)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!IsStunned && animator != null)
|
|
{
|
|
animatorSpeedBeforeStun = animator.speed;
|
|
}
|
|
|
|
stunnedRemaining = Mathf.Max(stunnedRemaining, duration);
|
|
if (animator != null)
|
|
{
|
|
animator.speed = 0f;
|
|
}
|
|
|
|
if (showStunIndicator)
|
|
{
|
|
EnsureIndicator();
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!IsStunned)
|
|
{
|
|
return;
|
|
}
|
|
|
|
stunnedRemaining -= Time.deltaTime;
|
|
if (animator != null)
|
|
{
|
|
animator.speed = 0f;
|
|
}
|
|
|
|
if (stunnedRemaining <= 0f)
|
|
{
|
|
stunnedRemaining = 0f;
|
|
if (animator != null)
|
|
{
|
|
UnitBase unitBase = GetComponent<UnitBase>();
|
|
animator.speed = unitBase != null
|
|
? Mathf.Max(0.01f, unitBase.AttackSpeedMultiplier)
|
|
: 1f;
|
|
}
|
|
DestroyIndicator();
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (indicatorTransform == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Bounds bounds = new Bounds(transform.position, Vector3.zero);
|
|
Renderer[] renderers = GetComponentsInChildren<Renderer>(true);
|
|
if (renderers.Length > 0)
|
|
{
|
|
bounds = renderers[0].bounds;
|
|
for (int i = 1; i < renderers.Length; i++)
|
|
{
|
|
bounds.Encapsulate(renderers[i].bounds);
|
|
}
|
|
}
|
|
|
|
indicatorTransform.position = new Vector3(
|
|
bounds.center.x,
|
|
bounds.max.y + indicatorHeight,
|
|
bounds.center.z);
|
|
|
|
}
|
|
|
|
private void EnsureIndicator()
|
|
{
|
|
if (stunIndicator != null || stunIndicatorPrefab == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
stunIndicator = Instantiate(stunIndicatorPrefab);
|
|
stunIndicator.name = "StunIndicator_Particle";
|
|
indicatorTransform = stunIndicator.transform;
|
|
}
|
|
|
|
private void DestroyIndicator()
|
|
{
|
|
if (stunIndicator != null)
|
|
{
|
|
Destroy(stunIndicator);
|
|
}
|
|
|
|
stunIndicator = null;
|
|
indicatorTransform = null;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
DestroyIndicator();
|
|
}
|
|
}
|