using Client.MirGraphics; using Client.MirScenes; using S = ServerPackets; using System.Text.RegularExpressions; namespace Client.MirObjects { public class ItemObject : MapObject { public override ObjectType Race{ get { return ObjectType.Item; } } public override bool Blocking { get { return false; } } public Size Size; public ItemObject(uint objectID) : base(objectID) { } public void Load(S.ObjectItem info) { Name = info.Name; NameColour = info.NameColour; BodyLibrary = Libraries.FloorItems; CurrentLocation = info.Location; MapLocation = info.Location; GameScene.Scene.MapControl.AddObject(this); DrawFrame = info.Image; Size = BodyLibrary.GetTrueSize(DrawFrame); DrawY = CurrentLocation.Y; } public void Load(S.ObjectGold info) { Name = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.GoldAmount), info.Gold); BodyLibrary = Libraries.FloorItems; CurrentLocation = info.Location; MapLocation = info.Location; GameScene.Scene.MapControl.AddObject(this); if (info.Gold < 100) DrawFrame = 112; else if (info.Gold < 200) DrawFrame = 113; else if (info.Gold < 500) DrawFrame = 114; else if (info.Gold < 1000) DrawFrame = 115; else DrawFrame = 116; Size = BodyLibrary.GetTrueSize(DrawFrame); DrawY = CurrentLocation.Y; } public override void Draw() { if (BodyLibrary != null) BodyLibrary.Draw(DrawFrame, DrawLocation, DrawColour); } public override void Process() { DrawLocation = new Point((CurrentLocation.X - User.Movement.X + MapControl.OffSetX) * MapControl.CellWidth, (CurrentLocation.Y - User.Movement.Y + MapControl.OffSetY) * MapControl.CellHeight); DrawLocation.Offset((MapControl.CellWidth - Size.Width) / 2, (MapControl.CellHeight - Size.Height) / 2); DrawLocation.Offset(User.OffSetMove); DrawLocation.Offset(GlobalDisplayLocationOffset); FinalDrawLocation = DrawLocation; DisplayRectangle = new Rectangle(DrawLocation, Size); } public override bool MouseOver(Point p) { return MapControl.MapLocation == CurrentLocation; // return DisplayRectangle.Contains(p); } public override void DrawName() { CreateLabel(Color.Transparent, false, true); if (NameLabel == null) return; NameLabel.Location = new Point( DisplayRectangle.X + (DisplayRectangle.Width - NameLabel.Size.Width) / 2, DisplayRectangle.Y + (DisplayRectangle.Height - NameLabel.Size.Height) / 2 - 20); NameLabel.Draw(); } public override void DrawBehindEffects(bool effectsEnabled) { } public override void DrawEffects(bool effectsEnabled) { } public void DrawName(int y) { CreateLabel(Color.FromArgb(100, 0, 24, 48), true, false); NameLabel.Location = new Point( DisplayRectangle.X + (DisplayRectangle.Width - NameLabel.Size.Width) / 2, DisplayRectangle.Y + y + (DisplayRectangle.Height - NameLabel.Size.Height) / 2 - 20); NameLabel.Draw(); } private void CreateLabel(Color backColour, bool border, bool outline) { NameLabel = null; for (int i = 0; i < LabelList.Count; i++) { if (LabelList[i].Text != Name || LabelList[i].Border != border || LabelList[i].BackColour != backColour || LabelList[i].ForeColour != NameColour || LabelList[i].OutLine != outline) continue; NameLabel = LabelList[i]; break; } if (NameLabel != null && !NameLabel.IsDisposed) return; NameLabel = new MirControls.MirLabel { AutoSize = true, BorderColour = Color.Black, BackColour = backColour, ForeColour = NameColour, OutLine = outline, Border = border, Text = Name,//Regex.Replace(Name, @"\d+$", string.Empty),//In fact, the item names passed from the server no longer have numeric suffixes, as they are redundant and affect performance. }; LabelList.Add(NameLabel); } } }