Added player load, added basic world load, v1.3.0
This commit is contained in:
parent
086910c7ca
commit
267dd1c626
@ -6,6 +6,8 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
@ -37,6 +39,9 @@ namespace Assets.Scripts
|
||||
{
|
||||
jsonString = jsonString + line.Replace("\r\n", "");
|
||||
}
|
||||
JArray json = JsonConvert.DeserializeObject<JArray>(jsonString);
|
||||
player.loadPlayer(json["player"]);
|
||||
worldGenerator.loadWorld(json["world"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Assets.Scripts.Classes;
|
||||
using Assets.Scripts.Races;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
@ -580,5 +581,64 @@ namespace Assets.Scripts
|
||||
result = result + FileHandler.generateJSON("difficulty", difficulty);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void loadPlayer(JToken json)
|
||||
{
|
||||
playername = json["playername"].ToString();
|
||||
maxHealth = (int)json["maxHealth"];
|
||||
maxSecondary = (int)json["maxSecondary"];
|
||||
secondary = (int)json["secondary"];
|
||||
health = (int)json["health"];
|
||||
strength = (int)json["strength"];
|
||||
dexterity = (int)json["dexterity"];
|
||||
intelligence = (int)json["intelligence"];
|
||||
level = (int)json["level"];
|
||||
experience = (int)json["experience"];
|
||||
maxExperience = (int)json["maxExperience"];
|
||||
loadRole(json["role"].ToString());
|
||||
loadRace(json["race"].ToString());
|
||||
points = (int)json["points"];
|
||||
isDodging = bool.Parse(json["isDodging"].ToString());
|
||||
killcount = (int)json["killcount"];
|
||||
difficulty = (int)json["difficulty"];
|
||||
}
|
||||
|
||||
private void loadRole(string name)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "Warrior":
|
||||
role = new WarriorClass();
|
||||
break;
|
||||
case "Mage":
|
||||
role = new MageClass();
|
||||
break;
|
||||
case "Thief":
|
||||
role = new ThiefClass();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void loadRace(string name)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "Human":
|
||||
race = new HumanRace();
|
||||
break;
|
||||
case "Dwarf":
|
||||
race = new DwarvenRace();
|
||||
break;
|
||||
case "Elf":
|
||||
race = new ElvenRace();
|
||||
break;
|
||||
case "Giant":
|
||||
race = new GiantRace();
|
||||
break;
|
||||
case "Goblin":
|
||||
race = new GoblinRace();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user