NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Pause/Impl/ParticalPauser.cs

80 lines
1.7 KiB
C#
Raw Normal View History

2023-08-22 19:08:45 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Gameplay.Common;
2023-12-13 16:20:41 +08:00
using Gameplay.Unit;
2023-08-22 19:08:45 +08:00
namespace Gameplay.Pause
{
using UnityEngine;
using Character;
using Gameplay.Skill;
public class ParticalPauser : IPauser
{
2023-10-19 15:00:19 +08:00
public readonly ParticleSystem rawPartical;
2023-08-22 19:08:45 +08:00
private float _logicScale = 1f;
public float logicScale
{
get
{
return _logicScale;
}
}
public bool isScaleChanged;
public GameUnit owner;
public ParticalPauser(ParticleSystem rawPartical)
{
isScaleChanged = false;
this.rawPartical = rawPartical;
}
public void LogicUpdate(float dt)
{
if (IsNeedRemove())
{
return;
}
var slogicScale = 1;
if (SkillManager.instance.needSkillPaused && SkillManager.instance.inSkillingUnit != owner)
2023-08-22 19:08:45 +08:00
{
slogicScale = 0;
}
2023-10-19 15:00:19 +08:00
if (Math.Abs(_logicScale - slogicScale) > 0.1f)
2023-08-22 19:08:45 +08:00
{
_logicScale = slogicScale;
isScaleChanged = true;
}
if (isScaleChanged || PauseManager.instance.isSpeedChanged)
{
isScaleChanged = false;
var main = rawPartical.main;
main.simulationSpeed = PauseManager.instance.globalScale * logicScale;
}
}
2023-10-19 15:00:19 +08:00
public bool isEffect
{
get;
set;
}
2023-08-22 19:08:45 +08:00
public bool IsNeedRemove()
{
return rawPartical == null || rawPartical.isStopped;
}
2024-02-20 15:17:22 +08:00
2023-08-22 19:08:45 +08:00
}
}