//------------------------------------------------------------------------------------------------------------------------ // Initialize() //------------------------------------------------------------------------------------------------------------------------ public void Initialize() { var itemGenerator = new Generator(new NormalItemFactory()); //Set up the model and controller _shopModel = new ShopModel(itemGenerator.CreateRandomItems(Globals.ItemsPerShop)); _shopController = new ShopController(_shopModel); //get view from children _shopView = GetComponentInChildren <ShopView>(); _shopView.Subscribe(_shopModel); Debug.Assert(_shopView != null); //get mesageview from children _shopMessageView = GetComponentInChildren <ShopMessageView>(); _shopMessageView.Subscribe(_shopModel); Debug.Assert(_shopMessageView != null); //get itemInfoView from children _shopItemInfoView = GetComponentInChildren <ShopItemInfoView>(); _shopItemInfoView.Subscribe(_shopModel); //setup model and controller //link them _shopView.Initialize(_shopController, Game.PlayerHumanoid); //view1 _shopMessageView.Initialize(_shopModel); //view2 }
public ActionResult Edit(ShopView editShop) { if (ModelState.IsValid) { var editDbShop = db.Shops.FirstOrDefault(f => f.Id == editShop.Id); if (editDbShop == null) { return(HttpNotFound()); } else { if (editShop.ShopImage != null && editShop.ShopImage.ContentLength > 0) { editDbShop.SaveImageFile(editShop.ShopImage, "/Image/Shops"); } editShop.ViewFromDb(editDbShop); editDbShop.IsActive = Convert.ToBoolean(editShop.Activ); db.SaveChanges(); return(RedirectToAction("Index")); } } else { return(HttpNotFound()); } }
//------------------------------------------------------------------------------------------------------------------------ // ShopBrowseState() //------------------------------------------------------------------------------------------------------------------------ public ShopBrowseState(List <Item> items, Actor pCustumer) { //create shop ShopModel shop = new ShopModel(items); //create controller _shopController = new ShopController(shop); //create shop view _shopView = new ShopView(_shopController, pCustumer); _shopView.Subscribe(shop); AddChild(_shopView); Helper.AlignToCenter(_shopView, true, true); //create item info view _itemInfoView = new ItemInfoView(); _itemInfoView.Subscribe(shop); AddChild(_itemInfoView); //create message view _shopMessageView = new ShopMessageView(); _shopMessageView.Subscribe(shop); AddChild(_shopMessageView); Helper.AlignToCenter(_shopMessageView, true, false); }
public ShopController( ShopView view, ShopModel shopModel, RoundEndModel roundEndModel, ProfileModel profileModel, UpgradesModel upgradesModel, UpgradeService upgradeService) : base(view) { _view = view; _view.Initialize(); _roundEndModel = roundEndModel; _shopModel = shopModel; _profileModel = profileModel; _upgradesModel = upgradesModel; _upgradeService = upgradeService; _roundEndModel.OpenShop .Subscribe(_ => Open()) .AddTo(Disposer); SetupOnClick(); SetupProfileModel(); SetupUpgradesModel(); }
//------------------------------------------------------------------------------------------------------------------------ // Initialize() //------------------------------------------------------------------------------------------------------------------------ public void Initialize() { //Set up the model and controller shopModel = new ShopModel(); shopController = new ShopController(shopModel); //get view from children shopView = GetComponentInChildren <ShopView>(); Debug.Assert(shopView != null); //get mesageview from children shopMessageView = GetComponentInChildren <ShopMessageView>(); Debug.Assert(shopMessageView != null); //setup model and controller //link them shopView.Initialize(shopModel, shopController); //view1 shopMessageView.Initialize(shopModel); //view2 shopView.Subscribe(shopModel); }
public ViewFactory() { _views = new Dictionary <string, UserControl>(); _views["ninja"] = new NinjaListView(); _views["shop"] = new ShopView(); _views["equipment"] = new EquipmentListView(); }
public MoveSelectionCommand( ShopController pShopController, ShopView pShopView, int pNewX, int pNewY) { _shopController = pShopController; _shopView = pShopView; _newX = pNewX; _newY = pNewY; }
// Use this for initialization protected override void Start() { myView = ShopView.singleton; base.Start(); if (currentSaveData != null) { myView.UpdateView(currentSaveData); } }
public ShopController(List <Boost> boostEntries, ShopView shopView) { ShopView = shopView; Dictionary <Boost, Button> buttons = shopView.PrepareShopEntriesAndButtons(boostEntries); foreach (KeyValuePair <Boost, Button> keyValuePair in buttons) { keyValuePair.Value.onClick.AsObservable().Subscribe(x => BuyBoost(keyValuePair.Key)); } }
private bool _canBuy = true; //si estamos en el medio de la oleada, no podemos comprar por ejemplo. private void Awake() { _shopMng = transform.parent.GetComponent <ShopsManager>(); _view = GetComponent <ShopView>(); _controller = new ShopControl(this); _itemScroller = GetComponentInChildren <ShopItemScroller>(); _itemScroller.shopModel = this; _itemScroller.shopMng = _shopMng; _itemScroller.UpdateIcons(); _audioControl = GetComponent <ShopAudioController>(); }
private Shop ToShop(ShopView view, string pic) { return(new Shop { SellerId = view.SellerId, ImagePath = pic, ShopName = view.ShopName, ShopAddres = view.ShopAddres, Latitude = view.Latitude, Longitude = view.Longitude, ShopPhone = view.ShopPhone }); }
/// <summary> /// Constructor for menu /// </summary> /// <param name="shopView"></param> public ShopViewModel(ShopView shopView, Shop shop) { this.shopView = shopView; this.shop = shop; this.shopView.MenuLabel.Content = "Menu principal Magasin " + shop.Name; Session.Shop = shop; this.shopView.ClientManagerBtn.Click += ClientManagerBtn_Click; //this.shopView.ProviderManagerBtn.Click += ProviderManagerBtn_Click; this.shopView.ProductManagerBtn.Click += ProductManagerBtn_Click; this.shopView.OwnerManagerBtn.Click += OwnerManagerBtn_Click; this.shopView.OrderManagerBtn.Click += OrderManagerBtn_Click; this.shopView.CategoryManagerBtn.Click += CategoryManagerBtn_Click; }
private static bool ConditionCheckPrefix(ref int __result, ShopView __instance, ShopInfo.Param param) { // If not a custom item and not set to be non-restockable, use stock game code if (param.ID < MinimumItemId || param.InitType != -1) { return(true); } // If custom item is set as restockable then base game code will only allow 1 of this item // to be bought and then set it as sold out, so we need to patch around that here __instance.player.buyNumTable.TryGetValue(param.ID, out var bought); __result = param.Num - bought; return(false); }
public async Task <IActionResult> Create(ShopView model) { try { await _shopRepository.AddOrUpdateAsync(_mapper.Map <ShopView, Shop>(model), true); return(Ok()); } catch (Exception e) { Log.Error(e, "ShopController.Create"); return(BadRequest(_messageModelBuilder.CreateModel("500", e.Message))); } }
public void Init(GameManager gameManager, IapGoodItem iapItem, ShopView shop) { base.Init(gameManager); IapItem = iapItem; _item = BaseObjectFactory.GetItem(IapItem.RewardItemName); _shop = shop; NameLabel.text = Localization.Get(IapItem.LocalizedTitle); IconSprite.spriteName = _item.IconName; PriceLabel.text = IapItem.Price.ToString(); AmountLabel.text = "x" + IapItem.RewardAmount; UIEventListener.Get(BuyButton).onClick += OnBuyClick; }
private void Awake() { _view = GetComponent <ShopView>(); _moneyController = FindObjectOfType <MoneyController>(); if (!_view) { throw new Exception($"{gameObject.name} does not have component! - {_view.GetType()}"); } if (!_moneyController) { throw new Exception($"{gameObject.name} does not have component! - {_moneyController.GetType()}"); } }
public GameViewModel(Game game, MainWindowViewModel baseViewModel) { this.game = game; OnHelloWorldButtonClickCommand = new RelayCommand(OnHelloWorldButtonClick); OnMenuCommand = new RelayCommand(OnMenuButtonClick); OnShopButtonClickCommand = new RelayCommand(OnShopButtonClick); OneSecondTimer oneSecondTimer = new OneSecondTimer(); oneSecondTimer.DispatcherTimer.Tick += OnTimerEnd; this.baseViewModel = baseViewModel; this.shopView = new ShopView() { DataContext = new ShopViewModel(this.game) }; }
//------------------------------------------------------------------------------------------------------------------------ // ShopBrowseState() //------------------------------------------------------------------------------------------------------------------------ public ShopBrowseState() { //create shop ShopModel shop = new ShopModel(); //create controller shopController = new ShopController(shop); //create shop view shopView = new ShopView(shop, shopController); AddChild(shopView); Helper.AlignToCenter(shopView, true, true); //create message view shopMessageView = new ShopMessageView(shop); AddChild(shopMessageView); Helper.AlignToCenter(shopMessageView, true, false); }
// 店铺信息及其拥有的所有商品 //public List<ShopCommodityView> getShopCommodities(string shopid) public ShopCommodityView getShopCommodities(string shopid) { Shop shop = _context.Shops.Where(x => x.ShopId == shopid).FirstOrDefault(); // 店铺信息 //List<ShopCommodityView> shopCommodityViews = new List<ShopCommodityView>(); // 返回信息列表 List <Commodity> shopCommodities = _context.Commodities.Where(x => x.ShopId == shopid).ToList(); // 所有商品 List <CommodityView> commodityViews = new List <CommodityView>(); foreach (var shopcommodity in shopCommodities) { CommodityView commodityView = new CommodityView { CommodityId = shopcommodity.CommodityId, ShopId = shopcommodity.ShopId, Url = shopcommodity.Url, Category = shopcommodity.Category, Name = shopcommodity.Name, Price = shopcommodity.Price, Storage = shopcommodity.Storage, Soldnum = shopcommodity.Soldnum, Description = shopcommodity.Description }; commodityViews.Add(commodityView); } ShopView shopView = new ShopView { shopID = shop.ShopId, shopName = shop.Name, shopDescription = shop.Description, img = shop.Url, creditScore = shop.CreditScore }; ShopCommodityView shopCommodityView = new ShopCommodityView { Shop = shopView, CommodityViews = commodityViews }; return(shopCommodityView); }
public async Task <IActionResult> Edit(ShopView model) { try { var editedItem = (await _shopRepository.GetSingleAsync(model.Id)); if (editedItem == null) { return(NotFound()); } editedItem.Name = model.Name; editedItem.CompanyId = model.CompanyId; await _shopRepository.AddOrUpdateAsync(editedItem, true); return(Ok()); } catch (Exception e) { Log.Error(e, "ShopController.Edit"); return(BadRequest(_messageModelBuilder.CreateModel("500", e.Message))); } }
//------------------------------------------------------------------------------------------------------------------------ // Initialize() //------------------------------------------------------------------------------------------------------------------------ public void Initialize(ShopView shopView, Item item, bool isSelected) { //store item this.shopView = shopView; this.item = item; //set checkmark visibility if (isSelected) { checkMark.SetActive(true); } //set button image Image image = GetComponentInChildren <Image>(); Sprite sprite = SpriteCache.Get("item"); if (sprite != null) { image.sprite = sprite; } }
public async Task <ActionResult> Create(ShopView shopView) { if (ModelState.IsValid) { ShopDb shopDb = new ShopDb(); shopView.ViewFromDb(shopDb); if (shopView.ShopImage != null && shopView.ShopImage.ContentLength > 0) { shopDb.SaveImageFile(shopView.ShopImage, "/Image/Shops"); } else { shopDb.ImagePath = null; } shopDb.IsActive = Convert.ToBoolean(shopView.Activ); db.Shops.Add(shopDb); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(shopView)); }
public async Task <ActionResult> Create(ShopView view) { if (ModelState.IsValid) { var pic = string.Empty; var folder = "~/Content/Shops"; if (view.ImageFile != null) { pic = FilesHelper.UploadPhoto(view.ImageFile, folder); pic = $"{folder}/{pic}"; } var shop = this.ToShop(view, pic); db.Shops.Add(shop); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.SellerId = new SelectList(db.Sellers, "SellerId", "SellerName", view.SellerId); return(View(view)); }
public async Task <ActionResult> Edit(ShopView view) { if (ModelState.IsValid) { var pic = view.ImagePath; var folder = "~/Content/Shops"; if (view.ImageFile != null) { pic = FilesHelper.UploadPhoto(view.ImageFile, folder); pic = $"{folder}/{pic}"; } var shop = this.ToShop(view, pic); this.db.Entry(shop).State = EntityState.Modified; await this.db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.SellerId = new SelectList(db.Sellers, "SellerId", "SellerName", view.SellerId); return(View(view)); }
public ShopState(GameEngine context, UserInterface ui, ShopView view) : base(context, ui) { this.view = view; }
//GET: Shop public ActionResult Index(int page, int?CID, int?PID) { //string.IsNullOrEmpty(""); ShopView AllList = new ShopView(); //bool IsInt_PID = int.TryParse(PID.ToString(), out int result); bool IsInt_PID = (PID is null); int isint_pid_val = PID.GetValueOrDefault(); if (CID == null) { var pro = from pr in db.Products join c in db.Categories on pr.CategoryID equals c.CategoryID where (pr.Status == "上架" && IsInt_PID || pr.ProductID == isint_pid_val) select new ProductView { CategoryID = pr.CategoryID, CategoryName = c.CategoryName, Description = pr.Description, Picture = pr.Picture, ProductID = pr.ProductID, ProductName = pr.ProductName, SupplierID = pr.SupplierID, SalesPrice = pr.SalesPrice, Status = pr.Status }; AllList.Product = pro.ToList(); } else { var products = db.Products.Where(c => c.CategoryID == CID & c.Status == "上架").Select(x => new ProductView { CategoryID = x.CategoryID, CategoryName = x.Category.CategoryName, Description = x.Description, Picture = x.Picture, ProductID = x.ProductID, ProductName = x.ProductName, SupplierID = x.SupplierID, SalesPrice = x.SalesPrice, Status = x.Status }); AllList.Product = products.ToList(); } var cat = from ca in db.Categories select new CategoryView { CategoryID = ca.CategoryID, Picture = ca.Picture, CategoryName = ca.CategoryName }; AllList.Category = cat.ToList(); var Sup = from su in db.Suppliers select new SupplierView { SupplierID = su.SupplierID, CampanyPhone = su.CampanyPhone, CompanyName = su.CompanyName, CompanyAddress = su.CompanyAddress }; AllList.Supplier = Sup.ToList(); //分頁的內容AllList.Product.ToPagedList(page, 幾個物件) ViewBag.MyPageList = AllList.Product.ToPagedList(page, 9); return(View(AllList)); }
void Awake() { singleton = this; }
//搜索店铺 public List <ShopView> SearchShop(string shopName, int searchType = 0)//根据搜索字,寻找所有包含关键字的店铺,返回店铺列表 { Random random = new Random(GetRandomSeedbyGuid()); List <Shop> newShopList = new List <Shop>(); List <ShopView> returnList = new List <ShopView>(); List <ShopView> tempList = new List <ShopView>(); int count = 0; int number = 0; if (shopName == "") { for (int i = 0; i < 4; i++) { string randShopID = random.Next(1, 1).ToString(); Shop newShop = _context.Shops.FirstOrDefault(c => c.ShopId == randShopID); ShopView newShopView = new ShopView(); newShopView.shopName = newShop.Name; newShopView.shopDescription = newShop.Description; newShopView.img = newShop.Url; newShopView.creditScore = newShop.CreditScore; newShopView.shopID = newShop.ShopId; returnList.Add(newShopView); } } else if (searchType == 0) { List <Shop> shopList = _context.Shops.ToList(); foreach (var item in shopList) { Regex r = new Regex("[" + shopName + "]"); MatchCollection m = r.Matches(item.Name); if (m.Count != 0) { count++; newShopList.Add(item); } } foreach (Shop newShop in newShopList) { number++; ShopView newShopView = new ShopView(); newShopView.shopID = newShop.ShopId; newShopView.shopName = newShop.Name; newShopView.shopDescription = newShop.Description; newShopView.img = newShop.Url; newShopView.creditScore = newShop.CreditScore; returnList.Add(newShopView); if (number == 4) { break; } } if (count < 4) { for (int i = count; i < 4; i++) { string randShopID = random.Next(1, 1).ToString(); Shop newShop = _context.Shops.FirstOrDefault(c => c.ShopId == randShopID); ShopView newShopView = new ShopView(); newShopView.shopName = newShop.Name; newShopView.shopDescription = newShop.Description; newShopView.img = newShop.Url; newShopView.creditScore = newShop.CreditScore; newShopView.shopID = newShop.ShopId; returnList.Add(newShopView); } } } else if (searchType == 1) { List <Shop> shopList = _context.Shops.OrderByDescending(s => s.CreditScore).ToList(); foreach (var item in shopList) { Regex r = new Regex("[" + shopName + "]"); MatchCollection m = r.Matches(item.Name); if (m.Count != 0) { count++; newShopList.Add(item); } } foreach (Shop newShop in newShopList) { number++; ShopView newShopView = new ShopView(); newShopView.shopID = newShop.ShopId; newShopView.shopName = newShop.Name; newShopView.shopDescription = newShop.Description; newShopView.img = newShop.Url; newShopView.creditScore = newShop.CreditScore; tempList.Add(newShopView); if (number == 4) { break; } } if (count < 4) { for (int i = count; i < 4; i++) { string randShopID = random.Next(1, 1).ToString(); Shop newShop = _context.Shops.FirstOrDefault(c => c.ShopId == randShopID); ShopView newShopView = new ShopView(); newShopView.shopID = newShop.ShopId; newShopView.shopName = newShop.Name; newShopView.shopDescription = newShop.Description; newShopView.img = newShop.Url; newShopView.creditScore = newShop.CreditScore; tempList.Add(newShopView); } int[] judge = new int[tempList.Count]; for (int i = 0; i < tempList.Count; i++) { int maxIndex = 0; while (judge[maxIndex] == 1) { maxIndex++; } for (int j = 0; j < tempList.Count; j++) { if (tempList[j].creditScore > tempList[maxIndex].creditScore && judge[j] != 1) { maxIndex = j; } } ShopView tempShopView = new ShopView(); tempShopView = tempList[maxIndex]; returnList.Add(tempShopView); judge[maxIndex] = 1; } } } return(returnList); }
public AzsController(VisualElement element, ShopView azs) { _azs = azs; }