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
            });
        }
Exemple #2
0
 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
             }));
         }
     }
 }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
 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);
 }
Exemple #5
0
 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);
 }