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

69 lines
1.4 KiB
C#
Raw Normal View History

using Framework;
2023-08-22 19:08:45 +08:00
using Gameplay.Pause;
2023-12-14 19:42:05 +08:00
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;
2023-08-22 19:08:45 +08:00
if (PauseManager.instance != null)
{
PauseManager.instance.globalScale = _isPause ? 0 : _speed;
}
2023-12-14 19:42:05 +08:00
}
public void SetSpeed(float speed)
{
if (speed < 0)
{
DebugUtil.LogError("错误的速度值: {0}", speed);
return;
}
_speed = speed;
if (PauseManager.instance != null)
2023-08-22 19:08:45 +08:00
{
PauseManager.instance.globalScale = _isPause ? 0 : _speed;
}
EventManager.Instance.Send(EventManager.EventName.LevelSpeedChange);
2023-08-22 19:08:45 +08:00
}
2023-12-14 19:42:05 +08:00
public bool IsPause()
{
return _isPause;
}
2023-08-22 19:08:45 +08:00
2023-12-14 19:42:05 +08:00
public float GetSpeed()
{
return _speed;
2023-08-22 19:08:45 +08:00
}
2023-12-14 19:42:05 +08:00
public bool IsSpeed(float speed)
{
return _speed - speed < 0.01f && _speed - speed > -0.01f;
}
}
}