NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/Level.Speed.cs

69 lines
1.5 KiB
C#

using Framework;
using Gameplay.Pause;
namespace Gameplay.Level
{
public static class ELevelSpeed
{
public static float Normal = 1f;
public static float Fast = 2f;
public static float Slow = 0.5f;
public static float SuperFast = 4f;
}
public partial class Level
{
private bool _isPause = false;
private float _speed = ELevelSpeed.Normal;
public void SetPause(bool pause)
{
_isPause = pause;
if (PauseManager.instance != null)
{
PauseManager.instance.globalScale = _isPause ? 0 : _speed;
}
EventManager.Instance.Send(EventManager.EventName.LevelFightUIPauseChange);
}
public void SetSpeed(float speed)
{
if (speed < 0)
{
DebugUtil.LogError("错误的速度值: {0}", speed);
return;
}
_speed = speed;
if (PauseManager.instance != null)
{
PauseManager.instance.globalScale = _isPause ? 0 : _speed;
}
EventManager.Instance.Send(EventManager.EventName.LevelSpeedChange);
}
public bool IsPause()
{
return _isPause;
}
public float GetSpeed()
{
return _speed;
}
public bool IsSpeed(float speed)
{
return _speed - speed < 0.01f && _speed - speed > -0.01f;
}
}
}