| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- 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);
- }
- }
- }
|