地图系统
This commit is contained in:
@@ -372,11 +372,25 @@ namespace BaseGames.Player
|
||||
public void OnLoad(SaveData saveData)
|
||||
{
|
||||
var p = saveData.Player;
|
||||
MaxHP = p.MaxHP;
|
||||
CurrentHP = Mathf.Clamp(p.CurrentHP, 0, MaxHP);
|
||||
CurrentLingZhu = p.CurrentLingZhu;
|
||||
_lifetimeLingZhu = p.LifetimeLingZhu;
|
||||
_unlockedAbilities = (AbilityType)p.AbilityFlags;
|
||||
|
||||
// 新档判定:MaxHP<=0 表示存档尚未初始化玩家数值(CreateSlot 创建的空档)。
|
||||
// 此时保留 Awake 从 _config 设置的初始值(避免被空档清零),并回写存档保持一致。
|
||||
if (p.MaxHP <= 0)
|
||||
{
|
||||
p.MaxHP = MaxHP;
|
||||
p.CurrentHP = CurrentHP;
|
||||
p.CurrentLingZhu = CurrentLingZhu;
|
||||
p.LifetimeLingZhu = _lifetimeLingZhu;
|
||||
p.AbilityFlags = (uint)_unlockedAbilities;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaxHP = p.MaxHP;
|
||||
CurrentHP = Mathf.Clamp(p.CurrentHP, 0, MaxHP);
|
||||
CurrentLingZhu = p.CurrentLingZhu;
|
||||
_lifetimeLingZhu = p.LifetimeLingZhu;
|
||||
_unlockedAbilities = (AbilityType)p.AbilityFlags;
|
||||
}
|
||||
|
||||
_onHPChanged?.Raise(CurrentHP);
|
||||
_onMaxHPChanged?.Raise(MaxHP);
|
||||
|
||||
Reference in New Issue
Block a user