public Section GetSectionByLevel() { int r = Random.Range(0, reservedTransform.childCount); Section s = reservedTransform.GetChild(r).GetComponent <Section>(); SectionCategory targetCategory = LevelController.Instance.GetSectionCategoryFromLevel(); int breakcount = 0; do { r = Random.Range(0, reservedTransform.childCount); s = reservedTransform.GetChild(r).GetComponent <Section>(); breakcount++; if (breakcount > 100) { Debug.Log("Break"); break; } }while (s.category != targetCategory || lastType == s.type); lastType = s.type; return(s); }
public async Task <ActionResult> Edit([Bind(Include = "Id,SectionId,CategoryId")] SectionCategory s_category) { ViewBag.sections = db.Sections.ToList(); ViewBag.categories = db.Categories.ToList(); if (!ModelState.IsValid) { return(View(s_category)); } var dbcheck = db.Sections.Find(s_category.SectionId); var dbcheck2 = db.Sections.Find(s_category.CategoryId); if (dbcheck == null || dbcheck2 == null) { ModelState.AddModelError("alError", "Plese,Enter the information correctly"); } SectionCategory s_cat = db.SectionCategories.Find(s_category.Id); s_cat.SectionId = s_category.SectionId; s_cat.CategoryId = s_category.CategoryId; await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create(int?sectionId, int?categoriId, SectionCategory sectionCategory) { ViewBag.sections = db.Sections.ToList(); ViewBag.categories = db.Categories.ToList(); if (sectionId == null || categoriId == null) { ModelState.AddModelError("allError", "Please Enter All Info"); return(View(sectionCategory)); } sectionCategory.SectionId = (int)sectionId; sectionCategory.CategoryId = (int)categoriId; var dbcheck = db.Sections.Find(sectionId); var dbcheck2 = db.Categories.Find(categoriId); if (dbcheck == null || dbcheck2 == null) { ModelState.AddModelError("allError", "Null Database Data"); return(View(sectionCategory)); } if (!ModelState.IsValid) { return(View(sectionCategory)); } db.SectionCategories.Add(sectionCategory); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { SectionCategory sectionC = db.SectionCategories.Find(id); db.SectionCategories.Remove(sectionC); db.SaveChanges(); return(RedirectToAction("Index")); }
public EnumerateRemoteSectionResponse(IntPtr baseAddress, IntPtr regionSize, SectionType type, SectionCategory category, SectionProtection protection, string name, string modulePath) { BaseAddress = baseAddress; Size = regionSize; Type = type; Category = category; Protection = protection; Name = name; ModulePath = modulePath; }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SectionCategory sectionCat = db.SectionCategories.Find(id); if (sectionCat == null) { return(HttpNotFound()); } return(View(sectionCat)); }
public void SetCategory(SectionCategory category) { this.category = category; }
private void RepositionSections() { List <Section> queue = new List <Section>(); int r = Random.Range(0, reservedTransform.childCount); int index = 0; Section to = GetSectionFromReservedByType(SectionType.Section_0); queue.Add(to); SectionCategory targetCategory = LevelController.Instance.GetSectionCategoryFromLevel(); SectionType lastChosenType = to.type; int breakCount = 0; bool canBypass = false; do { breakCount++; if (breakCount > 100) { Debug.Log("Break"); break; } r = Random.Range(0, reservedTransform.childCount); to = reservedTransform.GetChild(r).GetComponent <Section>(); if (to.category != targetCategory) { continue; } if (!queue.Contains(to) && lastChosenType != to.type) { queue.Add(to); index++; lastChosenType = to.type; } }while (queue.Count < 4); for (int i = 0; i < queue.Count; i++) { queue[i].transform.SetParent(transform); queue[i].transform.gameObject.SetActive(true); Vector3 position = new Vector3(0, 0, -5); if (i > 0) { position = queue[i - 1].EndConnector.position; } queue[i].transform.position = position; sections.Add(queue[i]); } }