public static void Test(LevelSet levelSet, Level level) { if (ccTestProcess != null && !ccTestProcess.HasExited) { ccTestProcess.Kill(); } var chipsExeFile = Properties.Settings.Default.ChipsChallengeLocation; var sourcePath = ChipsChallengeDirectory; var destPath = ChipsChallengeTestDirectory; if (!Directory.Exists(destPath)) { Directory.CreateDirectory(destPath); } levelSet.Save(Path.Combine(destPath, "CCT_Data")); var newChipsExeLocation = Path.Combine(destPath, @"CCTest.exe"); CopyFiles(sourcePath, destPath); try { File.Copy(chipsExeFile, newChipsExeLocation, true); using (var fs = new FileStream(newChipsExeLocation, FileMode.Open, FileAccess.Write, FileShare.Read)) { fs.Seek(0x4a68, SeekOrigin.Begin); var buffer1 = new byte[] { 0x43, 0x43, 0x54, 0x65, 0x6D, 0x70, 0x2E, 0x69, 0x6E, 0x69, 0x00, 0x00, 0x63, 0x68, 0x69, 0x70, 0x73, 0x20, 0x74, 0x65, 0x6D, 0x70, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00 }; fs.Write(buffer1, 0, buffer1.Length); fs.Seek(0x4ad4, SeekOrigin.Begin); var buffer2 = new byte[] { 0x43, 0x43, 0x54, 0x5F, 0x44, 0x61, 0x74, 0x61, 0x00 }; fs.Write(buffer2, 0, buffer2.Length); } } catch (IOException) { throw new ApplicationException("Please close any existing instances of Chip's Challenge before testing."); } var windowsDirectory = Properties.Settings.Default.WindowsDirectory; if (!Directory.Exists(windowsDirectory)) { Directory.CreateDirectory(windowsDirectory); } var ccTempPath = Path.Combine(windowsDirectory, "CCTemp.ini"); var ccTemp = level == null?Properties.Resources.CCTemp.Replace("Level{0}={1}\r\nCurrent Level={0}\r\n", string.Empty) : string.Format(CultureInfo.CurrentCulture, Properties.Resources.CCTemp, level.Index + 1, level.Password); File.WriteAllText(ccTempPath, ccTemp, Encoding.Default); ccTestProcess = Process.Start(new ProcessStartInfo { WorkingDirectory = destPath, FileName = Path.Combine(destPath, "CCTest.exe") }); }
public static void CompleteLevel(Level l) { Level.Save(l); List <Level> levels = Levels[l.setName]; LevelSet nextSet = null; CurrentLevel = l; //First unlock the next set. for (int i = 0; i < instance.LevelSets.Length; i++) { if (i + 1 < instance.LevelSets.Length && instance.LevelSets[i].levelSetName.Equals(l.setName)) { nextSet = instance.LevelSets[i + 1]; } } if (nextSet != null && nextSet.unlocked == false) { //Debug.Log("Next Set"); nextSet.unlocked = true; nextSet.Save(); Level nextLevel = Levels[nextSet.levelSetName][0]; if (nextLevel.unlocked == false) { nextLevel.unlocked = true; Level.Save(nextLevel); } } //Second unlock the next level in the current set if there is more levels if (l.id + 1 < levels.Count) { Level nextLevel = levels[l.id + 1]; //If the level is not yet unlocked, unlock the level and save the value if (nextLevel.unlocked == false) { nextLevel.unlocked = true; Level.Save(nextLevel); } } }
private void SaveInvoke() { levelSet.Save(); }
public void OpenSetFirstTime() { set.animated = true; set.Save(); StartCoroutine(UnlockFirstTime()); }