public void restoreFromMemento(GameMemento memento) { if (memento != null) { hp = memento.getGameHp(); mp = memento.getGameMp(); exp = memento.getGameExp(); } }
private void AddState(string stateName, GameMemento memento) { if (!mMementos.ContainsKey(stateName)) { mMementos.Add(stateName, memento); } else { Console.WriteLine($"存檔失敗!{stateName}已重複"); } }
public void setMemento(string stateName, GameMemento memento) { if (mMementos.Count < restoreNumber) { AddState(stateName, memento); } else { Console.WriteLine($"已到達最大存檔次數:{restoreNumber},請充值最大次數"); } }