Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Game.Entity;
- using Game.Scripts.Core.Entity.Stats;
- namespace Game.Scripts.Battle.Units
- {
- public class StatModifier
- {
- public string Guid;
- public float Value;
- public int Order;
- }
- public class UnitBuffExample
- {
- private readonly EntityStatsStorage _statsStorage;
- private SceneUnit _sceneUnit;
- private StatModifier _modifier;
- public UnitBuffExample(EntityStatsStorage statsStorage)
- {
- _statsStorage = statsStorage;
- }
- public void Init(IEntity parentEntity)
- {
- _sceneUnit = parentEntity as SceneUnit;
- if (_sceneUnit == null)
- return;
- var entityStats = _statsStorage.Get(_sceneUnit.Guid);
- var hpStat = entityStats.Get<float>("HP");
- _modifier = new StatModifier
- {
- Guid = System.Guid.NewGuid().ToString(),
- Value = 10f,
- Order = 0
- };
- hpStat.ApplyModifier(_modifier);
- }
- public void Dispose()
- {
- var entityStats = _statsStorage.Get(_sceneUnit.Guid);
- var hpStat = entityStats.Get<float>("HP");
- hpStat.RemoveModifier(_modifier);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment