public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { int position = msg.Position; if (msg.GetByte() != (byte)IncomingPacketType.ContainerOpen) { return(false); } Destination = destination; Type = IncomingPacketType.ContainerOpen; Id = msg.GetByte(); ItemId = msg.GetUInt16(); Name = msg.GetString(); Capacity = msg.GetByte(); HasParent = msg.GetByte(); ItemCount = msg.GetByte(); Items = new List <Tibia.Objects.Item>(ItemCount); for (int i = 0; i < ItemCount; i++) { Objects.Item item = msg.GetItem(); item.Location = Tibia.Objects.ItemLocation.FromContainer(Id, (byte)i); Items.Add(item); } return(true); }
/// <summary> /// Gets an item in a player's equipment slot. Returns null if unsuccessful. /// </summary> /// <param name="slot">The equipment slot to get the item from.</param> /// <returns></returns> public Objects.Item GetItemInSlot(Enums.EquipmentSlots slot) { Item item = null; switch (slot) { case Enums.EquipmentSlots.Ammo: item = new Objects.Item(this.Client, this.Client.Addresses.Containers.EqAmmo, this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqAmmo), this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqAmmo + this.Client.Addresses.Item.Distances.Count), Enums.EquipmentSlots.Ammo); break; case Enums.EquipmentSlots.Torso: item = new Objects.Item(this.Client, this.Client.Addresses.Containers.EqTorso, this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqTorso), this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqTorso + this.Client.Addresses.Item.Distances.Count), Enums.EquipmentSlots.Torso); break; case Enums.EquipmentSlots.Container: item = new Objects.Item(this.Client, this.Client.Addresses.Containers.EqContainer, this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqContainer), this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqContainer + this.Client.Addresses.Item.Distances.Count), Enums.EquipmentSlots.Container); break; case Enums.EquipmentSlots.Feet: item = new Objects.Item(this.Client, this.Client.Addresses.Containers.EqFeet, this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqFeet), this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqFeet + this.Client.Addresses.Item.Distances.Count), Enums.EquipmentSlots.Feet); break; case Enums.EquipmentSlots.Head: item = new Objects.Item(this.Client, this.Client.Addresses.Containers.EqHead, this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqHead), this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqHead + this.Client.Addresses.Item.Distances.Count), Enums.EquipmentSlots.Head); break; case Enums.EquipmentSlots.LeftHand: item = new Objects.Item(this.Client, this.Client.Addresses.Containers.EqLeftHand, this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqLeftHand), this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqLeftHand + this.Client.Addresses.Item.Distances.Count), Enums.EquipmentSlots.LeftHand); break; case Enums.EquipmentSlots.Neck: item = new Objects.Item(this.Client, this.Client.Addresses.Containers.EqNeck, this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqNeck), this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqNeck + this.Client.Addresses.Item.Distances.Count), Enums.EquipmentSlots.Neck); break; case Enums.EquipmentSlots.RightHand: item = new Objects.Item(this.Client, this.Client.Addresses.Containers.EqRightHand, this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqRightHand), this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqRightHand + this.Client.Addresses.Item.Distances.Count), Enums.EquipmentSlots.RightHand); break; case Enums.EquipmentSlots.Ring: item = new Objects.Item(this.Client, this.Client.Addresses.Containers.EqRing, this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqRing), this.Client.Memory.ReadUInt16(this.Client.Addresses.Containers.EqRing + this.Client.Addresses.Item.Distances.Count), Enums.EquipmentSlots.Ring); break; default: return(null); } if (item == null || item.ID == 0) { return(null); } return(item); }
/// <summary> /// Constructor for an item in the player's inventory. /// </summary> /// <param name="item"></param> public ItemLocation(Objects.Item item) { this.WorldLocation = item.ToLocation(); this.ItemID = item.ID; this.ItemCount = item.Count; this.StackIndex = item.Slot; }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { int position = msg.Position; if (msg.GetByte() != (byte)IncomingPacketType.SafeTradeRequestAck) { return(false); } Destination = destination; Type = IncomingPacketType.SafeTradeRequestAck; Name = msg.GetString(); Count = msg.GetByte(); Items = new List <Pokemon.Objects.Item>(Count); for (int i = 0; i < Count; i++) { Objects.Item item = msg.GetItem(); Items.Add(item); } return(true); }
public Pathfinder() { for (int i = 0; i < AImap.Length; i++) { AImap[i] = new Objects.Item[10]; } }
public static bool Send(Objects.Client client, byte slot, Objects.Item item) { InventorySetSlotPacket p = new InventorySetSlotPacket(client); p.Slot = slot; p.Item = item; return(p.Send()); }
/// <summary> /// Constructor for a non-existant item in a equpiment slot. /// Use Item.ToItemLocation() for an existing item. /// </summary> /// <param name="slot">The equipment slot.</param> public ItemLocation(Enums.EquipmentSlots slot) { Objects.Item item = new Objects.Item(null) { ID = 0, Count = 0, Slot = 0, ContainerNumber = (byte)slot, }; this.WorldLocation = item.ToLocation(); this.ItemID = item.ID; this.ItemCount = item.Count; this.StackIndex = item.Slot; }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { int position = msg.Position; if (msg.GetByte() != (byte)IncomingPacketType.ContainerAddItem) return false; Destination = destination; Type = IncomingPacketType.ContainerAddItem; Container = msg.GetByte(); Item = msg.GetItem(); return true; }
private void cmbT2Copy_SelectedValueChanged(object sender, EventArgs e) { string strT2Rate = this.txtT2Rate.Text; string strComRate = this.txtComRate.Text; this.dT2Rate = Commons.ReadDouble(strT2Rate) / 100; this.dComRate = Commons.ReadDouble(strComRate) / 100; if (dT2Rate == 0 || dComRate == 0) { return; } Objects.T2Product item = (Objects.T2Product)cmbT2Copy.SelectedItem; Objects.Item target = CEVEMarketFile.lstItem.Find(obj => obj.Name == item.Name); Dictionary <string, Price> dicResult = CEVEMarketAPI.SearchPriceJson(new List <string>() { target.TypeID }); this.lblTargetSell.Text = strBaseSellPrice + string.Format("{0:C}", dicResult[target.TypeID].sell.min * item.Volume).Trim('¥'); if (item != null) { lvBase.Items.Clear(); double dPriceSumBase = 0; foreach (string strKey in item.Items.Keys) { ListViewItem li = new ListViewItem(strKey); li.UseItemStyleForSubItems = false; //材料效率减免 int nItem = (int)Math.Ceiling(item.Items[strKey] * (1 - dT2Rate)); li.SubItems.Add(string.Format("{0:N}", nItem)); lvBase.Items.Add(li); //价格查询 target = CEVEMarketFile.lstItem.Find(obj => obj.Name == strKey); dicResult = CEVEMarketAPI.SearchPriceJson(new List <string>() { target.TypeID }); dPriceSumBase += nItem * dicResult[target.TypeID].sell.min; } this.lblBuyPrice0.Text = strBuyPrice + string.Format("{0:C}", dPriceSumBase).Trim('¥'); DoCalComponentCost(); } }
private void SetPropertiesFromItem(Objects.Item _item) { if (Item != null) { if (Item.CurrentLocation != null) { OriginLocation_Id = Item.CurrentLocation.Id; OriginLocation_Name = Item.CurrentLocation.Name; EPC = Item.Epc; return; } } OriginLocation_Id = Guid.Empty; OriginLocation_Name = string.Empty; EPC = string.Empty; }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { int position = msg.Position; if (msg.GetByte() != (byte)IncomingPacketType.InventorySetSlot) return false; Destination = destination; Type = IncomingPacketType.InventorySetSlot; Slot = msg.GetByte(); Item = msg.GetItem(); return true; }
public static void Send(Objects.Client client, Objects.Location fromPosition, ushort itemId, byte fromStack, byte index) { NetworkMessage packet = new NetworkMessage(); Objects.Item item = new Objects.Item(Core.client, itemId); packet.Position = 0; packet.AddByte(0x82); packet.AddBytes(fromPosition.ToBytes()); packet.AddUInt16(itemId); packet.AddByte(fromStack); packet.AddByte(index); client.HookProxy.SendPacketToServer(packet.Data); // client.HookProxy.SendToInternal(packet.Data); }
public Network() { for (int i = 0; i < map.Length; i++) { map[i] = new Objects.Item[10]; } for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { Objects.Item item = new Objects.Item(); item.type = 0; map[i][j] = item; } } AI = new PathFinding.Pathfinder(); }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { int position = msg.Position; if (msg.GetByte() != (byte)IncomingPacketType.ContainerAddItem) { return(false); } Destination = destination; Type = IncomingPacketType.ContainerAddItem; Container = msg.GetByte(); Item = msg.GetItem(); return(true); }
public override bool ParseMessage(NetworkMessage msg, PacketDestination destination) { int position = msg.Position; if (msg.GetByte() != (byte)IncomingPacketType.InventorySetSlot) { return(false); } Destination = destination; Type = IncomingPacketType.InventorySetSlot; Slot = msg.GetByte(); Item = msg.GetItem(); return(true); }
private static void ReadItem(Excel.IXLWorksheet shSheet) { int nRow = 1; lstItem.Clear(); //第一行是表头,行号从1开始 for (nRow = 2; shSheet.Cell(nRow, 1).GetString() != String.Empty; nRow++) { Objects.Item item = new Objects.Item(); item.TypeID = shSheet.Cell(nRow, 1).GetString(); item.Name = shSheet.Cell(nRow, 2).GetString(); item.Descript = shSheet.Cell(nRow, 3).GetString(); item.Category1 = shSheet.Cell(nRow, 4).GetString(); item.Category2 = shSheet.Cell(nRow, 5).GetString(); item.Category3 = shSheet.Cell(nRow, 6).GetString(); item.Category4 = shSheet.Cell(nRow, 7).GetString(); item.Category5 = shSheet.Cell(nRow, 8).GetString(); item.Category6 = shSheet.Cell(nRow, 9).GetString(); lstItem.Add(item); } }
private void RefreshPriceCached() { lvPriceCache.Items.Clear(); foreach (Price price in CEVEMarketAPI.lstPriceCache) { if (string.IsNullOrEmpty(price.Name)) { Objects.Item target = CEVEMarketFile.lstItem.Find(obj => obj.TypeID == price.TypeId); if (target != null) { price.Name = target.Name; } } ListViewItem li = new ListViewItem(price.Name); li.UseItemStyleForSubItems = false; li.SubItems.Add(string.Format("{0:N}", price.TypeId)); li.SubItems.Add(string.Format("{0:N2}", price.sell.min)); li.SubItems.Add(string.Format("{0:N2}", price.buy.max)); lvPriceCache.Items.Add(li); } }
/// <summary> /// Attempts to get a suitable slot for a given item. If none is found, null is returned. /// </summary> /// <param name="startingContainer">The container index to start looking for a suitable slot.</param> /// <param name="fromItem">The item to use for comparisons.</param> /// <returns></returns> public Objects.ItemLocation GetFirstSuitableSlot(Objects.Item fromItem, byte startingContainer = 0) { int maxContainerValue = Constants.Inventory.MaxContainers; byte fromNumber = fromItem.ContainerNumber >= maxContainerValue ? (byte)(fromItem.ContainerNumber - maxContainerValue) : fromItem.ContainerNumber; foreach (Objects.Container container in this.GetContainers(startingContainer)) { byte toNumber = container.OrderNumber >= maxContainerValue ? (byte)(container.OrderNumber - maxContainerValue) : container.OrderNumber; if (fromNumber == toNumber) { continue; } if (fromItem.Count > 0) // check if there is an existing item with the same ID (stackable) { foreach (Objects.Item item in container.GetItems()) { if (fromItem.ID == item.ID && (fromItem.Count + item.Count <= 100 || container.ItemsAmount < container.Slots)) { return(item.ToItemLocation()); } } } // check if container has room for a non-stacking item if (!container.IsFull) { return(container.GetFirstEmptySlot()); } } return(null); }
private void Run() { while (true) { try { this.ResetEvent.Wait(); if (this.WaypointExecutedBegin != null) { this.WaypointExecutedBegin(this.CurrentWaypoint); } bool success = false, firstRun = true; Objects.Location currentSubNode = Objects.Location.Invalid; while (!this.Cancel) { this.ResetEventTilesUpdated.WaitOne(); if (this.Cancel) { break; } Objects.Player player = this.Parent.Client.Player; Objects.Location playerLoc = player.Location; if (player.Z != this.CurrentWaypoint.Location.Z) { break; } if (firstRun) { firstRun = false; } else { if (this.Parent.Client.Window.StatusBar.GetText() == Enums.StatusBar.ThereIsNoWay) { this.Parent.Client.Window.StatusBar.SetText(string.Empty); success = false; break; } } bool isOnScreen = playerLoc.IsOnScreen(this.CurrentWaypoint.Location), doBreak = false; var tilesToLocation = isOnScreen ? playerLoc.GetTilesToLocation(this.Parent.Client, this.CurrentWaypoint.Location, this.CachedTiles, this.Parent.PathFinder) .ToList <Objects.PathFinder.Node>() : new List <Objects.PathFinder.Node>(); switch (this.CurrentWaypoint.Type) { case Waypoint.Types.Walk: #region walk if (playerLoc == this.CurrentWaypoint.Location) { doBreak = true; success = true; break; } if (isOnScreen && tilesToLocation.Count == 0) { doBreak = true; success = false; break; } if (!player.IsWalking || player.GoTo != this.CurrentWaypoint.Location) { player.GoTo = this.CurrentWaypoint.Location; } #endregion break; case Waypoint.Types.Node: #region node if (playerLoc == this.CurrentWaypoint.Location) { doBreak = true; success = true; break; } if (isOnScreen && tilesToLocation.Count == 0) { doBreak = true; success = false; break; } // check if the player is already walking to a node if (player.IsWalking) { int range = this.Parent.CurrentSettings.NodeRadius; Objects.Location currentGoTo = player.GoTo; bool found = false; for (int x = -range; x <= range; x++) { for (int y = -range; y <= range; y++) { Objects.Location subNode = this.CurrentWaypoint.Location.Offset(x, y); if (currentGoTo != subNode) { continue; } // check distance to node if (isOnScreen) { var tilesToSubNode = playerLoc.GetTilesToLocation(this.Parent.Client, subNode, this.CachedTiles, this.Parent.PathFinder, true).ToArray(); if (tilesToSubNode.Length <= this.Parent.CurrentSettings.NodeSkipRange) { success = true; doBreak = true; break; } } found = true; break; } if (found) { break; } } if (found) { break; } } else if (playerLoc.DistanceTo(this.CurrentWaypoint.Location) <= this.Parent.CurrentSettings.NodeSkipRange) { success = true; doBreak = true; break; } // find new node to walk to if (isOnScreen) { Map.Tile tile = this.CachedTiles.GetTile(this.CurrentWaypoint.Location); if (tile == null) { doBreak = true; success = false; break; } Map.TileCollection nearbyTiles = this.CachedTiles.GetNearbyTileCollection(tile, this.Parent.CurrentSettings.NodeRadius); Objects.Location loc = tilesToLocation.Count != 0 ? tile.WorldLocation : Objects.Location.Invalid; List <Map.Tile> goodTiles = new List <Map.Tile>(); foreach (Map.Tile nearbyTile in nearbyTiles.GetTiles()) { bool isReachable = playerLoc.CanReachLocation(this.Parent.Client, nearbyTile.WorldLocation, this.CachedTiles, this.Parent.PathFinder); if (isReachable) { goodTiles.Add(nearbyTile); } } if (goodTiles.Count > 0) { loc = goodTiles[new Random().Next(goodTiles.Count)].WorldLocation; } if (loc.IsValid()) { player.GoTo = loc; } else { doBreak = true; success = false; break; } } else if (this.Parent.CurrentSettings.UseAlternateNodeFinder) { int range = this.Parent.CurrentSettings.NodeRadius; Random rand = new Random(); Objects.Location loc = this.CurrentWaypoint.Location; for (int x = -range; x <= range; x++) { for (int y = -range; y <= range; y++) { Objects.Location subNode = this.CurrentWaypoint.Location.Offset( rand.Next(-range, range + 1), rand.Next(-range, range + 1)); if (!this.Parent.Client.Modules.MapViewer.IsWalkable(subNode)) { continue; } loc = subNode; break; } if (loc != this.CurrentWaypoint.Location) { break; } } player.GoTo = loc; } else // use stored subnodes { Objects.Location loc = this.CurrentWaypoint.Location; if (this.CurrentWaypoint.NodeLocations.Count > 0) { int index = -1, newIndex = new Random().Next(-1, this.CurrentWaypoint.NodeLocations.Count); if (newIndex != index) { loc = this.CurrentWaypoint.NodeLocations[newIndex]; } } player.GoTo = loc; } #endregion break; case Waypoint.Types.Machete: case Waypoint.Types.Pick: case Waypoint.Types.Rope: case Waypoint.Types.Shovel: #region tools // check if we're adjacent to the waypoint if (playerLoc.IsAdjacentTo(this.CurrentWaypoint.Location)) { Objects.Item tool = null; switch (this.CurrentWaypoint.Type) { case Waypoint.Types.Machete: tool = this.Parent.Client.Inventory.GetItem(this.Parent.Client.ItemList.Tools.Machete); break; case Waypoint.Types.Pick: tool = this.Parent.Client.Inventory.GetItem(this.Parent.Client.ItemList.Tools.Pick); break; case Waypoint.Types.Rope: tool = this.Parent.Client.Inventory.GetItem(this.Parent.Client.ItemList.Tools.Rope); break; case Waypoint.Types.Shovel: tool = this.Parent.Client.Inventory.GetItem(this.Parent.Client.ItemList.Tools.Shovel); break; } if (tool == null) { doBreak = true; success = false; break; } Map.Tile tile = this.CachedTiles.GetTile(this.CurrentWaypoint.Location); if (tile == null) { success = false; doBreak = true; break; } Map.TileObject topItem = tile.GetTopUseItem(true); if (this.CurrentWaypoint.Type != Waypoint.Types.Rope) { tool.UseOnTileObject(topItem); success = true; doBreak = true; } else { if (topItem.StackIndex != 0) { // find a non-blocking adjacent tile var adjacentTiles = this.CachedTiles.GetAdjacentTileCollection(tile).GetTiles() .ToList <Map.Tile>(); Map.Tile bestTile = tile; foreach (Map.Tile t in adjacentTiles.ToArray()) { if (!t.IsWalkable()) { adjacentTiles.Remove(t); } } if (adjacentTiles.Count > 0) { bestTile = adjacentTiles[new Random().Next(adjacentTiles.Count)]; } topItem.Move(bestTile.ToItemLocation()); } else { tool.UseOnTileObject(topItem); for (int i = 0; i < 3; i++) { Thread.Sleep(100); if (player.Z != this.CurrentWaypoint.Location.Z) { doBreak = true; success = true; break; } } } } break; } else if (isOnScreen) { Map.Tile tile = this.CachedTiles.GetTile(this.CurrentWaypoint.Location); if (tile == null) { success = false; doBreak = true; break; } Map.TileCollection adjacentTiles = this.CachedTiles.GetAdjacentTileCollection(tile); Objects.Location bestLoc = Objects.Location.Invalid; int distance = int.MaxValue; foreach (Map.Tile adjTile in adjacentTiles.GetTiles()) { if (!adjTile.IsWalkable()) { continue; } var tilesToAdjTile = playerLoc.GetTilesToLocation(this.Parent.Client, adjTile.WorldLocation, this.CachedTiles, this.Parent.PathFinder, true) .ToArray <Objects.PathFinder.Node>(); if (tilesToAdjTile.Length == 0) { continue; } if (tilesToAdjTile.Length < distance) { bestLoc = adjTile.WorldLocation; distance = tilesToAdjTile.Length; } } if (bestLoc.IsValid()) { player.GoTo = bestLoc; } else { doBreak = true; success = false; break; } } else if (!player.IsWalking) { player.GoTo = this.CurrentWaypoint.Location; } #endregion break; case Waypoint.Types.Ladder: #region ladder if (player.IsWalking) { break; } if (isOnScreen) { Map.Tile tile = this.CachedTiles.GetTile(this.CurrentWaypoint.Location); if (tile == null) { doBreak = true; success = false; break; } if (playerLoc.DistanceTo(this.CurrentWaypoint.Location) < 2) { Map.TileObject topItem = tile.GetTopUseItem(false); if (topItem == null) { doBreak = true; success = false; break; } for (int i = 0; i < 3; i++) { topItem.Use(); Thread.Sleep(300); if (player.Z != this.CurrentWaypoint.Location.Z) { doBreak = true; success = true; break; } } break; } // find suitable loc to walk to int distance = int.MaxValue; Objects.Location bestLoc = Objects.Location.Invalid; foreach (Map.Tile adjTile in this.CachedTiles.GetAdjacentTileCollection(tile).GetTiles()) { if (!adjTile.IsWalkable()) { continue; } var tilesToAdjTile = playerLoc.GetTilesToLocation(this.Parent.Client, adjTile.WorldLocation, this.CachedTiles, this.Parent.PathFinder, true) .ToArray <Objects.PathFinder.Node>(); if (tilesToAdjTile.Length == 0) { continue; } if (tilesToAdjTile.Length < distance) { distance = tilesToAdjTile.Length; bestLoc = adjTile.WorldLocation; } } if (bestLoc.IsValid()) { player.GoTo = bestLoc; } else { doBreak = true; success = false; } break; } else { player.GoTo = this.CurrentWaypoint.Location; } #endregion break; } if (doBreak) { break; } } if (this.WaypointExecutedEnd != null) { this.WaypointExecutedEnd(this.CurrentWaypoint, success); } this.ResetEvent.Reset(); } catch (Exception ex) { if (this.ErrorOccurred != null) { this.ErrorOccurred(ex); } } } }
/// <summary> /// Use an item on another item. /// Not tested. /// </summary> /// <param name="onItem"></param> /// <returns></returns> public bool Use(Objects.Item onItem) { return(Packets.Outgoing.ItemUseOnPacket.Send(client, location.ToLocation(), (ushort)id, 0, onItem.Location.ToLocation(), (ushort)onItem.Id, 0)); }
private void DoCalComponentCost() { lvHigher.Items.Clear(); //材料列表 List <Objects.SearchingItem> lstOthers = new List <Objects.SearchingItem>(); //组件列表 foreach (ListViewItem Target in lvBase.Items) { Objects.Reaction reaction = this.lstT2ComponentReaction.Find(X => { return(X.Name == Target.Text); }); if (reaction != null) { //有反应配方 foreach (string strKey in reaction.Input.Keys) { Objects.SearchingItem item = lstOthers.Find(X => { return(X.Name == strKey); }); if (item != null) { //材料个数 int nVol = (int)Math.Ceiling(reaction.Input[strKey] * (1 - dComRate) * ReadDouble(Target.SubItems[1].Text)); //每流程一个的材料不可缩减 item.Volume += nVol < ReadDouble(Target.SubItems[1].Text) ? (int)ReadDouble(Target.SubItems[1].Text) : nVol; item.Size += (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text) / reaction.Output); } else { item = new Objects.SearchingItem(); item.Name = strKey; //材料个数 int nVol = (int)Math.Ceiling(reaction.Input[strKey] * (1 - dComRate) * ReadDouble(Target.SubItems[1].Text)); //每流程一个的材料不可缩减 item.Volume = nVol < ReadDouble(Target.SubItems[1].Text) ? (int)ReadDouble(Target.SubItems[1].Text) : nVol; item.Size += (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text) / reaction.Output); lstOthers.Add(item); } } } else { //无反应配方 Objects.SearchingItem item = lstOthers.Find(X => { return(X.Name == Target.Text); }); if (item != null) { item.Volume += (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text)); } else { item = new Objects.SearchingItem(); item.Name = Target.Text; item.Volume = (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text)); lstOthers.Add(item); } } } int nLineSum = 0; double dPriceSumHigher = 0; foreach (Objects.SearchingItem Result in lstOthers) { ListViewItem li = new ListViewItem(Result.Name); li.UseItemStyleForSubItems = false; li.SubItems.Add(string.Format("{0:N}", Result.Volume)); Objects.Reaction reaction = this.lstHigherReaction.Find(X => { return(X.Name == Result.Name); }); if (reaction != null) { int nLineNumHigher = (int)Math.Ceiling(Result.Volume / reaction.Output); li.SubItems.Add(string.Format("{0:N}", nLineNumHigher)); nLineSum += nLineNumHigher; } lvHigher.Items.Add(li); //价格查询 Objects.Item target = CEVEMarketFile.lstItem.Find(obj => obj.Name == Result.Name); Dictionary <string, Price> dicResult = CEVEMarketAPI.SearchPriceJson(new List <string>() { target.TypeID }); dPriceSumHigher += Result.Volume * dicResult[target.TypeID].sell.min; } this.lblBuyPrice1.Text = strBuyPrice + string.Format("{0:C}", dPriceSumHigher).Trim('¥'); this.lblLineSum1.Text = strLineSum + nLineSum.ToString(); DoCalHigherCost(); }
private void LootItems(Objects.Container lootContainer, IEnumerable <Loot> loots, Map.TileCollection tiles) { Random rand = new Random(); if (!this.Parent.StopwatchFoodEater.IsRunning) { this.Parent.StopwatchFoodEater.Start(); } int index = lootContainer.ItemsAmount - 1, retryCount = 0; while (index >= 0 && !this.Cancel) { // sanity checks if (lootContainer.ItemsAmount == 0 || !lootContainer.IsOpen) { break; } if (retryCount >= 3) { retryCount = 0; index--; continue; } // get item Objects.Item item = lootContainer.GetItemInSlot((byte)index); if (item == null) { index--; retryCount = 0; continue; } // check if it's food, eat it if so if (this.Parent.CurrentSettings.EatFood && this.Parent.StopwatchFoodEater.Elapsed.TotalSeconds > 20 && this.Parent.Client.ItemList.Food.All.Contains(item.ID)) { if (item.Count <= 1) { item.Use(); } else { for (int i = 0; i < Math.Min(item.Count, (ushort)3); i++) { item.Use(); Thread.Sleep(rand.Next(200, 325)); } } this.Parent.StopwatchFoodEater.Restart(); Thread.Sleep(rand.Next(200, 350)); index--; continue; } // check if we want to loot this item Loot loot = null; foreach (Loot l in loots) { if (l.ID == item.ID) { loot = l; break; } } if (loot == null) { index--; continue; } // loot this item bool successful = false; switch (loot.Destination) { case Loot.Destinations.Ground: Objects.Map.Tile playerTile = tiles.GetTile(count: this.Parent.Client.Player.ID); if (playerTile == null) { break; } List <Map.Tile> adjacentTiles = tiles.GetAdjacentTileCollection(playerTile).GetTiles().ToList(); adjacentTiles.Shuffle(); foreach (Objects.Map.Tile tile in adjacentTiles) { if (!tile.IsWalkable()) { continue; } item.Move(new Objects.ItemLocation(tile.WorldLocation)); successful = true; break; } break; case Loot.Destinations.EmptyContainer: Objects.ItemLocation toItem = this.Parent.Client.Inventory.GetFirstSuitableSlot(item, loot.Index); if (toItem == null) { break; } item.Move(toItem); successful = true; break; } // if successful, check if it's looted // if it wasn't looted, try again if (successful) { if (!item.WaitForInteraction(800)) { retryCount++; continue; } if (this.Parent.ItemLooted != null) { this.Parent.ItemLooted(item); } if (!this.Parent.CurrentSettings.FastLooting) { Thread.Sleep(rand.Next(400, 700)); } } retryCount = 0; index--; } if (this.Parent.CurrentSettings.OpenContainers && !this.Cancel && lootContainer.IsOpen && lootContainer.ItemsAmount > 0) { bool found = false; foreach (Objects.Item item in lootContainer.GetItems().Reverse()) { if (item.HasFlag(Enums.ObjectPropertiesFlags.IsContainer)) { for (int i = 0; i < 3; i++) { item.Use(); if (item.WaitForInteraction(800)) { break; } } found = true; break; } } if (found) { this.LootItems(lootContainer, loots, this.CachedTiles); } } }
private void Run() { while (true) { try { this.ResetEvent.Wait(); if (this.TargetExecutedBegin != null) { this.TargetExecutedBegin(this.CurrentTarget); } Objects.Client client = this.Parent.Client; Objects.Creature oldCreature = null; while (!this.Cancel) { this.ResetEventCacheUpdated.WaitOne(); if (this.Cancel) { break; } // get best setting Target.Setting setting = this.CurrentTarget.GetBestSetting(this.CachedCreatures, this.CachedPlayers, this.CachedTiles, true); if (setting == null) { break; } // check if we should revert to older creature if sticky is on // or if new creature is in no better position if (oldCreature != null && oldCreature != this.CurrentTarget.Creature && oldCreature.IsVisible && client.Player.Location.IsOnScreen(oldCreature.Location)) { if (this.Parent.CurrentSettings.StickToCreature) { this.CurrentTarget.Creature = oldCreature; } else { int oldDist = (int)client.Player.Location.DistanceTo(oldCreature.Location), newDist = this.CurrentTarget.Creature != null ? (int)client.Player.Location.DistanceTo(this.CurrentTarget.Creature.Location) : 100; if (oldDist < newDist + 2) { this.CurrentTarget.Creature = oldCreature; } } } oldCreature = this.CurrentTarget.Creature; Objects.Location playerLoc = client.Player.Location, targetLoc = this.CurrentTarget.Creature.Location; #region targeting checks and whatnot // check if the creature is dead if (this.CurrentTarget.Creature.IsDead) { break; } // check if creature is about to become a corpse if (this.CurrentTarget.Creature.IsVisible && this.CurrentTarget.Creature.HealthPercent == 0) { continue; } // check if creature is still on screen, stop attacking and looping if so if (!playerLoc.IsOnScreen(targetLoc)) { this.CancelAttack(); break; } // check if creature if reachable and/or shootable // stop attacking and break if settings says they must be if ((setting.MustBeReachable && !this.CurrentTarget.Creature.IsReachable(this.CachedTiles, this.Parent.PathFinder)) || (setting.MustBeShootable && !this.CurrentTarget.Creature.IsShootable(this.CachedTiles))) { this.CancelAttack(); break; } // check if player is attacking the wrong target if (client.Player.Target != this.CurrentTarget.Creature.ID) { this.CurrentTarget.Creature.Attack(); Thread.Sleep(100); } // set fight stance+mode and move accordingly Map.Tile playerTile = this.CachedTiles.GetTile(count: client.Player.ID), creatureTile = this.CachedTiles.GetTile(count: this.CurrentTarget.Creature.ID); if (playerTile == null || creatureTile == null) { this.CancelAttack(); break; } switch (setting.FightStance) { case Enums.FightStance.Stand: if (client.Player.FightStance != Enums.FightStance.Stand) { client.Player.FightStance = Enums.FightStance.Stand; } break; case Enums.FightStance.Follow: if (client.Player.FightStance != Enums.FightStance.Follow) { client.Player.FightStance = Enums.FightStance.Follow; } break; case Enums.FightStance.FollowDiagonalOnly: case Enums.FightStance.DistanceFollow: case Enums.FightStance.DistanceWait: case Enums.FightStance.FollowStrike: if (client.Player.FightStance != Enums.FightStance.Stand) { client.Player.FightStance = Enums.FightStance.Stand; } if (client.Player.IsWalking) { break; } Objects.Location bestLoc = this.CurrentTarget.GetBestLocation(setting, this.CachedTiles, this.CachedCreatures); if (bestLoc.IsValid() && client.Player.GoTo != bestLoc) { client.Player.GoTo = bestLoc; } break; } // shoot rune or spell if (client.Player.HealthPercent >= this.Parent.CurrentSettings.MinimumHealthToShoot && this.CurrentTarget.Creature.HealthPercent > 0) { ushort runeID = 0; if ((runeID = setting.GetRuneID()) != 0) { Objects.Item rune = client.Inventory.GetItem(runeID); if (rune != null) { if (!this.StopwatchExhaust.IsRunning || this.StopwatchExhaust.ElapsedMilliseconds >= this.Parent.CurrentSettings.Exhaust) { if (setting.RuneIsAoE()) // todo: test this { Map.Tile aoeTile = this.Parent.GetAreaEffectTile(setting.GetAreaEffect(), this.CachedTiles, this.CurrentTarget.Creature); if (aoeTile != null) { rune.UseOnTile(aoeTile); this.StopwatchExhaust.Restart(); } } else if (this.CurrentTarget.Creature.IsShootable(this.CachedTiles)) { rune.UseOnBattleList(this.CurrentTarget.Creature); this.StopwatchExhaust.Restart(); } } } } else if (!string.IsNullOrEmpty(setting.Spell)) { // todo: add aoe spells if (playerLoc.IsAdjacentNonDiagonalOnly(targetLoc)) { Enums.Direction direction = Enums.Direction.Down; int diffX = playerLoc.X - targetLoc.X, diffY = playerLoc.Y - targetLoc.Y; if (diffX > 0) { direction = Enums.Direction.Left; } else if (diffX < 0) { direction = Enums.Direction.Right; } else if (diffY > 0) { direction = Enums.Direction.Up; } else if (diffY < 0) { direction = Enums.Direction.Down; } if (client.Player.Direction != direction) { client.Packets.Turn(direction); for (int i = 0; i < 6; i++) { Thread.Sleep(50); if ((Enums.Direction)client.Player.Direction == direction) { break; } } } if (client.Player.Direction == direction && (!this.StopwatchExhaust.IsRunning || this.StopwatchExhaust.ElapsedMilliseconds > this.Parent.CurrentSettings.Exhaust)) { client.Packets.Say(setting.Spell); this.StopwatchExhaust.Restart(); } } } } #endregion } if (this.TargetExecutedEnd != null) { this.TargetExecutedEnd(this.CurrentTarget); } this.ResetEvent.Reset(); this.Cancel = false; } catch (Exception ex) { if (this.ErrorOccurred != null) { this.ErrorOccurred(ex); } } } }
private void DoCalLowerCost() { lvMoon.Items.Clear(); //材料列表 List <Objects.SearchingItem> lstOthers = new List <Objects.SearchingItem>(); Objects.SearchingItem FuelC = new Objects.SearchingItem(); FuelC.Name = "氮燃料块"; lstOthers.Add(FuelC); Objects.SearchingItem FuelA = new Objects.SearchingItem(); FuelA.Name = "氦燃料块"; lstOthers.Add(FuelA); Objects.SearchingItem FuelG = new Objects.SearchingItem(); FuelG.Name = "氧燃料块"; lstOthers.Add(FuelG); Objects.SearchingItem FuelM = new Objects.SearchingItem(); FuelM.Name = "氢燃料块"; lstOthers.Add(FuelM); //组件列表 foreach (ListViewItem Target in lvLower.Items) { Objects.Reaction reaction = this.lstLowerReaction.Find(X => { return(X.Name == Target.Text); }); if (reaction != null) { //有反应配方 foreach (string strKey in reaction.Input.Keys) { Objects.SearchingItem item = lstOthers.Find(X => { return(X.Name == strKey); }); if (item != null) { //item.Volume += (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text) / reaction.Output * reaction.Input[strKey]); item.Volume += (int)(ReadDouble(Target.SubItems[2].Text) * reaction.Input[strKey]); } else { item = new Objects.SearchingItem(); item.Name = strKey; //item.Volume = (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text) / reaction.Output * reaction.Input[strKey]); item.Volume += (int)(ReadDouble(Target.SubItems[2].Text) * reaction.Input[strKey]); lstOthers.Add(item); } } } else { //无反应配方 Objects.SearchingItem item = lstOthers.Find(X => { return(X.Name == Target.Text); }); if (item != null) { item.Volume += (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text)); } else { item = new Objects.SearchingItem(); item.Name = Target.Text; item.Volume = (int)Math.Ceiling(ReadDouble(Target.SubItems[1].Text)); lstOthers.Add(item); } } } double dPriceSumMoon = 0; foreach (Objects.SearchingItem Result in lstOthers) { ListViewItem li = new ListViewItem(Result.Name); li.UseItemStyleForSubItems = false; li.SubItems.Add(string.Format("{0:N}", Result.Volume)); lvMoon.Items.Add(li); //价格查询 Objects.Item target = CEVEMarketFile.lstItem.Find(obj => obj.Name == Result.Name); Dictionary <string, Price> dicResult = CEVEMarketAPI.SearchPriceJson(new List <string>() { target.TypeID }); dPriceSumMoon += Result.Volume * dicResult[target.TypeID].sell.min; } this.lblBuyPrice3.Text = strBuyPrice + string.Format("{0:C}", dPriceSumMoon).Trim('¥'); }
/// <summary> /// Attempts to make one or more runes. /// </summary> /// <param name="spellName">The name of the spell.</param> /// <param name="runeMana">Minimum amount of mana required to make a rune.</param> /// <param name="doMakeUntilMana">Maximum mana to stop recursively making runes.</param> /// <param name="makeUntilMana">Whether to recursively make runes.</param> public void MakeRune(string spellName, ushort runeMana, bool doMakeUntilMana = false, int makeUntilMana = 0) { // check if player is connected if (!this.Connected) { return; } // check if the player has enough mana for the rune if (this.Mana < runeMana) { return; } // check if the player carries any blank runes Item blankRune = this.Client.Inventory.GetItem(this.Client.ItemList.Runes.Blank); if (blankRune == null) { return; } // check if there is an item in the right hand and move the item Item itemRightHand = this.Client.Inventory.GetItemInSlot(Enums.EquipmentSlots.RightHand); if (itemRightHand != null) { Objects.ItemLocation targetItem = this.Client.Inventory.GetFirstSuitableSlot(itemRightHand); if (targetItem == null) { return; } itemRightHand.Move(targetItem); for (int i = 0; i < 5; i++) { if (itemRightHand.WaitForInteraction(1000)) { break; } targetItem = this.Client.Inventory.GetFirstSuitableSlot(itemRightHand); if (targetItem == null) { return; } itemRightHand.Move(targetItem); } Thread.Sleep(500); } while (true) // initiate loop in case of recursive runemaking { // find a blank rune and move it to right hand blankRune = this.Client.Inventory.GetItem(this.Client.ItemList.Runes.Blank); if (blankRune == null) { break; } for (int i = 0; i < 5; i++) { blankRune = this.Client.Inventory.GetItem(this.Client.ItemList.Runes.Blank); if (blankRune == null) { break; } Objects.Item temp = this.Client.Inventory.GetItemInSlot(Enums.EquipmentSlots.RightHand); if (temp != null) { break; } blankRune.Move(new ItemLocation(Enums.EquipmentSlots.RightHand)); if (blankRune.WaitForInteraction(1000)) { break; } } Thread.Sleep(1000); // say the spell and wait for the rune to transform for (int i = 0; i < 5; i++) { Item tempItem = this.Client.Inventory.GetItemInSlot(Enums.EquipmentSlots.RightHand); if (tempItem == null) { break; } if (tempItem.ID != this.Client.ItemList.Runes.Blank) { break; } this.Client.Packets.Say(spellName); if (tempItem.WaitForInteraction(1000)) { break; } } Thread.Sleep(1000); // move the made rune back to its container // if the source container is full, try to find a free slot elsewhere Item transformedRune = this.Client.Inventory.GetItemInSlot(Enums.EquipmentSlots.RightHand); if (transformedRune == null) { break; } Objects.ItemLocation toItem = blankRune.GetParent() != null?blankRune.GetParent().GetFirstEmptySlot() : null; if (toItem == null) { toItem = this.Client.Inventory.GetFirstSuitableSlot(transformedRune); } if (toItem == null) { break; } for (int i = 0; i < 5; i++) { transformedRune = this.Client.Inventory.GetItemInSlot(Enums.EquipmentSlots.RightHand); if (transformedRune == null) { break; } transformedRune.Move(toItem); if (transformedRune.WaitForInteraction(1000)) { break; } } Thread.Sleep(1000); // check if the player should make more runes if (doMakeUntilMana && this.Client.Player.Mana > makeUntilMana) { continue; } break; } // put the item the player carried in his right hand back to its slot if (itemRightHand == null) { return; } Item oldRHandItem = itemRightHand; while (this.Client.Inventory.GetItemInSlot(Enums.EquipmentSlots.RightHand) == null) { itemRightHand = this.Client.Inventory.GetItem(oldRHandItem.ID); if (itemRightHand == null) { break; } itemRightHand.Move(new ItemLocation(Enums.EquipmentSlots.RightHand)); if (itemRightHand.WaitForInteraction(1000)) { break; } } }
/// <summary> /// Handles checking the player's values against the loaded criterias, and executes an action if a criteria is met. /// Run this method on a seperate thread. /// </summary> private void HealerLogic() { try { if (this.StatusChanged != null) { this.StatusChanged(this.IsRunning); } while (this.IsRunning) { Thread.Sleep(this.CheckInterval); if (!this.Client.Player.Connected) { continue; } ushort health = this.Client.Player.Health, mana = this.Client.Player.Mana; foreach (Criteria c in this.GetCriterias()) { if (c.Mana <= mana) { switch (c.Action) { case ActionType.ManaFluid: if (this.Client.Player.IsWalking) { break; } Objects.Item manafluid = this.Client.Inventory.GetItem(this.Client.ItemList.Runes.Vial, 7); if (manafluid == null) { break; } manafluid.UseOnSelf(); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); break; case ActionType.ManaPotion: this.Client.Packets.HotkeyUseItemOnSelf(this.Client.ItemList.Runes.ManaPotion); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); break; case ActionType.StrongManaPotion: this.Client.Packets.HotkeyUseItemOnSelf(this.Client.ItemList.Runes.StrongManaPotion); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); break; case ActionType.GreatManaPotion: this.Client.Packets.HotkeyUseItemOnSelf(this.Client.ItemList.Runes.GreatManaPotion); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); break; case ActionType.GreatSpiritPotion: this.Client.Packets.HotkeyUseItemOnSelf(this.Client.ItemList.Runes.GreatSpiritPotion); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); break; } } if (health < c.Health && mana >= c.Mana) { Objects.Item item = null; switch (c.Action) { case ActionType.UltimateHealingRune: item = this.Client.Inventory.GetItem(this.Client.ItemList.Runes.UltimateHealing); if (item != null) { item.UseOnSelf(); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); } break; case ActionType.IntenseHealingRune: item = this.Client.Inventory.GetItem(this.Client.ItemList.Runes.IntenseHealing); if (item != null) { item.UseOnSelf(); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); } break; case ActionType.HealthPotion: this.Client.Packets.HotkeyUseItemOnSelf(this.Client.ItemList.Runes.HealthPotion); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); break; case ActionType.StrongHealthPotion: this.Client.Packets.HotkeyUseItemOnSelf(this.Client.ItemList.Runes.StrongHealthPotion); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); break; case ActionType.GreatHealthPotion: this.Client.Packets.HotkeyUseItemOnSelf(this.Client.ItemList.Runes.GreatHealthPotion); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); break; case ActionType.UltimateHealthPotion: this.Client.Packets.HotkeyUseItemOnSelf(this.Client.ItemList.Runes.UltimateHealthPotion); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); break; case ActionType.GreatSpiritPotion: this.Client.Packets.HotkeyUseItemOnSelf(this.Client.ItemList.Runes.GreatSpiritPotion); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); break; case ActionType.Say: if (string.IsNullOrEmpty(c.Spell)) { break; } this.Client.Packets.Say(c.Spell); Thread.Sleep(rand.Next(Math.Min(this.SleepMin, this.SleepMax), Math.Max(this.SleepMin, this.SleepMax))); break; } break; } } } } catch { } finally { this.IsRunning = false; if (this.StatusChanged != null) { this.StatusChanged(this.IsRunning); } } }
//https://www.ceve-market.org/api/ //https://www.ceve-market.org/api/market/region/{星域ID}/system/{星系ID}/type/{物品ID}.{格式} //https://www.ceve-market.org/api/market/type/34.xml //https://www.ceve-market.org/api/market/region/10000002/type/34.json //https://www.ceve-market.org/api/market //https://www.ceve-market.org/api/marketstat //https://www.ceve-market.org/api/evemon //https://www.ceve-market.org/api/quicklook //https://www.ceve-market.org/api/searchname //伏尔戈 10000002 吉他 30000142 格式 必须为 xml 或 json (全部小写) //https://www.ceve-market.org/api/market/region/10000002/system/30000142/type/{物品ID}.json public static void SearchPrice(List <SearchingItem> lstItem) { lstResult.Clear(); foreach (SearchingItem Item in lstItem) { if (!string.IsNullOrEmpty(Item.ItemID)) { continue; } Objects.Item objItem = CEVEMarketFile.lstItem.Find(X => (X.Name == Item.Name)); if (objItem == null) { MessageBox.Show("请先导入物品ID"); return; } Item.ItemID = objItem.TypeID; } foreach (SearchingItem Item in lstItem) { //请求 string strReqPath = string.Format("https://www.ceve-market.org/api/market/region/10000002/system/30000142/type/{0}.xml", Item.ItemID); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strReqPath); request.Method = "GET"; using (WebResponse response = request.GetResponse()) { Stream stream = response.GetResponseStream(); StreamReader sr = new StreamReader(stream); string strXML = sr.ReadToEnd(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(strXML); XmlNode rootNode = xmlDoc.SelectSingleNode("cevemarket"); string strBuy = xmlDoc.SelectSingleNode("cevemarket/buy/max").InnerText; string strSell = xmlDoc.SelectSingleNode("cevemarket/sell/min").InnerText; string strBuyVolume = xmlDoc.SelectSingleNode("cevemarket/buy/volume").InnerText; string strSellVolume = xmlDoc.SelectSingleNode("cevemarket/sell/volume").InnerText; SearchingResult PriceStat = new SearchingResult(); PriceStat.Name = Item.Name; PriceStat.Volume = Item.Volume.ToString(); PriceStat.Buy1 = strBuy; PriceStat.Buy1Volume = strBuyVolume; PriceStat.Sell1 = strSell; PriceStat.Sell1Volume = strSellVolume; PriceStat.BasePrice = Item.BasePrice; PriceStat.Size = Item.Size; lstResult.Add(PriceStat); Price Cached = lstPriceCache.Find(X => X.TypeId == Item.ItemID); if (Cached != null) { Cached.buy.max = Commons.ReadDouble(strBuy); Cached.buy.volume = Commons.ReadInt(strBuyVolume); Cached.sell.min = Commons.ReadDouble(strSell); Cached.buy.volume = Commons.ReadInt(strSellVolume); } else { Cached = new Price(); Cached.TypeId = Item.ItemID; Cached.Name = Item.Name; PriceInfo buy = new PriceInfo(); buy.max = Commons.ReadDouble(strBuy); buy.volume = Commons.ReadInt(strBuyVolume); Cached.buy = buy; PriceInfo sell = new PriceInfo(); sell.min = Commons.ReadDouble(strSell); sell.volume = Commons.ReadInt(strSellVolume); Cached.sell = sell; lstPriceCache.Add(Cached); } } } }