public void SetEntryType(ENTRY entry) { switch (entry) { case ENTRY.TOP: _animator.Play("enter_top"); break; case ENTRY.BOTTOM: _animator.Play("enter_bottom"); break; case ENTRY.LEFT: _animator.Play("enter_left"); break; case ENTRY.RIGHT: _animator.Play("enter_right"); break; case ENTRY.RANDOM: int r = Random.Range(0, 4); SetEntryType((ENTRY)r); break; } }
//Function called to update the list, showing the email's current status public void UpdateList(List <EmailManager.PlayerAction> ACTION_LIST) { if (ACTION_LIST.Count == ENTRY_LIST.Count) { int index = 0; foreach (EntryController ENTRY in ENTRY_LIST) { switch (ACTION_LIST[index]) { case EmailManager.PlayerAction.Accepted: ENTRY.GetComponent <Image>().color = ACCEPTED; break; case EmailManager.PlayerAction.Declined: ENTRY.GetComponent <Image>().color = REJECTED; break; case EmailManager.PlayerAction.Important: ENTRY.GetComponent <Image>().color = IMPORTANT; break; default: break; } index++; } } else { Debug.Log("For some reason action and entry list don't have the same count. Entry: " + ENTRY_LIST.Count + " Action: " + ACTION_LIST.Count); } }
public int CreateLetter(int xOffset, char c, ENTRY entry) { //highlights the correct block and returns the letter's width to position the next letter if (!characterRefs.ContainsKey(c)) { return(0); } Letter letter = characterRefs[c]; long pos = 1; for (int y = 0; y < 7; y++) { for (int x = 0; x < letter.GetWidth(); x++) { Cube cube = _cubes[x + xOffset, y]; bool isOn = ((pos & letter.GetData()) != 0); cube.SetOn(isOn); float r = Random.Range(0.0f, 0.5f); //cube.SetAnimationSpeed(r); cube.SetEntryType(entry); cube.SetDelay(r); pos = pos << 1; } } return(letter.GetWidth()); }
public void CreateText(string s, ENTRY entry, GameObject prefab) { Debug.Log(TAG + "creating text"); ClearText(); //change string to uppercase s = s.ToUpper(); length = FindLength(s); height = 7; Debug.Log("length = " + length); FindIdealDistance(); _cubes = new Cube[length, height]; for (int x = 0; x < length; x++) { for (int y = 0; y < height; y++) { GameObject g = Instantiate(prefab); g.transform.SetParent(_cubeContainer, false); g.transform.localPosition = new Vector3(x, y, 0); Cube cube = g.GetComponent <Cube>(); _cubes[x, y] = cube; } } int xOffset = 0; for (int i = 0; i < s.Length; i++) { xOffset += CreateLetter(xOffset, s[i], entry); xOffset += CreateSpace(xOffset); } }
/// <summary> /// Function will test if the game we're trying to inject to /// is distributing a mscorlib.dll file and if so, we're going /// to test whether reflection is enabled. /// </summary> /// <param name="strAssemblyPath"></param> /// <param name="strEntryPoint"></param> /// <param name="exception"></param> internal static bool IsReflectionEnabled(string strDataPath) { // This method will most definitely have to be enhanced as we encounter new // situations where a game's mscorlib reflection functionality may have been disabled. const string ENTRY = "System.Reflection.Emit.AssemblyBuilder::DefineDynamicAssembly"; bool bReflectionEnabled = true; if (!File.Exists(Path.Combine(strDataPath, Constants.MSCORLIB))) { // No custom corlib, safe to assume that reflection is enabled. return(bReflectionEnabled); } string tempFile = GetTempFile(Path.Combine(strDataPath, Constants.MSCORLIB)); string[] entryPoint = ENTRY.Split(new string[] { "::" }, StringSplitOptions.None); try { AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(tempFile); TypeDefinition type = assembly.MainModule.GetType(entryPoint[0]); if (null == type) { throw new NullReferenceException("Failed to find entry Type in mod assembly"); } MethodDefinition meth = type.Methods .Where(method => method.Name.Contains(entryPoint[1]) && method.Parameters.Count == 2) .FirstOrDefault(); if (null == meth) { throw new NullReferenceException("Failed to find entry Method in mod assembly"); } Instruction instr = meth.Body.Instructions .Where(instruction => instruction.ToString().Contains(nameof(PlatformNotSupportedException))) .SingleOrDefault(); bReflectionEnabled = (instr == null); assembly.Dispose(); } catch (Exception exc) { bReflectionEnabled = false; } DeleteTemp(tempFile); return(bReflectionEnabled); }
public void Unpack(string sPath) { string sWorkDir = Path.GetDirectoryName(sPath) + "\\" + Path.GetFileNameWithoutExtension(sPath) + "\\"; if (File.Exists(sPath)) { Util.CreateDir(sWorkDir); using (var br = new BinaryReader(File.OpenRead(sPath))) { int count = br.ReadInt32(); Entries = new List <ENTRY>(); for (int i = 0; i < count; i++) { var temp = new ENTRY(); temp.Load(br); Entries.Add(temp); } for (int i = 0; i < count; i++) { var genericName = $"FILE_{i:D3}.dat"; br.SeekTo(Entries[i].Offset); byte[] PayloadData = br.ReadBytes((int)Entries[i].Size); if (PayloadData != null) { Console.Write($"Writing {genericName}... "); File.WriteAllBytes(sWorkDir + genericName, PayloadData); } } } } }
/// <summary> /// Function will test if the game we're trying to inject to /// is distributing a mscorlib.dll file and if so, we're going /// to test whether reflection is enabled. /// </summary> /// <param name="dataPath"></param> private bool IsReflectionEnabled(string dataPath) { // This method will most definitely have to be enhanced as we encounter new // situations where a game's mscorlib reflection functionality may have been disabled. const string ENTRY = "System.Reflection.Emit.AssemblyBuilder::DefineDynamicAssembly"; string corLib = Path.Combine(dataPath, Constants.MSCORLIB); bool reflectionEnabled = true; if (!File.Exists(corLib)) { // No custom corlib, safe to assume that reflection is enabled. return(reflectionEnabled); } string tempFile = string.Empty; try { tempFile = Util.GetTempFile(Path.Combine(dataPath, Constants.MSCORLIB)); } catch (Exception) { tempFile = Util.GetTempFile(Path.Combine(dataPath, Constants.MSCORLIB + VortexInjectorIPC.Constants.VORTEX_BACKUP_TAG)); } string [] entryPoint = ENTRY.Split(new string [] { "::" }, StringSplitOptions.None); try { AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(tempFile); if (assembly.Name.Version.Major <= 3) { // There doesn't seem to be a reason to replace the corlib // for older .NET versions. assembly.Dispose(); return(true); } TypeDefinition type = assembly.MainModule.GetType(entryPoint [0]); if (null == type) { throw new NullReferenceException("Failed to find entry Type in mod assembly"); } MethodDefinition meth = type.Methods .Where(method => method.Name.Contains(entryPoint [1]) && method.Parameters.Count == 2) .FirstOrDefault(); if (null == meth) { throw new NullReferenceException("Failed to find entry Method in mod assembly"); } Instruction instr = meth.Body.Instructions .Where(instruction => instruction.ToString().Contains(nameof(PlatformNotSupportedException))) .SingleOrDefault(); reflectionEnabled = (instr == null); assembly.Dispose(); } catch (Exception) { reflectionEnabled = false; } Util.DeleteTemp(tempFile); return(reflectionEnabled); }
public void CreateText(string s, ENTRY entry) { CreateText(s, entry, _cubePrefab); }