// GET: Cidade public ActionResult Index() { BreadCrumb.Add(Url.Action("Index", "Culturas", "Cultura_Default"), "Cultura"); var culturaViewModel = _mapper.Map <IEnumerable <Dominio.Entidades.Cultura>, IEnumerable <CulturaIndexViewModel> >(_appService.BuscaTodos()); return(View(culturaViewModel)); }
public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Credit credit = db.Credits .Include("Order") .Include("Order.OrderDetails") .Include("Order.OrderDetails.Product") .Include("Order.OrderDetails.ProductPrice") .Include("Order.Partner") .Include("Invoice") .Where(x => x.Id == id && x.CreatedBy == UserId).FirstOrDefault(); BreadCrumb.SetLabel("View " + credit.CreditNumber); credit.PaymentDetails = GetPaymentDetailList().Where(x => x.Credit_Id == id && !x.Payment.Deleted).ToList(); ViewBag.Total = credit.Order.OrderDetails.Sum(x => x.AmountAfterTax); if (credit == null) { return(HttpNotFound()); } return(View(credit)); }
public ActionResult Index(string obj) { BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add("/KPI/Index", "KPI"); BreadCrumb.SetLabel("Compare"); var compare = new DataChartDAO().Compare(obj); if (compare.list1 == null) { compare.list1 = new Model.ViewModel.ChartVM(); } if (compare.list2 == null) { compare.list2 = new Model.ViewModel.ChartVM(); } if (compare.list3 == null) { compare.list3 = new Model.ViewModel.ChartVM(); } if (compare.list4 == null) { compare.list4 = new Model.ViewModel.ChartVM(); } ViewBag.List1 = compare.list1; ViewBag.List2 = compare.list2; ViewBag.List3 = compare.list3; ViewBag.List4 = compare.list4; return(View()); }
public void Push(BreadCrumb bc) { if (bc.LinkName.IsNullOrWhiteSpace()) { return; } if (bc.Url.IsNullOrWhiteSpace()) { return; } if (bc.Url == "#") { return; } if (!BreadCrumbStack.IsNull()) { if (BreadCrumbStack.Count > 0) { if (BreadCrumbStack.Peek().Url == bc.Url) { return; } } } BreadCrumbStack.Push(bc); SaveToMemory(); }
public ActionResult Create(string OrderType, string IdToCopy) { switch (OrderType) { case Helper.Constants.OrderType.PURCHASE: BreadCrumb.SetLabel("Create Purchase Order"); break; case Helper.Constants.OrderType.SALE: BreadCrumb.SetLabel("Create Sales Order"); break; case Helper.Constants.OrderType.ADJUST: BreadCrumb.SetLabel("Create Adjustment"); break; } ViewBag.IdToCopy = IdToCopy; ViewBag.OrderTypes = Helper.Constants.OrderTypeList(); ViewBag.AdjustmentReasons = Helper.Constants.AdustmentReasonList(); ViewBag.Partners = GetPartnerList().Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Name }).ToList(); var setting = GetSetting(); var order = new Order(); if (setting != null) { if (!string.IsNullOrEmpty(setting.PurchaseNumber) && OrderType == Helper.Constants.OrderType.PURCHASE) { order.OrderNumber = string.Format("{0}-{1}", setting.PurchasePrefix, setting.PurchaseNumber); } if (!string.IsNullOrEmpty(setting.SalesNumber) && OrderType == Helper.Constants.OrderType.SALE) { order.OrderNumber = string.Format("{0}-{1}", setting.SalesPrefix, setting.SalesNumber); } //if (!string.IsNullOrEmpty(setting.CustomerReturnNumber) && OrderType == Helper.Constants.OrderType.CUSTOMER_RETURN) // order.OrderNumber = string.Format("{0}-{1}", setting.CustomerReturnPrefix, setting.CustomerReturnNumber); //if (!string.IsNullOrEmpty(setting.SupplierReturnNumber) && OrderType == Helper.Constants.OrderType.SUPPLIER_RETURN) // order.OrderNumber = string.Format("{0}-{1}", setting.SupplierReturnPrefix, setting.SupplierReturnNumber); if (!string.IsNullOrEmpty(setting.AdjustNumber) && OrderType == Helper.Constants.OrderType.ADJUST) { order.OrderNumber = string.Format("{0}-{1}", setting.AdjustPrefix, setting.AdjustNumber); } } order.OrderType = OrderType; order.ExpectedDate = DateTime.Now; order.OrderDate = DateTime.Now; order.CreatedBy = UserId; return(View(order)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } television television = db.televisions.Find(id); if (television == null) { return(HttpNotFound()); } BreadCrumb.Clear(); BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add(Url.Action("AppliancesType", "Home"), "Save Energy"); BreadCrumb.Add(Url.Action("Index", "televisions"), "Television"); BreadCrumb.Add("", television.Model_No); // Smiliar products display logic var results = from x in db.televisions select x; var list = results.Where(x => x.Brand_Reg.Contains(television.Brand_Reg)).OrderBy(x => Guid.NewGuid()).Take(3).ToList(); ViewData["SimilarProducts"] = list; return(View(television)); }
/// <summary> /// Adds a custom bread crumb to the list /// </summary> /// <param name="ctx"></param> /// <param name="breadCrumb"></param> public static bool AddBreadCrumb(this HttpContext ctx, BreadCrumb breadCrumb) { if (ctx == null) { return(false); } if (breadCrumbs == null) { breadCrumbs = GetCurrentCookie(ctx); } breadCrumbs?.RemoveAll(p => p.Position > breadCrumb.Position); if (breadCrumbs.Any(crumb => crumb.Link.Equals(breadCrumb.Link, StringComparison.OrdinalIgnoreCase))) { return(false); } if (breadCrumbs.FirstOrDefault(p => p.Position == breadCrumb.Position) != null) { breadCrumbs.RemoveAll(p => p.Position == breadCrumb.Position); } breadCrumbs.Add(breadCrumb); return(true); }
public static BreadCrumb FindPath(Grid world, Point start, Point end) { BreadCrumb bc = FindPathReversed(world, start, end); BreadCrumb[] temp = new BreadCrumb[256]; if (bc != null) { int index = 0; while (bc != null) { temp[index] = bc; bc = bc.next; index++; } index -= 2; BreadCrumb current = new BreadCrumb(start); BreadCrumb head = current; while (index >= 0) { current.next = new BreadCrumb(temp[index].position); current = current.next; index--; } return(head); } else { return(null); } }
public ActionResult AdjustDetails(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViewBag.AdjustmentReasons = Helper.Constants.AdustmentReasonList(); var adjust = new Adjust(); Order order = GetOrderById(id.Value); BreadCrumb.SetLabel("View " + order.OrderNumber); adjust.Id = order.Id; adjust.OrderNumber = order.OrderNumber; adjust.OrderDate = order.OrderDate; adjust.OrderDetails = order.OrderDetails; adjust.OrderNotes = order.OrderNotes; adjust.OrderType = order.OrderType; adjust.AdjustReason = order.AdjustmentReason; //Helper.Constants.AdustmentReasonList().Where( x => x.Value == order.AdjustmentReason).First().Text; adjust.Credits = db.Credits.Where(x => x.Order_Id == id.Value && x.CreatedBy == UserId).ToList(); if (order == null) { return(HttpNotFound()); } return(View(adjust)); }
private Tuple <Course, Module, Activity> MakeBreadCrumbs(int?courseId, int?moduleId, int?activityId) { BreadCrumb.Clear(); BreadCrumb.Add("/", "Home"); // Fetch DB Activity, Module and Course var activity = db.Activities.Find(activityId); var module = db.Modules.Find(moduleId); var course = db.Courses.Find(courseId); // Create return object var ret = new Tuple <Course, Module, Activity>(course, module, activity); // Make sure we have a course, fall back on module.Course or activity.Module.Course if course is null course = course ?? module?.Course ?? activity?.Module?.Course; if (course != null) { BreadCrumb.Add(Url.Action("Index", "Modules", new { courseId = course.Id }), course.Name); // Make sure we have a module, fall back on activity.Module if module is null module = module ?? activity?.Module; if (module != null) { BreadCrumb.Add(Url.Action("Index", "Activities", new { moduleId = module.Id }), module.Name); if (activity != null) { BreadCrumb.Add(Url.Action("Index", "Activities", new { moduleId = activity.ModuleId }), activity.Name); } } } return(ret); }
public ActionResult PhotoGallery() { BreadCrumb.Clear(); BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add(Url.Action("PhotoGallery", "Home"), "Photo Gallery"); return(View("PhotoGallery", "_AdsLayout1")); }
public ActionResult Composting() { BreadCrumb.Clear(); BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add("", "Composting"); return(View()); }
public ActionResult LeftoverRecipe() { ViewBag.Message = "LeftoverRecipe"; BreadCrumb.Clear(); BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add(Url.Action("ReduceFoodWaste", "Home"), "Reduce Waste"); BreadCrumb.Add("", "Left-Over Food Recipes"); List <SelectListItem> Difficulty_level = new List <SelectListItem>(); Difficulty_level.Add(new SelectListItem() { Text = "All", Value = null }); Difficulty_level.Add(new SelectListItem() { Text = "Easy", Value = "easy" }); Difficulty_level.Add(new SelectListItem() { Text = "Average", Value = "average" }); Difficulty_level.Add(new SelectListItem() { Text = "Challenging", Value = "Challenging" }); this.ViewBag.Difficulty = new SelectList(Difficulty_level, "Value", "Text"); return(View()); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } clothes_dryer clothes_dryer = db.clothes_dryer.Find(id); if (clothes_dryer == null) { return(HttpNotFound()); } BreadCrumb.Clear(); BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add(Url.Action("AppliancesType", "Home"), "Save Energy"); BreadCrumb.Add(Url.Action("Index", "clothes_dryer"), "Clothes Dryer"); BreadCrumb.Add("", clothes_dryer.Model_No); // Smiliar products display logic var results = from x in db.clothes_dryer select x; var list = results.Where(x => x.Brand.Contains(clothes_dryer.Brand)).OrderBy(x => Guid.NewGuid()).Take(3).ToList(); ViewData["SimilarProducts"] = list; return(View(clothes_dryer)); }
// // GET: /Roles/Details/5 public async Task <ActionResult> Details(string id) { BreadCrumb.Add(Url.Action("Index"), "Regras/Detalhes"); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var role = await _roleManager.FindByIdAsync(id); // Get the list of Users in this Role var users = new List <ApplicationUser>(); // Get the list of Users in this Role foreach (var user in _userManager.Users.ToList()) { if (await _userManager.IsInRoleAsync(user.Id, role.Name)) { users.Add(user); } } ViewBag.Users = users; ViewBag.UserCount = users.Count(); return(View(role)); }
public ActionResult MeetOurStaff() { BreadCrumb.Clear(); BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add(Url.Action("MeetOurStaff", "Home"), "Meet Our Staff"); return(View("MeetOurStaff", "_AdsLayout1")); }
public ActionResult AppliancesType() { BreadCrumb.Clear(); BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add("", "Save Energy"); return(View()); }
private void Update() { if (Input.GetMouseButtonDown(0)) { //Convert mouse click point to grid coordinates Vector2 worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast(worldPos, Vector2.zero, 0f); if (hit && hit.collider.tag == "Unit") { target = hit.transform.gameObject; } else { target = null; } Point gridPos = grid.WorldToGrid(worldPos); if (gridPos != null) { if (gridPos.X > 0 && gridPos.Y > 0 && gridPos.X < grid.Width && gridPos.Y < grid.Height) { //Convert player point to grid coordinates Point playerPos = grid.WorldToGrid(this.transform.position); grid.Nodes[playerPos.X, playerPos.Y].SetColor(Color.blue); //Find path from player to clicked position bc = PathFinder.FindPath(grid, playerPos, gridPos); } } } }
void MoveNext() { //Walk down untill there are no more children on the right of current entry while (ChildrenAddresses(this.CurrentNode).Count() > this.CurrentEntryIndex + 1) { var breadCrumb = new BreadCrumb() { CurrentEntryIndex = this.CurrentEntryIndex, Node = CurrentNode }; this.BreadCrumbs.Push(breadCrumb); var childAddress = ChildrenAddresses(this.CurrentNode).ElementAt(this.CurrentEntryIndex + 1); this.CurrentEntryIndex = -1; this.CurrentNode = this.DataProvider.GetNode(childAddress); } //move to next entry this.CurrentEntryIndex += 1; //walk up untill an entry is found while (this.CurrentEntryIndex >= Entries(this.CurrentNode).Count() && this.BreadCrumbs.Count > 0) { var breadCrumb = this.BreadCrumbs.Pop(); this.CurrentEntryIndex = breadCrumb.CurrentEntryIndex; this.CurrentNode = breadCrumb.Node; this.CurrentEntryIndex += 1; } }
public void LoadGraph(string data, string CWD, bool readOnly = false) { Release(); Graph = new ImageGraph("Untitled"); if (string.IsNullOrEmpty(data)) { return; } Original = Graph; Graph.CWD = CWD; Graph.FromJson(data); HdriManager.Selected = Graph.HdriIndex; Graph.OnGraphUpdated += Graph_OnGraphUpdated; Scale = Graph.Zoom; XShift = Graph.ShiftX; YShift = Graph.ShiftY; ZoomLevel.Text = String.Format("{0:0}", Scale * 100); LoadGraphUI(); ReadOnly = readOnly; Crumbs.Clear(); BreadCrumb cb = new BreadCrumb(Crumbs, "Root", this, null); }
public ActionResult GetProduct(int id) { var model = db.GetProduct(id); BreadCrumb.SetLabel("Product " + model.ProductName); return(View(model)); }
public ActionResult CompanyPlatformLogOff() { FormsAuthentication.SignOut(); Session.Clear(); BreadCrumb.ClearState(); return(RedirectToAction("CompanyPlatformLogin", "Account")); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } monitor monitor = db.monitors.Find(id); if (monitor == null) { return(HttpNotFound()); } BreadCrumb.Clear(); BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add(Url.Action("AppliancesType", "Home"), "Save Energy"); BreadCrumb.Add(Url.Action("Index", "monitors"), "Monitor"); BreadCrumb.Add("", monitor.Model_Number); // Smiliar products display logic var results = from x in db.monitors select x; var list = results.Where(x => x.Brand_Name.Contains(monitor.Brand_Name)).Take(3).ToList(); ViewData["SimilarProducts"] = list; return(View(monitor)); }
protected void Page_Load(object sender, EventArgs e) { (Master as WikiMaster).GetNavigateActionsVisible += new WikiMaster.GetNavigateActionsVisibleHandle(PageHistoryList_GetNavigateActionsVisible); var page = Wiki.GetPage(PageNameUtil.Decode(WikiPage)); if (Request["page"] == null || page == null) { Response.RedirectLC("Default.aspx", this); } string PageName = page.PageName.Equals(string.Empty) ? WikiResource.MainWikiCaption : page.PageName; BreadCrumb.Add(new ASC.Web.Controls.BreadCrumb() { Caption = PageName, NavigationUrl = ActionHelper.GetViewPagePath(this.ResolveUrlLC("Default.aspx"), page.PageName) }); BreadCrumb.Add(new ASC.Web.Controls.BreadCrumb() { Caption = WikiResource.wikiHistoryCaption }); if (!IsPostBack) { cmdDiff.Text = WikiResource.cmdDiff; cmdDiff_Top.Text = WikiResource.cmdDiff; BindHistoryList(); } }
public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Credit credit = db.Credits .Include("Order") //.Include("Order.OrderDetails") //.Include("Order.OrderDetails.Product") //.Include("Order.OrderDetails.ProductPrice") .Include("Order.Partner"). Where(x => x.Id == id && x.CreatedBy == UserId).FirstOrDefault(); BreadCrumb.SetLabel("Edit " + credit.CreditNumber); if (credit == null) { return(HttpNotFound()); } ViewBag.Order_Id = new SelectList(db.Orders, "Id", "OrderNumber", credit.Order_Id); ViewBag.Partner_Id = new SelectList(db.Partners, "Id", "Name", credit.Partner_Id); return(View(credit)); }
public ActionResult MeettheDoctors() { BreadCrumb.Clear(); BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add(Url.Action("MeettheDoctors", "Home"), "Meet Dr. Tekle"); return(View("MeettheDoctors", "_AdsLayout1")); }
private void SetupSearchLayoutWidgets(PageModel pageModel, LayoutModel layoutModel) { var recentlyViewed = new RecentlyViewedItems { Webpage = pageModel.ProductSearch, LayoutArea = layoutModel.SearchLayout.LayoutAreas.FirstOrDefault(x => x.AreaName == "After Filters"), Name = "Recently Viewed" }; _widgetService.AddWidget(recentlyViewed); //breadcrumb var breadcrumbs = new BreadCrumb { LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.First(x => x.AreaName == "Before Content"), Name = "Breadcrumbs", Webpage = pageModel.ProductSearch, IsRecursive = true, Cache = true, CacheExpiryType = CacheExpiryType.Sliding, CacheLength = 1800 }; _widgetService.AddWidget(breadcrumbs); }
public ActionResult OurPhilosophy() { BreadCrumb.Clear(); BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add(Url.Action("OurPhilosophy", "Home"), "Our Philosophy"); return(View("OurPhilosophy", "_AdsLayout1")); }
public ActionResult Index() { BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add("/KPI/Index", "KPI"); BreadCrumb.SetLabel("Period"); return(View()); }
public async Task <ActionResult> Index(string kpilevelcode, int?catid, string period, int?year, int?start, int?end) { BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add("/KPI/Index", "KPI"); if (period == "W") { BreadCrumb.SetLabel("Chart / Weekly"); } else if (period == "M") { BreadCrumb.SetLabel("Chart / Monthly"); } else if (period == "Q") { BreadCrumb.SetLabel("Chart / Quarterly"); } else if (period == "Y") { BreadCrumb.SetLabel("Chart / Yearly"); } var model = await new DataChartDAO().ListDatas(kpilevelcode, catid, period, year, start, end); ViewBag.Model = model; return(View()); }
public void Add(string text, string routeName, string action, string contorller, object routeValues) { if (_context.ViewData["breadcrumbs"]==null) { _context.ViewData["breadcrumbs"] = BreadCrumbs = new List<BreadCrumb>(); } var breadCrumb = new BreadCrumb() { Link = UrlHelper.GenerateUrl(routeName, action, contorller, new RouteValueDictionary(routeValues), RouteTable.Routes, _context.ControllerContext.RequestContext, false), Text = text }; if (!BreadCrumbs.Contains(breadCrumb)) { BreadCrumbs.Add(breadCrumb); } }
private void SetupProductLayoutWidgets(LayoutModel layoutModel, PageModel pageModel) { var breadcrumbs = new BreadCrumb { LayoutArea = layoutModel.ProductLayout.LayoutAreas.Single(x => x.AreaName == "Before Product Content"), Name = "Breadcrumbs", IsRecursive = true, Cache = true, CacheExpiryType = CacheExpiryType.Sliding, CacheLength = 180 }; _widgetService.AddWidget(breadcrumbs); var relatedProducts = new RelatedProducts { LayoutArea = layoutModel.ProductLayout.LayoutAreas.Single(x => x.AreaName == "After Product Content"), Name = "Related Products", Cache = true, CacheExpiryType = CacheExpiryType.Absolute, CacheLength = 1800 }; _widgetService.AddWidget(relatedProducts); var peopleAlsoBought = new PeopleWhoBoughtThisAlsoBought { LayoutArea = layoutModel.ProductLayout.LayoutAreas.Single(x => x.AreaName == "After Product Content"), Name = "People who bought this also bought", Cache = true, CacheExpiryType = CacheExpiryType.Absolute, CacheLength = 1800 }; _widgetService.AddWidget(peopleAlsoBought); var otherCategories = new NotWhatYouWereLookingForWidget { LayoutArea = layoutModel.ProductLayout.LayoutAreas.Single(x => x.AreaName == "Below Product Price"), Name = "Not what you were looking for?", Cache = true, CacheExpiryType = CacheExpiryType.Absolute, CacheLength = 1800 }; _widgetService.AddWidget(otherCategories); }
/// <summary> /// Function to add bread crumb item. /// </summary> /// <param name="text">Text value</param> /// <param name="address">Address value</param> protected void AddBreadcrumbItem(string text, string address) { if (ViewBag.BreadCrumbs == null) { ViewBag.BreadCrumbs = new List<BreadCrumb>(); } List<BreadCrumb> list = ViewBag.BreadCrumbs; var item = list.FirstOrDefault(bItem => bItem.Text.Equals(text, StringComparison.OrdinalIgnoreCase)); if (item == null) { BreadCrumb breadcrumb = new BreadCrumb(); breadcrumb.Text = text; breadcrumb.Address = address; ViewBag.BreadCrumbs.Add(breadcrumb); } else { item.Address = address; } }
public void Update(GameTime gameTime, Map gameMap, HeroDude gameHero, bool[,] mapFog, Camera gameCamera) { checkLOSTime += gameTime.ElapsedGameTime.TotalMilliseconds; genPathTime += gameTime.ElapsedGameTime.TotalMilliseconds; checkTorchTime += gameTime.ElapsedGameTime.TotalMilliseconds; // Moving if ((Position - Target).Length() > 10f) { Vector2 dir = Target - Position; Move(dir); //if(State==AIState.Patrolling) if(State!=AIState.Attacking) LookAt(Target); } else { Target = Position; // Reached target switch (State) { case AIState.Patrolling: if (Helper.Random.Next(500) == 1) { Vector2 potentialTarget = Helper.RandomPointInCircle(Position, 100, 500); if (!gameMap.CheckCollision(potentialTarget)) Target = potentialTarget; } break; } } switch (State) { case AIState.Patrolling: // Chase player if in LOS if (CheckLineOfSight(gameHero.Position, gameMap)) { gameHero.HuntedLevel.Seen(gameHero.Position); Target = Position; // Stop dead in tracks if (gameHero.drivingVehicle == null) State = AIState.Chasing; // Begin chasing player else { if (Weapons[SelectedWeapon].GetType() != typeof(Knife)) State = AIState.Attacking; } } // Allow the enemy to "hear" the player if player moves close to enemy if ((gameHero.Speed.Length() > 0f && (gameHero.Position - Position).Length() < 250f) || (gameHero.drivingVehicle != null && (gameHero.Position - Position).Length() < 800f)) { gameHero.HuntedLevel.Heard(gameHero.Position, false); LookAt(gameHero.Position); } if ((gameHero.Position - Position).Length() < 800f && insideBuilding == null && gameHero.drivingVehicle is Chopper && ((Chopper)gameHero.drivingVehicle).Height >0f && !(Weapons[SelectedWeapon] is Knife)) State = AIState.Attacking; break; case AIState.Chasing: Target = gameHero.Position; LookAt(gameHero.Position); if(gameHero.drivingVehicle is Chopper) State = AIState.Patrolling; if (((gameHero.Position - Position).Length() < 450f && CheckLineOfSight(gameHero.Position, gameMap)) || ((gameHero.Position - Position).Length() < 800f && gameHero.drivingVehicle is Chopper)) { Target = Position; State = AIState.Attacking; } break; case AIState.FollowingPath: if (Target == Position) { if (chasePath == null || regeneratePath) { if (genPathTime > 1000) { genPathTime = 0; regeneratePath = false; chasePath = PathFinder.FindPath(gameMap.AStarWorld, new Point3D((int)(Position.X / gameMap.TileWidth), (int)(Position.Y / gameMap.TileHeight), 0), new Point3D((int)(gameHero.Position.X / gameMap.TileWidth), (int)(gameHero.Position.Y / gameMap.TileHeight), 0)); if (chasePath != null) Target = new Vector2((chasePath.position.X * gameMap.TileWidth) + (gameMap.TileWidth / 2), (chasePath.position.Y * gameMap.TileHeight) + (gameMap.TileHeight / 2)); else State = AIState.Patrolling; } } else { chasePath = chasePath.next; if (chasePath != null) Target = new Vector2((chasePath.position.X * gameMap.TileWidth) + (gameMap.TileWidth / 2), (chasePath.position.Y * gameMap.TileHeight) + (gameMap.TileHeight / 2)); else State = AIState.Chasing; } } if (CheckLineOfSight(gameHero.Position, gameMap)) { Target = Position; // Stop dead in tracks State = AIState.Chasing; // Begin chasing player } break; case AIState.Attacking: if (gameHero.drivingVehicle is Chopper && insideBuilding != null) { State = AIState.Patrolling; break; } LookAt(gameHero.Position); bool shootUp = (gameHero.drivingVehicle != null && gameHero.drivingVehicle is Chopper && ((Chopper)gameHero.drivingVehicle).Height >0f); Attack(gameTime, gameHero.Position, true, gameCamera, !shootUp); if (Weapons[SelectedWeapon].GetType() != typeof(Knife)) { if ((gameHero.Position - Position).Length() > 450f) { if (gameHero.drivingVehicle == null) { Target = gameHero.Position; State = AIState.Chasing; } else State = AIState.Patrolling; } if (Helper.Random.Next(100) == 1) { Vector2 potentialTarget = Helper.RandomPointInCircle(Position, 100, 500); if (!gameMap.CheckCollision(potentialTarget)) Target = potentialTarget; } } else { if (gameHero.drivingVehicle == null) { Target = gameHero.Position; if ((gameHero.Position - Position).Length() < 100f) Target = Position; } else State = AIState.Patrolling; } break; case AIState.Investigating: if (Target == Position) { if (chasePath == null || regeneratePath) { if (genPathTime > 1000) { genPathTime = 0; regeneratePath = false; chasePath = PathFinder.FindPath(gameMap.AStarWorld, new Point3D((int)(Position.X / gameMap.TileWidth), (int)(Position.Y / gameMap.TileHeight), 0), new Point3D((int)(gameHero.HuntedLevel.LastKnownPosition.X / gameMap.TileWidth), (int)(gameHero.HuntedLevel.LastKnownPosition.Y / gameMap.TileHeight), 0)); if (chasePath != null) Target = new Vector2((chasePath.position.X * gameMap.TileWidth) + (gameMap.TileWidth / 2), (chasePath.position.Y * gameMap.TileHeight) + (gameMap.TileHeight / 2)); else State = AIState.Patrolling; } } else { chasePath = chasePath.next; if (chasePath != null) Target = new Vector2((chasePath.position.X * gameMap.TileWidth) + (gameMap.TileWidth / 2), (chasePath.position.Y * gameMap.TileHeight) + (gameMap.TileHeight / 2)); else State = AIState.Patrolling; } } if ((Position - gameHero.HuntedLevel.LastKnownPosition).Length() < 200f) State = AIState.Patrolling; if (CheckLineOfSight(gameHero.Position, gameMap)) { Target = Position; // Stop dead in tracks State = AIState.Chasing; // Begin chasing player } break; } if (gameHero.Dead) State = AIState.Patrolling; if (Health <= 0 && !Dead) { deadTime = 5000; deadAlpha = 1f; Dead = true; SpawnDrops(gameMap, gameHero); LightingEngine.Instance.RemoveSource(HeadTorch); ParticleController.Instance.AddBloodPool(Position); if (IsGeneral) { Hud.Instance.Ticker.AddLine("> You have eliminated a General! " + (3 - (3-EnemyController.Instance.Enemies.Count(e => e.IsGeneral && !e.Dead))) + "/" + (3)); } } if (IsGeneral) { if ((gameHero.Position - Position).Length() < 720f && !Discovered && gameHero.drivingVehicle==null && !LineCollision(gameHero.Position, gameMap, true)) { Discovered = true; Hud.Instance.Ticker.AddLine("> You have found a General!"); } } HeadTorch.Position = Helper.PointOnCircle(ref Position, 32, Rotation - MathHelper.PiOver2); HeadTorch.Rotation = Rotation - MathHelper.PiOver2; if (checkTorchTime > 250) { checkTorchTime = 0; if ((Position.X < gameCamera.Position.X - ((gameCamera.Width / gameCamera.Zoom) / 2) || Position.X > gameCamera.Position.X + ((gameCamera.Width / gameCamera.Zoom) / 2) || Position.Y < gameCamera.Position.Y - ((gameCamera.Height / gameCamera.Zoom) / 2) || Position.Y > gameCamera.Position.Y + ((gameCamera.Height / gameCamera.Zoom) / 2)) && LineCollision(gameHero.Position, gameMap, false)) { HeadTorch.Active = false; } } else if (!Dead) HeadTorch.Active = true; if (IsGeneral) Animations["head"].XOffset = 4; else Animations["head"].XOffset = 2; if (Dead) { if (deadTime <= 0) { deadAlpha -= 0.01f; } } if (Dead && deadTime <= 0 && deadAlpha <= 0f) { Active = false; } base.Update(gameTime, gameMap, mapFog, gameHero); }
public void Add(string text, string link) { if (_context.ViewData["breadcrumbs"] == null) { _context.ViewData["breadcrumbs"] = BreadCrumbs = new List<BreadCrumb>(); } var breadCrumb = new BreadCrumb { Link = link, Text = text }; if (!BreadCrumbs.Contains(breadCrumb)) { BreadCrumbs.Add(breadCrumb); } }
/// <summary> /// Method that switfly finds the best path from start to end. Doesn't reverse outcome /// </summary> /// <returns>The end breadcrump where each .next is a step back)</returns> private static BreadCrumb FindPathReversed(World world, Point3D start, Point3D end) { MinHeap<BreadCrumb> openList = new MinHeap<BreadCrumb>(256); BreadCrumb[, ,] brWorld = new BreadCrumb[world.Right, world.Top, world.Back]; BreadCrumb node; Point3D tmp; int cost; int diff; int count; BreadCrumb current = new BreadCrumb(start); current.cost = 0; BreadCrumb finish = new BreadCrumb(end); if (current.position.X < 0 || current.position.X > brWorld.GetUpperBound(0) || current.position.Y < 0 || current.position.Y > brWorld.GetUpperBound(0)) return null; brWorld[current.position.X, current.position.Y, current.position.Z] = current; openList.Add(current); count = 0; while (openList.Count > 0) { //Find best item and switch it to the 'closedList' current = openList.ExtractFirst(); current.onClosedList = true; //Find neighbours for (int i = 0; i < surrounding.Length; i++) { tmp = current.position + surrounding[i]; if (world.PositionIsFree(tmp) || (tmp.X==end.X && tmp.Y==end.Y && tmp.Z==end.Z)) { //Check if we've already examined a neighbour, if not create a new node for it. if (brWorld[tmp.X, tmp.Y, tmp.Z] == null) { node = new BreadCrumb(tmp); brWorld[tmp.X, tmp.Y, tmp.Z] = node; } else { node = brWorld[tmp.X, tmp.Y, tmp.Z]; } //If the node is not on the 'closedList' check it's new score, keep the best if (!node.onClosedList) { diff = 0; if (current.position.X != node.position.X) { diff += 1; } if (current.position.Y != node.position.Y) { diff += 1; } if (current.position.Z != node.position.Z) { diff += 1; } cost = current.cost + diff + node.position.GetDistanceSquared(end); if (cost < node.cost) { node.cost = cost; node.next = current; } //If the node wasn't on the openList yet, add it if (!node.onOpenList) { //Check to see if we're done if (node.Equals(finish)) { node.next = current; return node; } node.onOpenList = true; openList.Add(node); } } } } count++; if (count > 1000) return null; } return null; //no path found }
/// <summary> /// Method that switfly finds the best path from start to end. Doesn't reverse outcome /// </summary> /// <returns>The end breadcrump where each next is a step back)</returns> private static BreadCrumb FindPathReversed(Level world, BotMap level, Point3D start, Point3D end) { MinHeap<BreadCrumb> openList = new MinHeap<BreadCrumb>(256); BreadCrumb[, ,] brWorld = new BreadCrumb[world.Size.x, world.Size.y, world.Size.z]; BreadCrumb node; Point3D tmp; int cost; int diff; BreadCrumb current = new BreadCrumb(start); current.cost = 0; BreadCrumb finish = new BreadCrumb(end); try { brWorld[current.position.X, current.position.Y, current.position.Z] = current; } catch { return current; } openList.Add(current); while (openList.Count > 0) { //Find best item and switch it to the 'closedList' current = openList.ExtractFirst(); current.onClosedList = true; //Find neighbours for (int i = 0; i < surrounding.Length; i++) { tmp = current.position + surrounding[i]; if ((tmp.X <= -1 || tmp.Y <= -1 || tmp.Z <= -1) || (tmp.X >= level.Size.x || tmp.Y >= level.Size.y || tmp.Z >= level.Size.z)) break; TriBool block = false; try { block = level.AirMap[tmp.X, tmp.Z, tmp.Y]; //Check if block is air } catch { } if (block != TriBool.Unknown) { //Check if we've already examined a neighbour, if not create a new node for it. if (brWorld[tmp.X, tmp.Y, tmp.Z] == null) { node = new BreadCrumb(tmp); brWorld[tmp.X, tmp.Y, tmp.Z] = node; } else { node = brWorld[tmp.X, tmp.Y, tmp.Z]; } //If the node is not on the 'closedList' check it's new score, keep the best if (!node.onClosedList) { diff = 0; if (current.position.X != node.position.X) { diff += 1; } if (current.position.Y != node.position.Y) { diff += 1; } if (current.position.Z != node.position.Z) { diff += 1; } if (block == false) //Solid but breakable, allows bot to go through solid areas { diff += 50; } cost = current.cost + diff + node.position.GetDistanceSquared(end); if (cost < node.cost) { node.cost = cost; node.next = current; } //If the node wasn't on the openList yet, add it if (!node.onOpenList) { //Check to see if we're done if (node.Equals(finish)) { node.next = current; return node; } node.onOpenList = true; openList.Add(node); } } } } } return null; //no path found }
void DrawChasePath(SpriteBatch sb, BreadCrumb p) { if(p!=null) { sb.Draw(spriteSheet, new Vector2((p.position.X * 100) + (100 / 2), (p.position.Y * 100) + (100 / 2)), new Rectangle(50,50,10,10), Color.Red, (float)Helper.Random.NextDouble(), new Vector2(5,5)/2, 1f, SpriteEffects.None, 1); DrawChasePath(sb, p.next); } }
public bool Equals(BreadCrumb other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.Text, Text) && Equals(other.Link, Link); }
/// <summary> /// Handles bot AI /// </summary> public static void HandleBots() { foreach (Bot Bot in Server.Bots.ToArray()) { Random Random = new Random(); if (Bot.Movement) { Vector3S TemporaryLocation = new Vector3S(Bot.Player.Pos.x, Bot.Player.Pos.z, Bot.Player.Pos.y); string PlayerName = ""; if (Bot.FollowPlayers) { #region Find Closest Player bool HitAPlayer = false; Vector3S ClosestLocation = Bot.Player.Level.CWMap.Size * 32; foreach (Player p in Server.Players) { if (p.Level == Bot.Player.Level) { TargetPlayerArgs eargs = new TargetPlayerArgs(p); bool cancel = OnBotTargetPlayer.Call(Bot, eargs).Canceled; if (!cancel) { if (Bot.BlackListPlayers.ContainsKey(p.Username)) { if (Math.Abs(Bot.BlackListPlayers[p.Username] - Bot.shouldCheckAgainLoopInt) > 100) { Bot.BlackListPlayers.Remove(p.Username); } } if (p.Pos - Bot.Player.Pos < ClosestLocation - Bot.Player.Pos && !Bot.BlackListPlayers.ContainsKey(p.Username)) { HitAPlayer = true; ClosestLocation = new Vector3S(p.Pos); PlayerName = p.Username; if (Math.Abs((ClosestLocation.x / 32) - (Bot.LastPos.x / 32)) >= 12 || Math.Abs((ClosestLocation.z / 32) - (Bot.LastPos.z / 32)) >= 12) { Bot.shouldCheckAgainLoopInt = 1000; } } } } } #endregion if (HitAPlayer) { Vector3S TempLocation = new Vector3S(Bot.Player.Pos); TemporaryLocation = new Vector3S(Bot.Player.Pos); Vector3S Pathfound = new Vector3S(Bot.Player.Pos); #region AStar if (Bot.shouldCheckAgain || Bot.Waypoint == null) { Bot.Waypoint = Pathfind(Bot, ClosestLocation); Bot.LastPos = ClosestLocation; } try { Pathfound.x = (short)(Bot.Waypoint.position.X * 32); Pathfound.z = (short)(Bot.Waypoint.position.Z * 32); Pathfound.y = (short)(Bot.Waypoint.position.Y * 32); } catch { Bot.shouldCheckAgainLoopInt = 1000; try { Bot.BlackListPlayers.Add(PlayerName, Bot.shouldCheckAgainLoopInt); } catch { } break; } if (Bot.intLoop >= 2) //Slows down the bots so they arent insta-propogate, it slows them a bit too much though, need to fix { //Also makes them a bit less accurate than instant, but much more accurate than Vector2D.Move() Bot.intLoop = 0; Bot.Waypoint = Bot.Waypoint.next; } else { Bot.intLoop += 1; } TemporaryLocation.x += (short)((Pathfound.x - TemporaryLocation.x) / 2); TemporaryLocation.z += (short)((Pathfound.z - TemporaryLocation.z) / 2); //TemporaryLocation.y += (short)((Pathfound.y - TemporaryLocation.y) / 2); #endregion Block Block1 = Bot.Player.Level.GetBlock(TemporaryLocation / 32); Block Block2 = Bot.Player.Level.GetBlock((TemporaryLocation.x / 32), (TemporaryLocation.z / 32), (TemporaryLocation.y / 32) - 1); Block BlockUnderneath = Bot.Player.Level.GetBlock((TemporaryLocation.x / 32), (TemporaryLocation.z / 32), (TemporaryLocation.y / 32) - 2); Block BlockAbove = Bot.Player.Level.GetBlock((TemporaryLocation.x / 32), (TemporaryLocation.z / 32), (TemporaryLocation.y / 32) + 1); Vector3S delta = new Vector3S((short)Math.Abs(ClosestLocation.x - TemporaryLocation.x), (short)Math.Abs(ClosestLocation.z - TemporaryLocation.z), (short)Math.Abs(ClosestLocation.y - TemporaryLocation.y)); if (Block.CanWalkThrough(BlockUnderneath) && Block.CanWalkThrough(Block2) && !Block.CanEscalate(Block1) && !Block.CanEscalate(Block2)) { TemporaryLocation.y -= 21; } if (Block.CanWalkThrough(Block1) && !Block.CanWalkThrough(Block2) && !Block.CanWalkThrough(BlockUnderneath)) { TemporaryLocation.y += 21; } else if (Block.CanEscalate(Block1) && Block.CanEscalate(Block2) && Pathfound.y > TemporaryLocation.y) { TemporaryLocation.y += 21; } else if (Block.CanWalkThrough(BlockAbove) && !Block.CanWalkThrough(BlockUnderneath) && Pathfound.y > TemporaryLocation.y && !Block.IsOPBlock(BlockUnderneath)) { TemporaryLocation.y += 21; Bot.Player.Level.BlockChange((ushort)(TemporaryLocation.x / 32), (ushort)(TemporaryLocation.z / 32), (ushort)((TemporaryLocation.y / 32) - 2), 1); } else if (!Block.CanWalkThrough(BlockAbove) && !Block.CanWalkThrough(BlockUnderneath) && !Block.IsOPBlock(BlockAbove)) { Bot.Player.Level.BlockChange((ushort)(TemporaryLocation.x / 32), (ushort)(TemporaryLocation.z / 32), (ushort)((TemporaryLocation.y / 32) + 1), 0); } if (Block.CanWalkThrough(BlockUnderneath) && !Block.CanWalkThrough(Bot.Player.Level.GetBlock((Bot.Player.oldPos.x / 32), (Bot.Player.oldPos.z / 32), (Bot.Player.oldPos.y / 32) - 2)) && !Block.IsOPBlock(BlockUnderneath) && Pathfound.y > TemporaryLocation.y) { Bot.Player.Level.BlockChange((ushort)(TemporaryLocation.x / 32), (ushort)(TemporaryLocation.z / 32), (ushort)((TemporaryLocation.y / 32) - 2), 1); } if ((!Block.IsOPBlock(Block1) && !Block.IsOPBlock(Block2)) && (!Block.CanWalkThrough(Block1) && !Block.CanWalkThrough(Block2)) && (Block1 != Block.BlockList.UNKNOWN && Block2 != Block.BlockList.UNKNOWN)) { Bot.Player.Level.BlockChange(TemporaryLocation / 32, 0); Bot.Player.Level.BlockChange((ushort)(TemporaryLocation.x / 32), (ushort)(TemporaryLocation.z / 32), (ushort)((TemporaryLocation.y / 32) - 1), 0); } if (!Block.CanWalkThrough(BlockUnderneath) && (Pathfound.y / 32) < (TemporaryLocation.y / 32) && !Block.IsOPBlock(BlockUnderneath)) { Bot.Player.Level.BlockChange((ushort)(TemporaryLocation.x / 32), (ushort)(TemporaryLocation.z / 32), (ushort)((TemporaryLocation.y / 32) - 2), 0); } MoveEventArgs eargs = new MoveEventArgs(TemporaryLocation, Bot.Player.Pos); bool cancel = OnBotMove.Call(Bot, eargs).Canceled; if (cancel) { TemporaryLocation = TempLocation; } } } Bot.Player.Pos = TemporaryLocation; Bot.Player.UpdatePosition(true); //Pls leave this true, bots dont appear properly otherwise } } }
private void SetupSearchLayoutWidgets(PageModel pageModel, LayoutModel layoutModel) { var recentlyViewed = new RecentlyViewedItems { Webpage = pageModel.ProductSearch, LayoutArea = layoutModel.SearchLayout.LayoutAreas.FirstOrDefault(x => x.AreaName == "After Filters"), Name = "Recently Viewed" }; _widgetService.AddWidget(recentlyViewed); //breadcrumb var breadcrumbs = new BreadCrumb { LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == "Before Content"), Name = "Breadcrumbs", Webpage = pageModel.ProductSearch, IsRecursive = true, Cache = true, CacheExpiryType = CacheExpiryType.Sliding, CacheLength = 1800 }; _widgetService.AddWidget(breadcrumbs); }