private void RefreshMyItems() { StackPanel currentPanel = null; UIHost uiHost = RuntimeData.Instance.gameEngine.uihost; List <Item> xiangziItems = XiangziManager.Items; int count = 0; uiHost.shopPanel.myItemsPanel.RootPanel.Children.Clear(); List <string> visitedItem = new List <string>(); foreach (var item in RuntimeData.Instance.Items) { 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; } if (count > 5) { count = 0; } //只能存装备和残章 if (item.Type != (int)ItemType.Armor && item.Type != (int)ItemType.Canzhang && item.Type != (int)ItemType.Weapon && item.Type != (int)ItemType.Accessories) { continue; } if (count == 0) { currentPanel = new StackPanel(); currentPanel.Orientation = Orientation.Horizontal; currentPanel.Height = 58; currentPanel.Margin = new Thickness(2, 2, 2, 0); uiHost.shopPanel.myItemsPanel.RootPanel.Children.Add(currentPanel); } 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 = RuntimeData.Instance.Items.Count(p => p.Name == item.Name); visitedItem.Add(item.Name); } ItemUnit c = new ItemUnit(); c.BindItem(item); c.Margin = new Thickness(2, 2, 2, 5); c.ItemCount = itemCount; Item tmp = item; c.MouseLeftButtonUp += (s, e) => { lock (this) { int maxItemCount = 4 + RuntimeData.Instance.Round * 3; if (xiangziItems.Count + 1 > maxItemCount) { MessageBox.Show("你这个周目最多存放" + maxItemCount + "个装备"); uiHost.shopPanel.storePanel.ShowXiangzi(); //this.ShowXiangzi(); return; } xiangziItems.Add(item); XiangziManager.Items = xiangziItems; RuntimeData.Instance.Items.Remove(item); //this.ShowXiangzi(); uiHost.shopPanel.storePanel.ShowXiangzi(); e.Handled = true; } }; ToolTipService.SetToolTip(c, item.GenerateTooltip()); currentPanel.Children.Add(c); count++; } }
// <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; }
/// <summary> /// 显示箱子 /// </summary> public void ShowXiangzi() { AllSellButton.Visibility = System.Windows.Visibility.Collapsed; Type = ShopType.XIANGZI; UIHost uiHost = RuntimeData.Instance.gameEngine.uihost; uiHost.RightClickCallback = null; uiHost.shopPanel.SuggestText.Text = "单击鼠标左键取出或存入装备"; uiHost.shopPanel.myItemsPanel.Visibility = Visibility.Visible; uiHost.shopPanel.myItemsPanel.Type = ShopType.MYITEMS; List <Item> xiangziItems = XiangziManager.Items; RootPanel.Children.Clear(); this.money.Text = ""; StackPanel currentPanel = null; int count = 0; List <string> visitedItem = new List <string>(); foreach (var item in xiangziItems) { 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; } if (count > 5) { count = 0; } if (count == 0) { currentPanel = new StackPanel(); currentPanel.Orientation = Orientation.Horizontal; currentPanel.Height = 58; currentPanel.Margin = new Thickness(2, 2, 2, 0); RootPanel.Children.Add(currentPanel); } 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 = xiangziItems.Count(p => p.Name == item.Name); visitedItem.Add(item.Name); } ItemUnit c = new ItemUnit(); c.BindItem(item); c.Margin = new Thickness(2, 2, 2, 5); c.ItemCount = itemCount; Item tmp = item; c.MouseLeftButtonUp += (s, e) => { lock (this) { if (xiangziItems.Remove(item)) { RuntimeData.Instance.Items.Add(item); } XiangziManager.Items = xiangziItems; } this.ShowXiangzi(); }; ToolTipService.SetToolTip(c, item.GenerateTooltip()); currentPanel.Children.Add(c); count++; } RefreshMyItems(); this.Visibility = System.Windows.Visibility.Visible; }
//计算普通Battle获得的物品 public void calcBattleBonusItems() { bonusItems.Clear(); foreach (String roleKey in uiHost.battleFieldContainer.field.EnemyTeam) { List <Item> itemList = new List <Item>(); Role role = RoleManager.GetRole(roleKey); if (role != null) { int roleLevel = role.Level; foreach (Item item in ItemManager.Items) { if (item.IsDrop && roleLevel >= (item.level - 1) * 5) { itemList.Add(item); } } } //计算取得的物品概率,常规战斗下每个人掉落物品的概率均为10% if (itemList.Count > 0 && Tools.ProbabilityTest(0.1)) { bonusItems.Add(itemList[Tools.GetRandomInt(0, itemList.Count - 1)]); } double roleHard = 2; if (role != null) { roleHard += role.Level / 3.0; if (role.Level == 30) { roleHard = 99999; //30级的角色可以掉落所有残章 } } double canzhangProperty = 0; if (RuntimeData.Instance.GameMode == "hard") { canzhangProperty = 0.03; } else if (RuntimeData.Instance.GameMode == "crazy") //炼狱难度,掉率提高 { canzhangProperty = 0.08 + (RuntimeData.Instance.Round - 1) * 0.04; } //外功残章 if (Tools.ProbabilityTest(canzhangProperty)) { Skill s = null; int c = 0; while (c < 100) { c++; s = SkillManager.GetRandomSkill(); if (role != null && role.Level == 30 && s.Hard < 7) { continue; //高级角色不掉落低级残章 } if (role != null && role.Level >= 20 && s.Hard < 4) { continue; } if (s.Hard < roleHard) { break; } } bonusItems.Add(ItemManager.GetItem(s.Name + "残章")); } //内功残章 if (Tools.ProbabilityTest(canzhangProperty / 2.0)) { InternalSkill s = null; while (true) { s = SkillManager.GetRandomInternalSkill(); if (s.Hard < roleHard) { break; } } bonusItems.Add(ItemManager.GetItem(s.Name + "残章")); } } //显示物品 int count = 0; this.bonusItemsPanel.Children.Clear(); StackPanel currentPanel = null; for (int i = 0; i < bonusItems.Count; i++) { if (count > 6) { count = 0; } if (count == 0) { currentPanel = new StackPanel(); currentPanel.Orientation = Orientation.Horizontal; currentPanel.Height = 60; currentPanel.Margin = new Thickness(2, 2, 2, 0); this.bonusItemsPanel.Children.Add(currentPanel); } Item newItem = bonusItems[i].Clone(true); ItemUnit itemUnit = new ItemUnit(); itemUnit.BindItem(newItem); itemUnit.Margin = new Thickness(2, 2, 2, 8); currentPanel.Children.Add(itemUnit); count++; //添加物品 RuntimeData.Instance.Items.Add(newItem); } }