SamsonGame/Assets/Scripts/Game/Save/LevelReward.cs

41 lines
1012 B
C#

using game;
using UnityEngine;
public class LevelReward
{
public bool HaveItem => _itemId != null;
public uint ItemId => _itemId ?? 0;
public float Progress => _progress;
private uint? _itemId;
private float _progress;
public void ResetProgress() => _progress = 0;
public void ResetItemWithProgress()
{
_itemId = 0;
_progress = 0;
}
public void ChangeItemWithProgress(uint itemId, float progress)
{
SetItem(itemId);
SetProgress(progress);
}
public void SetItem(uint itemId) => _itemId = itemId;
public void SetProgress(float progress) => _progress = progress;
public LevelReward(DataGame data)
{
_itemId = data.progress.levelReward.itemId;
_progress = data.progress.levelReward.progress;
}
public void Save(DataGame data)
{
data.progress.levelReward.itemId = ItemId;
data.progress.levelReward.progress = Progress;
}
}