mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-12 12:25:53 +00:00
Saving and loading difficulty
This commit is contained in:
parent
a2319b3b88
commit
22a1ec5ba2
1 changed files with 6 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Enums;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
|
@ -214,7 +215,8 @@ public partial class GlobalState : Node
|
|||
var serializedSavedata = new Godot.Collections.Dictionary<string, Variant>()
|
||||
{
|
||||
{ "Items", items },
|
||||
{ "Level", SessionSettings.LevelNumber }
|
||||
{ "Level", SessionSettings.LevelNumber },
|
||||
{ "Difficulty", (int)SessionSettings.Difficulty}
|
||||
};
|
||||
|
||||
var saveFile = FileAccess.Open(SaveNameFile, FileAccess.ModeFlags.Write);
|
||||
|
|
@ -248,6 +250,8 @@ public partial class GlobalState : Node
|
|||
|
||||
Dictionary<string, int> items = (Dictionary<string, int>)deserializedSaveData["Items"];
|
||||
|
||||
DifficultyLevel difficulty = (DifficultyLevel)deserializedSaveData["Difficulty"].AsInt32();
|
||||
|
||||
int levelNumber = (int)deserializedSaveData["Level"];
|
||||
|
||||
var levelData = _mapsDatabase.Maps.FirstOrDefault(x => x.LevelId == levelNumber);
|
||||
|
|
@ -259,6 +263,7 @@ public partial class GlobalState : Node
|
|||
this.SessionSettings.NewSession();
|
||||
SessionSettings.LevelNumber = levelNumber;
|
||||
SessionSettings.Items = items;
|
||||
SessionSettings.Difficulty = difficulty;
|
||||
|
||||
this.GotoScene(levelData);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue