public void IstAufgeladenHandy() { Handy h = new Handy(); h.Vollgeladen(); Assert.IsTrue(h.Vollgeladen()); }
public int GetRomFromFile(string foundFilePath) { int total = 0; var SHA1 = Audit.GetHash(foundFilePath, HashOption.SHA1, (int)HeaderLength); Rom matchedRom = Roms.FirstOrDefault(x => SHA1.Equals(x.SHA1, StringComparison.OrdinalIgnoreCase)); if (matchedRom == null && HeaderLength > 0) { SHA1 = Audit.GetHash(foundFilePath, HashOption.SHA1, 0); matchedRom = Roms.FirstOrDefault(x => SHA1.Equals(x.SHA1, StringComparison.OrdinalIgnoreCase)); } // Have found a match so do this stuff with it if (matchedRom != null) { // Check whether the release has a filename stored and that file exists if (string.IsNullOrEmpty(matchedRom.FileName) || !File.Exists(matchedRom.FilePath)) { string extension = Path.GetExtension(foundFilePath); matchedRom.StoreFileName(extension); if (foundFilePath != matchedRom.FilePath) { if (File.Exists(matchedRom.FilePath)) { File.Move(matchedRom.FilePath, FileLocation.RomsBackup + matchedRom.FileName); } if (matchedRom.Platform_ID == CONSTANTS.Platform_ID.Lynx) { string tempFile = "lnxtmp.lyx"; string tempFile2 = "lnxtmp.lnx"; string tempPath = Path.GetDirectoryName(FileLocation.HandyConverter) + @"\" + tempFile; string tempPath2 = Path.GetDirectoryName(FileLocation.HandyConverter) + @"\" + tempFile2; File.Delete(tempPath); Thread.Sleep(100); File.Copy(foundFilePath, tempPath); Thread.Sleep(100); if (Handy.ConvertLynx(tempFile)) { File.Move(tempPath2, matchedRom.FilePath); } } else { File.Copy(foundFilePath, matchedRom.FilePath); } } total = 1; } } return(total); }
public void BSP1_Aufgabe_006() { Handy h = new Handy(); h.WertSetzen <int>("anzahlSMS", 21); h.WertSetzen <int>("anzahlMegaByte", 999); Programmieren.PrüfeMethode <string>(h, "autoTarifWahl", null, "tarif", x => { return(x == "mini"); }); h = new Handy(); h.WertSetzen <int>("anzahlSMS", 19); h.WertSetzen <int>("anzahlMegaByte", 1001); Programmieren.PrüfeMethode <string>(h, "autoTarifWahl", null, "tarif", x => { return(x == "mini"); }); h = new Handy(); h.WertSetzen <int>("anzahlSMS", 19); h.WertSetzen <int>("anzahlMegaByte", 999); Programmieren.PrüfeMethode <string>(h, "autoTarifWahl", null, "tarif", x => { return(x != "mini"); }); h = new Handy(); h.WertSetzen <int>("anzahlSMS", 51); h.WertSetzen <int>("anzahlMegaByte", 999); Programmieren.PrüfeMethode <string>(h, "autoTarifWahl", null, "tarif", x => { return(x == "midi"); }); h = new Handy(); h.WertSetzen <int>("anzahlSMS", 19); h.WertSetzen <int>("anzahlMegaByte", 1501); Programmieren.PrüfeMethode <string>(h, "autoTarifWahl", null, "tarif", x => { return(x == "midi"); }); h = new Handy(); h.WertSetzen <int>("anzahlSMS", 49); h.WertSetzen <int>("anzahlMegaByte", 1499); Programmieren.PrüfeMethode <string>(h, "autoTarifWahl", null, "tarif", x => { return(x == "mini"); }); h = new Handy(); h.WertSetzen <int>("anzahlSMS", 101); h.WertSetzen <int>("anzahlMegaByte", 2001); Programmieren.PrüfeMethode <string>(h, "autoTarifWahl", null, "tarif", x => { return(x == "maxi"); }); h = new Handy(); h.WertSetzen <int>("anzahlSMS", 99); h.WertSetzen <int>("anzahlMegaByte", 2001); Programmieren.PrüfeMethode <string>(h, "autoTarifWahl", null, "tarif", x => { return(x == "midi"); }); h = new Handy(); h.WertSetzen <int>("anzahlSMS", 99); h.WertSetzen <int>("anzahlMegaByte", 1999); Programmieren.PrüfeMethode <string>(h, "autoTarifWahl", null, "tarif", x => { return(x == "midi"); }); }
public ActionResult Unlock(UnlockerModel model) { var algorithm = new SHA256Cng(); var unicoding = new UnicodeEncoding(); var hashed = unicoding.GetString(algorithm.ComputeHash(unicoding.GetBytes(model.Passphrase))); if (hashed == "嘃ᥐ倹⦦듑ꈳ囬쀺诫谾臭ᰠ屯") { FormsAuthentication.SetAuthCookie("Manager", false); var url = Handy.BaseUrl() + (model.ReturnUrl ?? Url.Action("Unlock")); return(Redirect(url)); } ModelState.AddModelError("AuthenticationFailed", "Wrong Passphrase"); return(View()); }
public void BSP1_Aufgabe_005() { Handy h = new Handy(); h.WertSetzen <string>("tarif", "mini"); Programmieren.PrüfeMethode <double>(h, "tarifWechsel", null, "kostenSMS", x => { return(x == 0.2); }); Programmieren.PrüfeMethode <double>(h, "tarifWechsel", null, "kostenMegaByte", x => { return(x == 0.35); }); h = new Handy(); h.WertSetzen <string>("tarif", "midi"); Programmieren.PrüfeMethode <double>(h, "tarifWechsel", null, "kostenSMS", x => { return(x == 0.16); }); Programmieren.PrüfeMethode <double>(h, "tarifWechsel", null, "kostenMegaByte", x => { return(x == 0.33); }); h = new Handy(); h.WertSetzen <string>("tarif", "maxi"); Programmieren.PrüfeMethode <double>(h, "tarifWechsel", null, "kostenSMS", x => { return(x == 0.14); }); Programmieren.PrüfeMethode <double>(h, "tarifWechsel", null, "kostenMegaByte", x => { return(x == 0.3); }); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUILayout.Space(16); GUI.enabled = Application.isPlaying; if (GUILayout.Button("Explode!")) { explosion.Explode(); } GUI.enabled = true; if (explosion.sources.Length == 0) { EditorGUILayout.HelpBox(SOURCE_WARNING, MessageType.Warning); } if (GUILayout.Button("Duplicate Component")) { Handy.DuplicateComponent(explosion, explosion.gameObject); } }
public void Explode() { if (sources.Length == 0) { Debug.LogWarning(SOURCE_WARNING); return; } if (explodeDelay > 0) { var go = new GameObject(); go.transform.position = transform.position; var copy = Handy.DuplicateComponent(this, go); copy.explodeDelay = 0f; Destroy(go, explodeDelay); return; } for (int index = 0; index < count; index++) { int sourceIndex = mode == Mode.Random ? Random.Range(0, sources.Length) : index % sources.Length; Item source = sources[sourceIndex]; float angle = mode == Mode.Random ? Random.Range(0f, 360f) : (float)index / count * 360f; Item shard = Instantiate(source, transform.position, Quaternion.Euler(0f, 0f, angle)); shard.gameObject.hideFlags = hideClonesInHierarchy ? HideFlags.HideInHierarchy : HideFlags.None; float vVariation = mode == Mode.Random ? Random.Range(-velocityVariation, velocityVariation) : 0f; float shardVelocity = velocity * (1f + vVariation); float shardVelocityX = shardVelocity * Mathf.Cos(angle * Mathf.Deg2Rad); float shardVelocityY = shardVelocity * Mathf.Sin(angle * Mathf.Deg2Rad); shard.velocity = new Vector3(shardVelocityX, shardVelocityY, 0f); float tVariation = mode == Mode.Random ? Random.Range(-timeMaxVariation, timeMaxVariation) : 0f; shard.timeMax = timeMax * (1f + tVariation); } }
public int GetRomsFromZipFile(string filename) { int total = 0; string SHA1; Rom matchedRom; try { using ZipArchive archive = ZipFile.Open(filename, ZipArchiveMode.Read); foreach (ZipArchiveEntry entry in archive.Entries) { using Stream stream = entry.Open(); using MemoryStream memoryStream = new(); int count; do { byte[] buffer = new byte[1024]; count = stream.Read(buffer, 0, 1024); memoryStream.Write(buffer, 0, count); } while (stream.CanRead && count > 0); // TODO Some roms in DB have no SHA1 this is a substantial bug SHA1 = Audit.GetHash(memoryStream, HashOption.SHA1, (int)HeaderLength); matchedRom = Roms.FirstOrDefault(x => SHA1.Equals(x.SHA1, StringComparison.OrdinalIgnoreCase)); if (matchedRom == null && HeaderLength > 0) { SHA1 = Audit.GetHash(memoryStream, HashOption.SHA1, 0); matchedRom = Roms.FirstOrDefault(x => SHA1.Equals(x.SHA1, StringComparison.OrdinalIgnoreCase)); } // Have found a match so do this stuff with it if (matchedRom != null) { // Check that the release has no filename, or the file doesn't yet exist if (string.IsNullOrEmpty(matchedRom.FileName) || !File.Exists(matchedRom.FilePath)) { string extension = Path.GetExtension(entry.Name); matchedRom.StoreFileName(extension); if (File.Exists(matchedRom.FilePath)) { File.Move(matchedRom.FilePath, FileLocation.RomsBackup + matchedRom.FileName); } if (matchedRom.Platform_ID == CONSTANTS.Platform_ID.Lynx) { //TODO: This looks pretty shady string tempFile = "lnxtmp.lyx"; string tempFile2 = "lnxtmp.lnx"; string tempPath = Path.GetDirectoryName(FileLocation.HandyConverter) + @"\" + tempFile; string tempPath2 = Path.GetDirectoryName(FileLocation.HandyConverter) + @"\" + tempFile2; File.Delete(tempPath); File.Delete(tempPath2); entry.ExtractToFile(tempPath); Handy.ConvertLynx(tempFile); File.Move(tempPath, matchedRom.FilePath); } else { entry.ExtractToFile(matchedRom.FilePath); } total += 1; } } } } catch (Exception) { } return(total); }
public ActionResult Lock() { FormsAuthentication.SignOut(); return(Redirect(Handy.BaseUrl() + "/Home")); }
public string Permalink(UrlHelper url) { return(string.Format("{0}{1}/{2}", Handy.BaseUrl(), url.Action("Post", "Blog"), Slug)); }
public string ThumbnailLink(UrlHelper url) { return(string.Format("{0}{1}/{2}", Handy.BaseUrl(), url.Action("Thumbnail", "Blog"), Slug)); }
/// <summary> /// 플레이어가 땅과 접촉했는지에 대한 필드를 갱신합니다. /// </summary> /// <returns>플레이어가 땅에 닿아있다면 참입니다.</returns> bool UpdateLanding() { RaycastHit2D rayB = Physics2D.Raycast(groundCheckBack.position, Vector2.down, groundCheckRadius, _whatIsGround); RaycastHit2D rayF = Physics2D.Raycast(groundCheckFront.position, Vector2.down, groundCheckRadius, _whatIsGround); Debug.DrawRay(groundCheckBack.position, Vector2.down, Color.red); Debug.DrawRay(groundCheckFront.position, Vector2.down, Color.red); if (Handy.DebugPoint) // PlayerController.UpdateLanding { Handy.Log("PlayerController.UpdateLanding"); } if (OnGround()) { // 절차: // 1. 캐릭터에서 수직으로 내린 직선에 맞는 경사면의 법선 벡터를 구한다. // 2. 법선 벡터와 이동 방향 벡터가 이루는 각도가 예각이면 내려오는 것 // 법선 벡터와 이동 방향 벡터가 이루는 각도가 둔각이면 올라가는 것 /// Handy.Log("OnGround()"); // 앞 부분 Ray와 뒤 부분 Ray의 경사각이 다른 경우 if (rayB.normal.normalized != rayF.normal.normalized) { bool isTouchingSlopeFromB = rayB.normal.x == 0; /// Transform pos = isTouchingSlopeFromB ? groundCheckBack : groundCheckFront; RaycastHit2D ray = isTouchingSlopeFromB ? rayB : rayF; Vector2 from = FacingRight ? Vector2.right : Vector2.left; float rayAngle = Vector2.Angle(from, ray.normal); float rayAngleRad = Mathf.Deg2Rad * rayAngle; float sx = _movingSpeed * Mathf.Cos(rayAngleRad); float sy = _movingSpeed * Mathf.Sin(rayAngleRad); float vx = FacingRight ? sx : -sx; if (Jumping || Flying) { } // 예각이라면 내려갑니다. else if (rayAngle < 90) { float vy = -sy; _Velocity = new Vector2(vx, vy); } // 둔각이라면 올라갑니다. else if (rayAngle > 90) { float vy = sy; _Velocity = new Vector2(vx, vy); } // 90도라면 else { } } else { } Landed = true; } else if (rayB || rayF) { // 가장 가까운 거리에 적중한 Ray를 탐색합니다. RaycastHit2D ray; if (rayB && !rayF) { ray = rayB; } else if (!rayB && rayF) { ray = rayF; } else { ray = rayB.distance < rayF.distance ? rayB : rayF; } /// Vector3 pos = transform.position; /// pos.y -= difY; // 지형과 Y 좌표의 차이가 작으면 추락을 중지합니다. float difY = ray.distance / transform.localScale.y; if (Mathf.Abs(difY) < _jumpDecSize) { // transform.position = pos; float vy = _Velocity.y > 0 ? _Velocity.y : 0; _Velocity = new Vector2(_Velocity.x, vy); Landed = true; } else { Landed = false; } } else if (Jumping || Falling || Flying) { Landed = false; } else { Landed = false; } return(Landed); }
public ActionResult PostContent(string slug, string contentName) { return(File( Server.MapPath("~" + Constants.PostsFolder + slug + Constants.PostContent + @"\" + contentName), Handy.ContentType(contentName))); }
public void HandyInstanceof() { Gerät h = new Handy(); Assert.IsInstanceOfType(h, typeof(Handy)); }
public void HandyAreEqual() { Gerät h = new Handy(); Assert.AreEqual(true, h.Vollgeladen()); }