public JsonResult Load(string fileName) { CombatSave saved = Combat.LoadCombat(fileName); s_CurrentRow = saved.Current; s_Rows = saved.Rows; return(new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = s_Rows }); }
public static void SaveCombat(CombatRow current, List <CombatRow> allRows, string fileName) { using (FileStream st = new FileStream(s_fileLoc + Path.DirectorySeparatorChar + fileName, FileMode.Create)) { using (StreamWriter stw = new StreamWriter(st)) { stw.Write(JsonConvert.SerializeObject(new CombatSave() { Rows = allRows, Current = current })); } } }
public void RemoveCharacter(int id) { CombatRow toRemove = null; foreach (CombatRow row in s_Rows) { if (id == row.Actor.Id) { toRemove = row; break; } } if (toRemove != null) { s_Rows.Remove(toRemove); Clients.All.removeCharacter(id); } }
public void PrevInitiative() { if (s_Rows.Count == 0) { return; } if (s_CurrentRow == null || !s_Rows.Contains(s_CurrentRow)) { s_CurrentRow = s_Rows.Last(); } else { int index = s_Rows.IndexOf(s_CurrentRow) - 1; if (index < 0) { index = s_Rows.Count - 1; } s_CurrentRow = s_Rows[index]; } Clients.All.updateInitiative(s_CurrentRow.Actor.Id); }
public void NextInitiative() { if (s_Rows.Count == 0) { return; } if (s_CurrentRow == null || !s_Rows.Contains(s_CurrentRow)) { s_CurrentRow = s_Rows.First(); } else { int index = s_Rows.IndexOf(s_CurrentRow) + 1; if (index >= s_Rows.Count) { index = 0; } s_CurrentRow = s_Rows[index]; } Clients.All.updateInitiative(s_CurrentRow.Actor.Id); }