Example #1
0
 public MapObjectDeferred(Texture2D texture, AMapObject parent)
     : base(new Position3D(parent.Position.X, parent.Position.Y, (int)parent.Z))
 {
     m_texture = texture;
     Vertices = getVerticesFromBuffer();
     SortZ = parent.SortZ;
     SortThreshold = parent.SortThreshold;
     SortTiebreaker = parent.SortTiebreaker;
 }
Example #2
0
        void onInteractButton(InputEventMouse e)
        {
            AMapObject overObject = (e.EventType == MouseEvent.DragBegin) ? m_dragObject : IsometricRenderer.MouseOverObject;
            Vector2 overObjectOffset = (e.EventType == MouseEvent.DragBegin) ? m_dragOffset : IsometricRenderer.MouseOverObjectPoint;

            if (e.EventType == MouseEvent.Down)
            {
                m_dragObject = overObject;
                m_dragOffset = overObjectOffset;
            }

            if (overObject == null)
                return;

            if (m_Model.Cursor.IsTargeting && e.EventType == MouseEvent.Click)
            {
                // Special case: targeting
                // handled by cursor class.
            }
            else
            {
                // standard interaction actions ...
                if (overObject is MapObjectGround)
                {
                    // we can't interact with ground tiles.
                }
                else if (overObject is MapObjectStatic)
                {
                    // clicking a should pop up the name of the static.
                    if (e.EventType == MouseEvent.Click)
                    {

                    }
                }
                else if (overObject is MapObjectItem)
                {
                    Item item = (Item)overObject.OwnerEntity;
                    // single click = tool tip
                    // double click = use / open
                    // click and drag = pick up
                    switch (e.EventType)
                    {
                        case MouseEvent.Click:
                            // tool tip
                            UltimaInteraction.SingleClick(item);
                            break;
                        case MouseEvent.DoubleClick:
                            UltimaInteraction.DoubleClick(item);
                            break;
                        case MouseEvent.DragBegin:
                            UltimaInteraction.PickupItem(item, new Point((int)overObjectOffset.X, (int)overObjectOffset.Y));
                            break;
                    }
                }
                else if (overObject is MapObjectMobile)
                {
                    Mobile entity = (Mobile)overObject.OwnerEntity;
                    // single click = tool tip; if npc = request context sensitive menu
                    // double click = set last target; if is human open paper doll; if ridable ride; if self and riding, dismount;
                    // click and drag = pull off status bar
                    switch (e.EventType)
                    {
                        case MouseEvent.Click:
                            // tool tip
                            UltimaInteraction.SingleClick(entity);
                            if (UltimaVars.EngineVars.WarMode)
                                m_Model.Client.Send(new AttackRequestPacket(entity.Serial));
                            else
                                m_Model.Client.Send(new RequestContextMenuPacket(entity.Serial));
                            break;
                        case MouseEvent.DoubleClick:
                            UltimaInteraction.DoubleClick(entity);
                            UltimaVars.EngineVars.LastTarget = entity.Serial;
                            break;
                        case MouseEvent.DragBegin:
                            // pull off status bar
                            break;
                    }
                }
                else if (overObject is MapObjectCorpse)
                {
                    Corpse entity = (Corpse)overObject.OwnerEntity;
                    // click and drag = nothing
                    // single click = tool tip
                    // double click = open loot window.
                }
                else if (overObject is MapObjectText)
                {
                    // clicking on text should somehow indicate the person speaking.
                }
                else
                {
                    throw new Exception("Unknown object type in onInteractButtonDown()");
                }
            }

            e.Handled = true;
        }
Example #3
0
 void createHoverLabel(AMapObject mapObject)
 {
     if (mapObject.OwnerSerial.IsValid)
     {
         // this object is an entity of some kind.
         createHoverLabel(mapObject.OwnerSerial);
     }
     else if (mapObject is MapObjectStatic)
     {
         // since statics have no entity object, we can't easily create a label for them at the moment.
         // surely this will be fixed.
     }
 }
Example #4
0
 public void AddMapObject(AMapObject[] items)
 {
     for (int i = 0; i < items.Length; i++)
     {
         AddMapObject(items[i]);
     }
 }
Example #5
0
 public void AddMapObject(AMapObject item)
 {
     m_Objects.Add(item);
     m_NeedsSorting = true;
     if (item is MapObjectDeferred)
         m_HasDeferredObjects = true;
 }
Example #6
0
 private bool matchNames(AMapObject m1, AMapObject m2)
 {
     if (UltimaData.TileData.ItemData[m1.ItemID & 0x3FFF].Name ==
         UltimaData.TileData.ItemData[m2.ItemID & 0x3FFF].Name)
     {
         return true;
     }
     return false;
 }
Example #7
0
        // Check if under a roof.
        public void IsUnder(int originZ, out AMapObject underItem, out AMapObject underTerrain)
        {
            underItem = null;
            underTerrain = null;

            List<AMapObject> iObjects = this.Items;
            for (int i = iObjects.Count - 1; i >= 0; i--)
            {
                if (iObjects[i].Z <= originZ)
                    continue;

                if (iObjects[i] is MapObjectStatic)
                {
                    UltimaData.ItemData iData = UltimaData.TileData.ItemData[((MapObjectStatic)iObjects[i]).ItemID & 0x3FFF];
                    if (iData.IsRoof || iData.IsSurface || iData.IsWall)
                    {
                        if (underItem == null || iObjects[i].Z < underItem.Z)
                            underItem = iObjects[i];
                    }
                }
                else if (iObjects[i] is MapObjectGround && iObjects[i].Z >= originZ + 20)
                {
                    underTerrain = iObjects[i];
                }
            }
        }