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

74 lines
1.7 KiB
C#

using Framework;
using Gameplay.Common;
using Gameplay.Pause;
using UnityEngine;
namespace Gameplay.Level
{
public static class ELevelSpeed
{
public static float Level_0 = 0f;
public static float Level_1 = 1f;
public static float Level_2 = 2f;
public static float Level_3 = 4f;
public static float DEFAULT_SPEED = 1F;
}
public partial class Level
{
private bool _isPause = false;
private float _speed = ELevelSpeed.Level_1;
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;
var scaleSpeed = Mathf.Max(1f, _speed);
CodeDefine.Fight.LIGHT_UP_TIME = scaleSpeed * 0.2f;
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;
}
}
}