public void SetupData() { World.VillageName = "Tall Trees"; World[0].Name = "Rep"; //World[0].Col = Color.red; World[0].Set(0); (World[0] as Stat).SetLevel(1); RepLast = 1; World[1].Name = "Funds"; //World[1].Col = Color.green; World[1].Set(0); World[2].Name = "Meds"; //World[2].Col = Color.blue; World[2].Set(0); FundsHourly = new GoodBoy(TimeLast, new System.TimeSpan(1, 0, 0)); Grands.Clear(); for (int i = 0; i < World.Population; i++) { Grands.Add(GameManager.Generator.GenerateGrand()); } }
public void Load() { Debug.Log("---- LOADING FROM " + Save_Target); Grands = new List <GrandData>(); if (!System.IO.File.Exists(Save_Target)) { Debug.Log("COULDN'T FIND SAVE FILE"); SetupData(); Save(); return; } Save_Data = SaveData.Load(Save_Target); Debug.Log("--LOADING SAVE DATA: " + Save_Data); if (Save_Data == null) { Debug.Log("COULDN'T FIND SAVE FILE"); SetupData(); return; } if (!Save_Data.TryGetValue <System.DateTime>("Time", out TimeLast)) { TimeLast = System.DateTime.Now; } FundsHourly = new GoodBoy(TimeLast, new System.TimeSpan(1, 0, 0)); //Loading World string [] s; if (Save_Data.TryGetValue <string[]>("World-Resources", out s)) { //World = new WorldResources(); for (int i = 0; i < s.Length; i++) { World[i].Name = s[i]; World[i].Multiplier = Save_Data.GetValue <float>("World-" + s[i] + "-Multiplier"); //World[i].Index = Save_Data.GetValue<int>("World-"+s[i]+"-Index"); //World[i].Col = Save_Data.GetValue<Color>("World-"+s[i]+"-Col"); if (World[i] is Stat) { (World[i] as Stat).SetLevel(Save_Data.GetValue <int>("World-" + s[i] + "-Level")); } else { World[i].Max = Save_Data.GetValue <int>("World-" + s[i] + "-Max"); } World[i].Set(Save_Data.GetValue <int>("World-" + s[i] + "-Current")); } } RepLast = Save_Data.TryGetValue <int>("Rep Last"); //Loading Grands System.Guid [] prevhex; if (Save_Data.TryGetValue <System.Guid[]>("Prev Grands", out prevhex)) { for (int i = 0; i < World.Population; i++) { if (i >= prevhex.Length || prevhex[i] == null) { continue; } GrandData g = new GrandData(prevhex[i]); string pref = "Grand:" + prevhex[i].ToString(); g.Info.Name = Save_Data.TryGetValue <string>(pref + "-Name"); g.Info.Gender = Save_Data.TryGetValue <bool>(pref + "-Gender"); g.Info.PupilScale = Save_Data.TryGetValue <Vector3>(pref + "-Pupils"); g.Info.Nation = Save_Data.TryGetValue <NationStatus>(pref + "-Nation"); g.Info.C_Skin = Save_Data.TryGetValue <Color>(pref + "-C_Skin"); g.Info.C_Hair = Save_Data.TryGetValue <Color>(pref + "-C_Hair"); g.Info.C_Eye = Save_Data.TryGetValue <Color>(pref + "-C_Eye"); g.Info.C_Offset = Save_Data.TryGetValue <Color>(pref + "-C_Offset"); g.Info.C_Nose = Save_Data.TryGetValue <Color>(pref + "-C_Nose"); for (int a = 0; a < f_inf.Length; a++) { g.SetFaceInfo(f_inf[a], new FaceInfo( Save_Data.TryGetValue <int>(pref + "-" + f_inf[a] + ":Index"), Save_Data.TryGetValue <Vector3[]>(pref + "-" + f_inf[a] + ":Values"), Save_Data.TryGetValue <ColorType>(pref + "-" + f_inf[a] + ":Colour"))); } for (int r = 0; r < g.Resources.Length; r++) { g.Resources[r] = new Resource( Save_Data.TryGetValue <int>(pref + "-Res " + r + ":Index"), Save_Data.TryGetValue <int>(pref + "-Res " + r + ":Current"), Save_Data.TryGetValue <int>(pref + "-Res " + r + ":Max") ); g.Resources[r].Set(Save_Data.TryGetValue <int>(pref + "-Res " + r + ":Current")); System.TimeSpan span = System.TimeSpan.FromSeconds(Save_Data.GetValue <double>(pref + "-Res " + r + ":SpanSecs")); g.Resources[r].SetRate(Save_Data.TryGetValue <float>(pref + "-Res " + r + ":Rate"), span); g.Resources[r].TimeLast = Save_Data.TryGetValue <System.DateTime>(pref + "-Res " + r + ":TimeLast"); } Grands.Add(g); } } print("Loaded info: " + Grands.Count + " grands"); }