/// <summary> /// Test one or more files as specified on the command line /// </summary> /// <returns>number of failures</returns> static int Testfiles() { int rc = 0; foreach (FileRecord File in config.Files) { if (File.Sentinal) { Sentinal sentinal = new Sentinal(File.Path); if (sentinal.Test()) { Console.WriteLine(" Passed: " + File.Path + " R=" + sentinal.Randomness); } else { Console.WriteLine(" Failed: " + File.Path + " " + sentinal.Error); try { if (sentinal.Randomness < 400) { Console.WriteLine(" " + File.Path + " APPEARS TO BE ENCRYPTED " + sentinal.Randomness); } } catch (Exception) { Console.WriteLine(" " + File.Path + " is missing or not accessible "); } rc++; } } } Console.WriteLine("RC=" + rc); return(rc); }
// Update is called once per frame void Update() { //make array of sentinal gameobjects by finding sentinals scripts Sentinal[] sentinals = GameObject.FindObjectsOfType <Sentinal>(); Sentinal closestEnemy = null; float dist = Mathf.Infinity; // search sentinals to find closest one to this object foreach (Sentinal s in sentinals) { float d = Vector3.Distance(this.transform.position, s.transform.position); if (closestEnemy == null || d < dist) { closestEnemy = s; dist = d; } } // if there are no more sentinals if (closestEnemy == null) { Debug.Log("No Sentinals To Shoot"); return; } // rotate towards enemy Vector3 dir = closestEnemy.transform.position - this.transform.position; Quaternion lookAtRot = Quaternion.LookRotation(dir); //Debug.Log(lookAtRot.eulerAngles); mechTransform.rotation = Quaternion.Euler(lookAtRot.eulerAngles.x - 90, lookAtRot.eulerAngles.y, lookAtRot.eulerAngles.z); }
/// <summary> /// Generate one or more sentinal files /// </summary> /// <returns>int number of failures</returns> static int Genfiles() { int rc = 0; foreach (FileRecord File in config.Files) { if (File.Sentinal) // only generate for files where Sentinal is true { if (System.IO.File.Exists(File.Path)) { Console.WriteLine("Failure: '" + File.Path + "' already exists "); rc++; continue; } Sentinal s = new Sentinal(File.Path); int length = File.GetLength(); if (length == 0) { s.Length = new Random().Next(4, 32768) * 1024; // set a random size if not specified } else { s.Length = length; } try { if (s.GenerateType1()) { Console.WriteLine("Success: '" + s.Path + "' Generated, " + BytesConvert.ToString(s.Length)); } else { Console.WriteLine("Something wierd happened attempting to write '" + File.Path); // shouldnt be here } // there should have been an execption if anything went wrong in s.Generate(). } catch (Exception e) { Console.WriteLine("301 Error writing file: " + " " + e.Message); rc++; } } } Console.WriteLine("RC=" + rc); return(rc); }
/// <summary> /// Delete files previously generated sentinal files /// </summary> static void Deletefiles() { foreach (FileRecord File in config.Files) { if (File.Sentinal) { Sentinal s = new Sentinal(File.Path); if (s.Delete()) { Console.WriteLine("Deleted: '" + s.Path + "'"); } else { Console.WriteLine("Failed: '" + s.Path + "' " + s.Error); } } else { Console.WriteLine("Skipped: '" + File.Path + "' is Not a sentinal file"); } } }