private void SpawnFirstCharacter() { GameObject newCharacter = Instantiate(m_characterPrefab); newCharacter.transform.parent = transform; float randomX = Random.Range(m_xMin, m_xMax); float randomY = Random.Range(m_yMin, m_yMax); newCharacter.transform.localPosition = new Vector3(randomX, randomY, 0.0f); List <Item> topList = m_itemsDatabase.GetItems(Item.ItemType.Top); int topIndex = Random.Range(0, topList.Count); TopItem top = (TopItem)topList[topIndex]; newCharacter.GetComponent <Character>().AssignTop(top); List <Item> bottomList = m_itemsDatabase.GetItems(Item.ItemType.Bottom); int bottomIndex = Random.Range(0, bottomList.Count); BottomItem bottom = (BottomItem)bottomList[bottomIndex]; newCharacter.GetComponent <Character>().AssignBottom(bottom); AssignHead(Item.ItemType.Head, newCharacter); AssignFace(Item.ItemType.Face, newCharacter); AssignHeadAccessory(Item.ItemType.HeadAccessory, newCharacter); AssignFaceAccessory(Item.ItemType.FaceAccessory, newCharacter); newCharacter.GetComponent <Character>().InitOrders(); newCharacter.GetComponentInChildren <SuspectController>().IsTarget = true; m_characters.Add(newCharacter); m_zManager.m_playersAndObstacles.Add(newCharacter); }
public void InPaint() { if (Width > 0 && Height > 0) { int Topsz = 0; if (Items.Count != 0) { for (int i = 0; i < Items.Count; i++) { TopItem it = Items[i]; it.Index = i; if (it.Visible) { Size sizeF = TextRenderer.MeasureText(it.Name, this.Font); it.FontWidth = sizeF.Width; it.FontHeight = sizeF.Height + 10; it.Name_Bounds = new Rectangle(Topsz + 10, (Height - it.FontHeight) / 2, it.FontWidth, it.FontHeight); it.SelectBounds = new Rectangle(Topsz + 10, 5, it.FontWidth, 5); it.Bounds = new Rectangle(Topsz, 0, it.FontWidth + 20, Height); it.ErrBounds = new Rectangle((it.Bounds.X + it.Bounds.Width) - 16, 12, 16, 16); Topsz += it.Bounds.Width; } } Tops = Topsz; if (chatVScroll.VirtualWidth != Tops) { chatVScroll.VirtualHeight = Height; chatVScroll.VirtualWidth = Tops; Invalidate(chatVScroll.Bounds); } } } }
public async Task <IActionResult> Edit(int id, [Bind("Id,PopularRate,Type,Name,ShorDescription,Description,Author,LocalPrice,WorldPrice,SmallPhotoId,MainPhotoId,PhotosIds,LikedUsersIds,IsActive,IsVIP,VipExpirationDate,TotalSum,InstagramUrl,InstagramLikesCount,FacebookUrl,FacebookLikesCount,VkUrl,VkLikesCount,PinterestUrl,PinterestLikesCount,MediumUrl,MediumLikesCount,AmazonUrl,AmazonLikesCount,AmazonPrice,EbayUrl,EbayLikesCount,EbayPrice,AvitoUrl,AvitoLikesCount,AvitoPrice,OlxUrl,OlxLikesCount,OlxPrice,KufarUrl,KufarLikesCount,KufarPrice,OnlinerUrl,OnlinerLikesCount,OnlinerPrice,vek21Url,vek21LikesCount,vek21Price,IsAdultContent")] TopItem topItem) { if (id != topItem.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(topItem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TopItemExists(topItem.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(topItem)); }
public override void ApplyRule(TopItem item) { if (item == null) { return; } var potentialMatches = TopItemsRepo.GetItemsAsync(i => i.Name == item.Name).Result.ToList(); logger.LogInformation("{0} potential existing matches found.", potentialMatches?.Count); logger.LogInformation("Looking for potential matches in {0}", item.Date.AddDays(-1).ToString("yyyy-MM-dd")); var potentialMatch = potentialMatches .FirstOrDefault(p => p.Date.ToString("yyyy-MM-dd") == item.Date.AddDays(-1).ToString("yyyy-MM-dd") && p.Hits > 0); if (potentialMatch == null || potentialMatch.Hits < item.Hits) { logger.LogInformation("Apply bonus. Reason: {0}{1}{2}", (potentialMatch == null) ? "Not found item with name " : "Found the item with name: ", item.Name, (potentialMatch == null) ? "." : $" but with Hits in db = {potentialMatch.Hits} compared with new hits = {item.Hits}"); AddHitsAndRankingBonus(item); } else { logger.LogInformation( "No bonus just hits. Reason: Item in the db with name:{0} with existing hits {1} matched against the new item {2} with new hits {3}", potentialMatch.Name, potentialMatch.Hits, item.Name, item.Hits); AddHits(item); } }
public void ApplyAllRules(TopItem item) { logger.LogInformation("Applying {0} rules to {1}", _rules.Count, item.Name); foreach (var rule in _rules) { rule.ApplyRule(item); } logger.LogInformation("All Rules applied."); }
public override void ApplyRule(TopItem item) { if (item == null) { return; } item.Score += (item.Loved * _lovedBonus); logger.LogInformation("After calculating score based on rule{2} item {0} has score {1}", item.Name, item.Score, this); }
public void AssignTop(TopItem _top) { m_top = _top; m_trunkAnchor.GetComponent <SpriteRenderer>().sprite = m_top.m_trunkSprite; m_topLAnchor.GetComponent <SpriteRenderer>().sprite = m_top.m_topLsprite; m_topRAnchor.GetComponent <SpriteRenderer>().sprite = m_top.m_topRsprite; m_botLAnchor.GetComponent <SpriteRenderer>().sprite = m_top.m_botLsprite; m_botRAnchor.GetComponent <SpriteRenderer>().sprite = m_top.m_botRsprite; }
private void StoreItem(TopItem topItem) { if (topItem == null || topItem.Date == DateTime.MinValue || string.IsNullOrEmpty(topItem.Name) || (topItem.Hits == 0 && topItem.Loved == 0)) { throw new ArgumentNullException(nameof(topItem)); } _itemsRepo.UpsertItemAsync(topItem).Wait(); logger.LogInformation("Persisted item {0}", topItem.Name); }
public decimal Calculate(TopItem topItem) { decimal rate = 0; if (!string.IsNullOrEmpty(topItem.InstagramUrl)) { } return(rate); }
private void UpdateItemsState() { var buttons = ButtonBarUtil.GetButtonsFromBarItems(TopItem.GetNavItemBarItems()); foreach (var button in buttons) { button.SemiTransparentType = ItemSemiTransparentType; button.UpdateState(); } }
private void InitializeVIP(TopItem item) { if (false) //TODO: replace with checking some transaction { item.IsVIP = true; item.VipExpirationDate = DateTime.Now.AddDays(7); //item.TotalSum = someTransaction.Sum; } else { item.IsVIP = false; item.TotalSum = 0; } }
public override void MergeSourceProperties(TopItem fromItem, TopItem toItem) { if (fromItem == null) { throw new ArgumentNullException(nameof(fromItem)); } if (toItem == null) { throw new ArgumentNullException(nameof(toItem)); } toItem.Loved = fromItem.Loved; logger.LogInformation("After merge top Item has been set to {toItem.Loved} Loved.", toItem.Loved); }
public void SetSvs(TopItem TopItem) { if (chatVScroll.ShouldBeDraw) { if (chatVScroll.Value + Width < TopItem.Bounds.X + 100) { chatVScroll.Value += 5; } else if (chatVScroll.Value > TopItem.Bounds.X - 100) { chatVScroll.Value -= 5; } } }
public void SetSv(TopItem TopItem) { if (chatVScroll.ShouldBeDraw) { if (chatVScroll.Value + Width < TopItem.Bounds.X) { chatVScroll.Value = TopItem.Bounds.X; } else if (chatVScroll.Value > TopItem.Bounds.X) { chatVScroll.Value = TopItem.Bounds.X - 150; } } }
public override void MergeSourceProperties(TopItem fromItem, TopItem toItem) { if (fromItem == null) { throw new ArgumentNullException(nameof(fromItem)); } if (toItem == null) { throw new ArgumentNullException(nameof(toItem)); } toItem.Hits = fromItem.Hits; toItem.DayRanking = fromItem.DayRanking; logger.LogInformation( "After merge topItem has been set to:{toItem.Hits} Hits and {toItem.DayRanking} DayRanking.", toItem.Hits, toItem.DayRanking); }
public async Task <IActionResult> Create([Bind("Id,Type,Name,ShorDescription,Description,LocalPrice,WorldPrice,SmallPhotoId,MainPhotoId,PhotosIds,InstagramUrl,InstagramLikesCount,FacebookUrl,FacebookLikesCount,VkUrl,VkLikesCount,PinterestUrl,PinterestLikesCount,MediumUrl,MediumLikesCount,AmazonUrl,AmazonLikesCount,AmazonPrice,EbayUrl,EbayLikesCount,EbayPrice,AvitoUrl,AvitoLikesCount,AvitoPrice,OlxUrl,OlxLikesCount,OlxPrice,KufarUrl,KufarLikesCount,KufarPrice,OnlinerUrl,OnlinerLikesCount,OnlinerPrice,vek21Url,vek21LikesCount,vek21Price,IsAdultContent")] TopItem topItem) { if (ModelState.IsValid) { topItem.PopularRate = new CalculateRate().Calculate(topItem); topItem.Author = GetUserIdFromContext(); //TODO: only authorised users can create new items InitializeVIP(topItem); InitializeAdultCheck(topItem); topItem.IsActive = true; _context.Add(topItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(topItem)); }
public override void LayoutSubviews() { base.LayoutSubviews(); // manually adjusting position of items in landscape (stick it to bottom) if (!ScreenUtil.IsVerticalOrientation) { var itemViews = ButtonBarUtil.GetViewsFromBarItems(TopItem.GetNavItemBarItems()); foreach (var itemView in itemViews) { var frame = new CGRect( new CGPoint(itemView.Frame.X, Frame.Height - itemView.Frame.Height), itemView.Frame.Size); itemView.Frame = frame; } } }
protected override void OnSizeChanged(EventArgs e) { if (Width > 0 && Height > 0) { int Topsz = 0; if (Items.Count != 0) { for (int i = 0; i < Items.Count; i++) { TopItem it = Items[i]; it.Index = i; if (it.Visible) { it.Name_Bounds = new Rectangle(Topsz + 10, (Height - it.FontHeight) / 2, it.FontWidth, it.FontHeight); it.SelectBounds = new Rectangle(Topsz + 10, 5, it.FontWidth, 5); it.Bounds = new Rectangle(Topsz, 0, it.FontWidth + 20, Height); it.ErrBounds = new Rectangle((it.Bounds.X + it.Bounds.Width) - 16, 12, 16, 16); Topsz += it.Bounds.Width; } } Tops = Topsz; chatVScroll.VirtualHeight = Height; chatVScroll.VirtualWidth = Tops; Invalidate(chatVScroll.Bounds); } } //InPaint(); //int height = Height; //foreach (TopItem it in Items) //{ // it.Bounds = new Rectangle(it.Bounds.X, it.Bounds.Y, it.Bounds.Width, height); //} //if (chatVScroll.VirtualWidth != Tops) //{ // chatVScroll.VirtualHeight = height; // chatVScroll.VirtualWidth = Tops; // Invalidate(chatVScroll.Bounds); //} base.OnSizeChanged(e); }
private void SpawnCharacterV3(List <ItemClue> _defClues) { GameObject newCharacter = Instantiate(m_characterPrefab); newCharacter.transform.parent = transform; float randomX = Random.Range(m_xMin, m_xMax); float randomY = Random.Range(m_yMin, m_yMax); newCharacter.transform.localPosition = new Vector3(randomX, randomY, 0.0f); List <Item> topList = m_itemsDatabase.GetItems(Item.ItemType.Top); int topIndex = Random.Range(0, topList.Count); TopItem top = (TopItem)topList[topIndex]; newCharacter.GetComponent <Character>().AssignTop(top); List <Item> bottomList = m_itemsDatabase.GetItems(Item.ItemType.Bottom); int bottomIndex = Random.Range(0, bottomList.Count); BottomItem bottom = (BottomItem)bottomList[bottomIndex]; newCharacter.GetComponent <Character>().AssignBottom(bottom); AssignHead(Item.ItemType.Head, newCharacter); AssignFace(Item.ItemType.Face, newCharacter); AssignHeadAccessory(Item.ItemType.HeadAccessory, newCharacter); AssignFaceAccessory(Item.ItemType.FaceAccessory, newCharacter); newCharacter.GetComponent <Character>().InitOrders(); if (m_characters.Count > 0 && newCharacter.GetComponent <Character>().RespectClues(_defClues)) { // same as the bad guy // Debug.Log("Duplicate"); } else { m_characters.Add(newCharacter); m_zManager.m_playersAndObstacles.Add(newCharacter); } }
private void SpawnCharacterWithConstraints(List <Constraint> _constraints) { GameObject newCharacter = Instantiate(m_characterPrefab); newCharacter.transform.parent = transform; float randomX = Random.Range(m_xMin, m_xMax); float randomY = Random.Range(m_yMin, m_yMax); newCharacter.transform.localPosition = new Vector3(randomX, randomY, 0.0f); TopItem itemTop = HasTopConstraint(_constraints); if (itemTop == null) { List <Item> topList = m_itemsDatabase.GetItems(Item.ItemType.Top); int topIndex = Random.Range(0, topList.Count); TopItem top = (TopItem)topList[topIndex]; newCharacter.GetComponent <Character>().AssignTop(top); } else { newCharacter.GetComponent <Character>().AssignTop(itemTop); } BottomItem itemBottom = HasBottomConstraint(_constraints); if (itemBottom == null) { List <Item> bottomList = m_itemsDatabase.GetItems(Item.ItemType.Bottom); int bottomIndex = Random.Range(0, bottomList.Count); BottomItem bottom = (BottomItem)bottomList[bottomIndex]; newCharacter.GetComponent <Character>().AssignBottom(bottom); } else { newCharacter.GetComponent <Character>().AssignBottom((BottomItem)itemBottom); } Item itemHead = HasConstraint(_constraints, Item.ItemType.Head); if (itemHead == null) { AssignHead(Item.ItemType.Head, newCharacter); } else { newCharacter.GetComponent <Character>().AssignHead((SimpleItem)itemHead); } Item itemFace = HasConstraint(_constraints, Item.ItemType.Face); if (itemFace == null) { AssignFace(Item.ItemType.Face, newCharacter); } else { newCharacter.GetComponent <Character>().AssignFace((SimpleItem)itemFace); } Item itemHeadAccessory = HasConstraint(_constraints, Item.ItemType.HeadAccessory); if (itemHeadAccessory == null) { AssignHeadAccessory(Item.ItemType.HeadAccessory, newCharacter); } else { newCharacter.GetComponent <Character>().AssignHeadAccessory((SimpleItem)itemHeadAccessory); } Item itemFaceAccessory = HasConstraint(_constraints, Item.ItemType.FaceAccessory); if (itemFaceAccessory == null) { AssignFaceAccessory(Item.ItemType.FaceAccessory, newCharacter); } else { newCharacter.GetComponent <Character>().AssignFaceAccessory((SimpleItem)itemFaceAccessory); } newCharacter.GetComponent <Character>().InitOrders(); m_characters.Add(newCharacter); m_zManager.m_playersAndObstacles.Add(newCharacter); }
private void InitializeAdultCheck(TopItem item) { //TODO: item.IsAdultContent = item.IsAdultContent && AdultChecker.IsPossiblyAdultContent(item); image recognition ? or googling ? or smth like that ? }
public ProgressEventArgs(TopItem topItem, Status status) { Status = status; TopItem = topItem; }
public abstract void MergeSourceProperties(TopItem fromItem, TopItem toItem);
public bool IsSameItem(TopItem _topItem) { return(m_trunkSprite == _topItem.m_trunkSprite); }
public abstract void ApplyRule(TopItem item);
private void AddHitsAndRankingBonus(TopItem item) { item.Score += ((item.Hits == 0) ? 0 : (item.Hits + _rankingBonus / item.DayRanking)); logger.LogInformation("After calculating score based on rule{2} item {0} has score {1}", item.Name, item.Score, this); }
private void AddHits(TopItem item) { item.Score += item.Hits; logger.LogInformation("After calculating score based on rule{2} item {0} has score {1}", item.Name, item.Score, this); }
public bool Kdown(Keys KeyCode) { if (KeyCode == Keys.Right) { //int seb = SelectIndex; //doha(seb); int seb = SelectIndex; int bbqq = seb + 1; if (bbqq < Items.Count) { TopItem TopItem = Items[bbqq]; SelectIndex = TopItem.Index; SetSv(TopItem); foreach (TopItem TopItems in Items) { if (TopItems.Select) { TopItems.Select = false; Tom(TopItems); } } if (!TopItem.Select) { TopItem.Select = true; Tom(TopItem); } } return(true); } else if (KeyCode == Keys.Left) { int seb = SelectIndex; int bbqq = seb - 1; if (bbqq >= 0) { TopItem TopItem = Items[bbqq]; SelectIndex = TopItem.Index; SetSv(TopItem); foreach (TopItem TopItems in Items) { if (TopItems.Select) { TopItems.Select = false; Tom(TopItems); } } if (!TopItem.Select) { TopItem.Select = true; Tom(TopItem); } } return(true); } else if (KeyCode == Keys.Enter || KeyCode == Keys.Space) { if (SelectIndex != -1) { TopItem TopItem = Items[SelectIndex]; if (TopItem != null) { SelectItem = TopItem; if (TopItem.Visible) { if (DownClick != null) { DownClick(TopItem); } return(true); } } } } return(false); }