public void Show(SellShop shop) { this.background.Source = shop.Pic; AudioManager.PlayMusic(ResourceManager.Get(shop.Music)); storePanel.Show(shop); storePanel.Callback = () => { RuntimeData.Instance.gameEngine.CallScence(this, new NextGameState() { Type = "map", Value = RuntimeData.Instance.CurrentBigMap }); }; this.Visibility = System.Windows.Visibility.Visible; }
// <summary> // 显示 // </summary> // 只显示价格为正的产品(价格为零的是非卖品) public void Show(SellShop shop) { AllSellButton.Visibility = System.Windows.Visibility.Visible; Type = ShopType.SELL; sellShop = shop; UIHost uiHost = RuntimeData.Instance.gameEngine.uihost; uiHost.RightClickCallback = null; uiHost.shopPanel.myItemsPanel.Visibility = Visibility.Collapsed; uiHost.shopPanel.SuggestText.Text = "右键快捷出售"; Dictionary <Item, int> items = shop.GetAvaliableItems(); int count = 0; RootPanel.Children.Clear(); this.money.Text = RuntimeData.Instance.Money.ToString(); this.yuanbao.Text = RuntimeData.Instance.YuanBao.ToString(); List <string> visitedItem = new List <string>(); foreach (var item in items.Keys) { if (ItemTypeCombo.SelectedItem.ToString() == "武器" && (item.Type != (int)ItemType.Weapon)) { continue; } if (ItemTypeCombo.SelectedItem.ToString() == "消耗品" && (item.Type != (int)ItemType.Costa)) { continue; } if (ItemTypeCombo.SelectedItem.ToString() == "防具" && (item.Type != (int)ItemType.Armor)) { continue; } if (ItemTypeCombo.SelectedItem.ToString() == "饰品" && (item.Type != (int)ItemType.Accessories)) { continue; } if (ItemTypeCombo.SelectedItem.ToString() == "经书" && (item.Type != (int)ItemType.Book)) { continue; } if (ItemTypeCombo.SelectedItem.ToString() == "任务物品" && (item.Type != (int)ItemType.Mission)) { continue; } if (ItemTypeCombo.SelectedItem.ToString() == "技能书" && (item.Type != (int)ItemType.TalentBook) && item.Type != (int)ItemType.Upgrade) { continue; } if (ItemTypeCombo.SelectedItem.ToString() == "残章" && (item.Type != (int)ItemType.Canzhang)) { continue; } if (ItemTypeCombo.SelectedItem.ToString() == "特殊物品" && (item.Type != (int)ItemType.Special)) { continue; } int itemCount = 1; //如果不是装备,则层叠 if (!(item.Type == (int)ItemType.Armor || item.Type == (int)ItemType.Accessories || item.Type == (int)ItemType.Weapon)) { if (visitedItem.Contains(item.Name)) { continue; } itemCount = items.Keys.Count(p => p.Name == item.Name); visitedItem.Add(item.Name); } if (count > 5) { count = 0; } ItemUnit c = new ItemUnit(); c.BindItem(item); c.ItemCount = itemCount; c.Margin = new Thickness(2, 2, 2, 5); string info = item.ToString(); int price = items[item]; Item tmp = item; c.MouseRightButtonUp += (s, e) => { if (uiHost.selectPanel.Visibility == System.Windows.Visibility.Visible) { return; } RuntimeData.Instance.Money += price; RuntimeData.Instance.Items.Remove(tmp); AudioManager.PlayEffect(ResourceManager.Get("音效.装备")); this.money.Text = RuntimeData.Instance.Money.ToString(); //uiHost.itemSelectPanel.Show(RuntimeData.Instance.Items);//刷新物品栏 this.Show(shop); e.Handled = true; }; c.MouseLeftButtonUp += (s, e) => { //uiHost.selectPanel.CallBack = () => //{ // if (uiHost.selectPanel.currentSelection == "yes") // { // RuntimeData.Instance.Money += price; // RuntimeData.Instance.Items.Remove(tmp); // AudioManager.PlayEffect(ResourceManager.Get("音效.装备")); // this.money.Text = RuntimeData.Instance.Money.ToString(); // //uiHost.itemSelectPanel.Show(RuntimeData.Instance.Items);//刷新物品栏 // this.Show(shop); // } //}; //uiHost.selectPanel.title.Text = "确定出售?"; //uiHost.selectPanel.yes.Content = "出售"; //uiHost.selectPanel.no.Content = "取消"; //uiHost.selectPanel.ShowSelection(); BuyItemWindow win = new BuyItemWindow(); win.Bind(tmp, "出售物品", (number) => { RuntimeData.Instance.Money += price * number; RuntimeData.Instance.RemoveItem(tmp.Name, number); AudioManager.PlayEffect(ResourceManager.Get("音效.装备")); this.Show(shop); }, itemCount); win.Show(); e.Handled = true; }; //ToolTipService.SetToolTip(c,info + "\n价格:" + price.ToString() + "两白银"); RichTextBox rtb = item.GenerateTooltip(); (rtb.Blocks[0] as Paragraph).Inlines.Add(new LineBreak()); (rtb.Blocks[0] as Paragraph).Inlines.Add(new LineBreak()); (rtb.Blocks[0] as Paragraph).Inlines.Add(new Run() { Text = "价格:" + price.ToString() + "两白银", FontSize = 12, FontWeight = FontWeights.Bold }); ToolTipService.SetToolTip(c, rtb); RootPanel.Children.Add(c); count++; } this.Visibility = System.Windows.Visibility.Visible; }
protected void initializeShop(){ if(playerEnabled && Application.loadedLevelName == townSceneName){ mainShop = (MainShopMenu) GameObject.FindObjectOfType (typeof (MainShopMenu)); sellShop = (SellShop) GameObject.FindObjectOfType (typeof (SellShop)); fighterShop = (FighterShop) GameObject.FindObjectOfType (typeof (FighterShop)); sorcererShop = (SorcererShop) GameObject.FindObjectOfType (typeof (SorcererShop)); } }