public virtual void Hide() { ThicknessAnimation thicknessAnimation = new ThicknessAnimation(new Thickness(0, -700, 0, 700), TimeSpan.FromSeconds(0.8f)); thicknessAnimation.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseOut, }; thicknessAnimation.Completed += EndHide; ContainerContent.BeginAnimation(Rectangle.MarginProperty, thicknessAnimation); }
public void TestContainerContent() { var cont = new Container(Serial.LastItem + 1); cont.AddItem(new Item(Serial.LastItem + 2)); var m = new Mobile(0x1); m.DefaultMobileInit(); var data = new ContainerContent(m, cont).Compile(); Span <byte> expectedData = stackalloc byte[5 + cont.Items.Count * 19]; // Max Size var pos = 0; expectedData.Write(ref pos, (byte)0x3C); // Packet ID pos += 4; // Length + Count ushort count = 0; var itemCount = cont.Items.Count; for (var i = 0; i < itemCount; i++) { var child = cont.Items[i]; if (child.Deleted || !m.CanSee(child)) { continue; } expectedData.Write(ref pos, child.Serial); expectedData.Write(ref pos, (ushort)child.ItemID); #if NO_LOCAL_INIT expectedData.Write(ref pos, (byte)0); // ItemID offset #else pos++; #endif expectedData.Write(ref pos, (ushort)Math.Min(child.Amount, ushort.MaxValue)); expectedData.Write(ref pos, (ushort)child.X); expectedData.Write(ref pos, (ushort)child.Y); expectedData.Write(ref pos, cont.Serial); expectedData.Write(ref pos, (ushort)(child.QuestItem ? Item.QuestItemHue : child.Hue)); count++; } expectedData.Slice(1, 2).Write((ushort)pos); // Length expectedData.Slice(3, 2).Write(count); // Count expectedData = expectedData.Slice(0, pos); AssertThat.Equal(data, expectedData); }
public void TestContainerContent() { var cont = new Container(World.NewItem); cont.AddItem(new Item(World.NewItem)); var m = new Mobile(0x1); m.DefaultMobileInit(); var expected = new ContainerContent(m, cont).Compile(); using var ns = PacketTestUtilities.CreateTestNetState(); ns.SendContainerContent(m, cont); var result = ns.SendPipe.Reader.TryRead(); AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); }
public virtual void Show(UserControl modelContent) { if (this.modelContent != null) { ContainerContent.Children.Remove(modelContent); } ContainerContent.Children.Add(modelContent); this.modelContent = modelContent; Visibility = Visibility.Visible; ThicknessAnimation thicknessAnimation = new ThicknessAnimation(new Thickness(0, 0, 0, 0), TimeSpan.FromSeconds(0.8f)); thicknessAnimation.EasingFunction = new ElasticEase() { Oscillations = 1, }; ContainerContent.BeginAnimation(Rectangle.MarginProperty, thicknessAnimation); }
public void TestContainerContent() { var cont = new Container(World.NewItem); cont.AddItem(new Item(World.NewItem)); cont.Map = Map.Felucca; var m = new Mobile((Serial)0x1); m.DefaultMobileInit(); m.AccessLevel = AccessLevel.Administrator; m.Map = Map.Felucca; var expected = new ContainerContent(m, cont).Compile(); var ns = PacketTestUtilities.CreateTestNetState(); ns.SendContainerContent(m, cont); var result = ns.SendPipe.Reader.TryRead(); AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); }
/// <summary> /// Analyzes packet and saves it, if its part of the loot. /// </summary> /// <param name="packet">Packet</param> public void AnalyzePacket(Packet packet) { if (packet is MobileIncoming) { MobileIncoming p = (MobileIncoming)packet; if (!m_Mobiles.ContainsKey(p.Serial)) { Mobile m = new Mobile(p.Serial); m.Body = p.ModelId; m.Hue = (int)p.Hue; m.Notoriety = (Notoriety)p.Notoriety; m.Female = (p.Flag & 0x2) == 1 ? true : false; m.Blessed = (p.Flag & 0x8) == 1 ? true : false; m_Mobiles.Add(p.Serial, m); } else { Mobile m = m_Mobiles[p.Serial]; m.Body = p.ModelId; m.Hue = (int)p.Hue; m.Notoriety = (Notoriety)p.Notoriety; m.Female = (p.Flag & 0x2) == 1 ? true : false; m.Blessed = (p.Flag & 0x8) == 1 ? true : false; } } /*else if ( packet is MobileStat ) * { * MobileStat p = (MobileStat) packet; * * if ( m_Mobiles.ContainsKey( p.Serial ) ) * { * Mobile m = m_Mobiles[ p.Serial ]; * * if ( m.Name == null ) * m.Name = p.Name; * } * }*/ else if (packet is DeathAnimation) { DeathAnimation p = (DeathAnimation)packet; if (m_Mobiles.ContainsKey(p.Serial)) { Mobile m = m_Mobiles[p.Serial]; if (m.Corpse == 0) { m.Corpse = p.Corpse; if (!m_Corpses.ContainsKey(p.Corpse)) { m_Corpses.Add(p.Corpse, m); } } } } else if (packet is ContainerContentUpdate) { ContainerContentUpdate p = (ContainerContentUpdate)packet; if (m_Corpses.ContainsKey(p.ContSerial)) { Mobile m = m_Corpses[p.ContSerial]; if (m.CorpseContainer == 0) { m.CorpseContainer = p.Serial; m_Filter.AddMobile(m.Name); if (!m_CorpseContainers.ContainsKey(p.Serial)) { m_CorpseContainers.Add(p.Serial, m); } } } } else if (packet is ContainerContent) { ContainerContent p = (ContainerContent)packet; foreach (ContainerContent.ContainedItem i in p.Items) { if (m_CorpseContainers.ContainsKey(i.ContSerial)) { Mobile m = m_CorpseContainers[i.ContSerial]; if (!m.Loot.ContainsKey(i.Serial)) { Item item; if (!m_Items.ContainsKey(i.Serial)) { item = new Item(i.Serial); m_Items.Add(i.Serial, item); } else { item = m_Items[i.Serial]; } item.ItemID = i.ItemId; item.Hue = i.Hue; item.Amount = i.Amount; m.Loot.Add(i.Serial, item); } } } } else if (packet is ObjectProperties) { ObjectProperties p = (ObjectProperties)packet; if (m_Corpses.ContainsKey(p.Serial)) { Mobile m = m_Corpses[p.Serial]; if (m.CorpseName == null && p.Properties.Length > 0) { ObjectProperties.Property prop = p.Properties[0]; m.CorpseName = LocalizedList.Construct(prop.Number, prop.Arguments); } } else if (m_Mobiles.ContainsKey(p.Serial)) { Mobile m = m_Mobiles[p.Serial]; if (p.Properties.Length > 0) { m.Name = LocalizedList.Construct(p.Properties[0].Number, p.Properties[0].Arguments); } } else { Item item; if (!m_Items.ContainsKey(p.Serial)) { item = new Item(p.Serial); m_Items.Add(p.Serial, item); } else { item = m_Items[p.Serial]; } if (item.Name != null) { return; } for (int i = 0; i < p.Properties.Length; i++) { ObjectProperties.Property prop = p.Properties[i]; item.ParseProperty(i, prop.Number, prop.Arguments); } } } }
/// <summary> /// Analyzes packet and saves it, if it is related to vendors. /// </summary> /// <param name="packet">Packet.</param> public void AnalyzePacket(Packet packet) { if (packet is MobileIncoming) { MobileIncoming p = (MobileIncoming)packet; if (!m_Vendors.ContainsKey(p.Serial) && p.Notoriety == Notoriety.Invulnerable) { Vendor m = new Vendor(p.Serial); m.Body = p.ModelId; m.Hue = (int)p.Hue; m.Notoriety = (Notoriety)p.Notoriety; m.Female = (p.Flag & 0x2) == 1 ? true : false; m.Blessed = (p.Flag & 0x8) == 1 ? true : false; foreach (MobileIncoming.EquipInfo i in p.Equipment) { Item item = new Item(i.Serial); item.ItemID = i.ItemId; item.Layer = (Layer)i.Layer; item.Hue = i.Hue; m.Items.Add(item); m_Items.Add(i.Serial, item); if (item.Layer == Layer.ShopBuy) { m_Shops.Add(item.Serial, m); } } m_Vendors.Add(p.Serial, m); } } else if (packet is ContainerContent) { ContainerContent p = (ContainerContent)packet; foreach (ContainerContent.ContainedItem i in p.Items) { if (m_Shops.ContainsKey(i.ContSerial)) { Vendor m = m_Shops[i.ContSerial]; if (!m.Shop.ContainsKey(i.Serial)) { VendorItem item = new VendorItem(i.Serial); if (!m_Items.ContainsKey(i.Serial)) { m_Items.Add(i.Serial, item); } item.ItemID = i.ItemId; item.Hue = i.Hue; item.Amount = i.Amount; m.Shop.Add(i.Serial, item); } } } } else if (packet is BuyInfo) { BuyInfo p = (BuyInfo)packet; if (m_Shops.ContainsKey(p.VendorSerial)) { m_Prices = new int[p.ItemCount]; m_Counter = 0; for (int i = 0; i < p.ItemCount; i++) { m_Prices[i] = p.List[i].Price; } } } else if (packet is ObjectProperties) { ObjectProperties p = (ObjectProperties)packet; if (m_Items.ContainsKey(p.Serial)) { Item item = m_Items[p.Serial]; if (item.Name != null) { return; } for (int i = 0; i < p.Properties.Length; i++) { ObjectProperties.Property prop = p.Properties[i]; item.ParseProperty(i, prop.Number, prop.Arguments); } if (item is VendorItem && m_Prices != null && m_Counter < m_Prices.Length) { ((VendorItem)item).SellPrice = m_Prices[m_Counter++]; } } else if (m_Vendors.ContainsKey(p.Serial)) { Mobile m = m_Vendors[p.Serial]; if (m.Name == null && p.Properties.Length > 0) { m.Name = LocalizedList.Construct(p.Properties[0].Number, p.Properties[0].Arguments); } } } }