Exemplo n.º 1
0
 public void LoadAutosave(string InFilename)
 {
     try
     {
         FileStream File = new FileStream(InFilename, FileMode.Open);
         CurData = AIData.Load(File);
         File.Close();
     }
     catch (System.Exception e)
     {
         Debug.Log("Load autosave exception: " + e.Message);
     }
 }
Exemplo n.º 2
0
    public void ReceiveAIData(string JudgeGuid, string InData)
    {
        AIData NewAiData = AIData.Load(Global.GenerateStreamFromString(InData));

        if (NewAiData != null)
        {
            TeamData TData = Global.GetTeamData(NewAiData.Division, NewAiData.Round, NewAiData.Pool, NewAiData.Team);
            if (TData != null)
            {
                bool bNewScore = TData.RoutineScores.SetAIResults(NewAiData);

                OnRecievedResultsData(bNewScore);
            }
        }
    }
Exemplo n.º 3
0
    public override void RecoverAutosave()
    {
        base.RecoverAutosave();

        BackupList.Clear();

        string BackupPath = Application.persistentDataPath + "/Backup";

        string[] Files = Directory.GetFiles(BackupPath);
        foreach (string filename in Files)
        {
            if (filename.Contains("AIBackup"))
            {
                BackupAIData backup = new BackupAIData();
                try
                {
                    FileStream BackupFile = new FileStream(filename, FileMode.Open);
                    backup.Data     = AIData.Load(BackupFile);
                    backup.Filename = filename;
                    BackupFile.Close();
                }
                catch (System.Exception e)
                {
                    Debug.Log("Load autosave exception: " + e.Message);
                }

                backup.WrittenTime = File.GetLastWriteTime(filename);
                BackupList.Add(backup);
            }
        }

        BackupList.Sort(
            delegate(BackupAIData b1, BackupAIData b2)
        {
            if (b1 == b2)
            {
                return(0);
            }
            else if (b1.WrittenTime < b2.WrittenTime)
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        });

        // Delete old backup files
        if (BackupList.Count > Global.MaxBackupFileCount)
        {
            for (int FileIndex = Global.MaxBackupFileCount; FileIndex < BackupList.Count; ++FileIndex)
            {
                try
                {
                    File.Delete(BackupList[FileIndex].Filename);
                }
                catch (System.Exception e)
                {
                    Debug.Log("Delete old backup files exception: " + e.Message);
                }
            }

            while (BackupList.Count > Global.MaxBackupFileCount)
            {
                BackupList.RemoveAt(Global.MaxBackupFileCount);
            }
        }
    }