Beispiel #1
0
        void SaveCraddleFiles(bool newLevel)
        {
            //CradleOfRome2_e0600-n2702-h0685_2.zip
            GetLevelsFromSaveDirectory();
            _lastLevel = _currentLevel;
            if (newLevel)
            {
                if (_blitzLevelType == CradleOfRomeBlitzLevelType.Easy)
                {
                    _currentLevel.EasyLevel++;
                }
                else if (_blitzLevelType == CradleOfRomeBlitzLevelType.Normal)
                {
                    _currentLevel.NormalLevel++;
                }
                else if (_blitzLevelType == CradleOfRomeBlitzLevelType.Hard)
                {
                    _currentLevel.HardLevel++;
                }
                else
                {
                    //throw new Exception(string.Format("Error bad blitz level type \"{0}\"", gBlitzLevelType));
                    Message("Error bad blitz level type \"{0}\"", _blitzLevelType);
                }
                _currentLevel.FileNumber = 1;
            }
            else
            {
                _currentLevel.FileNumber++;
            }
            //string zipFile = string.Format("CradleOfRome2_e{0:0000}-n{1:0000}-h{2:0000}{3}.zip", gEasyLevel, gNormalLevel, gHardLevel, gFileNumber == 1 ? "" : string.Format("_{0}", gFileNumber));
            string zipFile = _currentLevel.GetFilename();

            Message("save craddle files to \"{0}\"", zipFile);
            //////////throw new Exception("error test test test test test");
            zipFile = zPath.Combine(_cradleFileSaveDirectory, zipFile);
            ZipFile zip = new ZipFile();

            if (!zDirectory.Exists(_cradleFileSaveDirectory))
            {
                zDirectory.CreateDirectory(_cradleFileSaveDirectory);
            }
            zip.AddFile(zPath.Combine(_cradleFileDirectory, "config.xml"), "");
            zip.AddFile(zPath.Combine(_cradleFileDirectory, "hiscores.xml"), "");
            zip.AddFile(zPath.Combine(_cradleFileDirectory, "profiles.xml"), "");
            zip.Save(zipFile);
            zip.Dispose();
            if (CraddleFilesSaved != null)
            {
                CraddleFilesSaved();
            }
            ArchiveOldLevels();
            //_cradleFileCopyDirectory
            if (newLevel)
            {
                CopySavedFile(zipFile);
            }
        }
Beispiel #2
0
 public void RunCraddleLastLevel()
 {
     if (_currentLevel != _lastLevel)
     {
         DeleteFileLevel(_currentLevel);
         _currentLevel = _lastLevel;
     }
     Message("Start craddle of rome 2 {0}", _lastLevel.GetFilename());
     CopyFileLevel(_lastLevel);
     Process.Start(_cradleProgram);
 }
Beispiel #3
0
        private void CopyFileLevel(CradleOfRomeBlitzLevel level)
        {
            _fileSystemWatcher.EnableRaisingEvents = false;
            ZipFile zip = new ZipFile(zPath.Combine(_cradleFileSaveDirectory, level.GetFilename()));

            //zip["config.xml"].Extract(gCradleFileDirectory, true);
            zip["config.xml"].Extract(_cradleFileDirectory, ExtractExistingFileAction.OverwriteSilently);
            //zip["hiscores.xml"].Extract(gCradleFileDirectory, true);
            zip["hiscores.xml"].Extract(_cradleFileDirectory, ExtractExistingFileAction.OverwriteSilently);
            //zip["profiles.xml"].Extract(gCradleFileDirectory, true);
            zip["profiles.xml"].Extract(_cradleFileDirectory, ExtractExistingFileAction.OverwriteSilently);
            zip.Dispose();
            _fileSystemWatcher.EnableRaisingEvents = true;
        }
Beispiel #4
0
 private void DeleteFileLevel(CradleOfRomeBlitzLevel level)
 {
     Message("Delete craddle of rome 2 level {0}", level.GetFilename());
     zFile.Delete(zPath.Combine(_cradleFileSaveDirectory, level.GetFilename()));
 }