Exemplo n.º 1
0
        private void onInteractButton(InputEventMouse e, AEntity overEntity, Vector2 overEntityPoint)
        {
            if(e.EventType == MouseEvent.Down)
            {
                // prepare to pick this item up.
                m_DraggingEntity = overEntity;
                m_dragOffset = overEntityPoint;
            }
            else if(e.EventType == MouseEvent.Click)
            {
                if(overEntity is Ground)
                {
                    // no action.
                }
                else if(overEntity is StaticItem)
                {
                    // pop up name of item.
                    overEntity.AddOverhead(MessageTypes.Label, "<outline>" + overEntity.Name, 0, 0);
                    WorldModel.Statics.AddStaticThatNeedsUpdating(overEntity as StaticItem);
                }
                else if(overEntity is Item)
                {
                    // request context menu
                    World.Interaction.SingleClick(overEntity);
                }
                else if(overEntity is Mobile)
                {
                    // request context menu
                    World.Interaction.SingleClick(overEntity);
                }
            }
            else if(e.EventType == MouseEvent.DoubleClick)
            {
                if(overEntity is Ground)
                {
                    // no action.
                }
                else if(overEntity is StaticItem)
                {
                    // no action.
                }
                else if(overEntity is Item)
                {
                    // request context menu
                    World.Interaction.DoubleClick(overEntity);
                }
                else if(overEntity is Mobile)
                {
                    // Send double click packet.
                    // Set LastTarget == targeted Mobile.
                    // If in WarMode, set Attacking == true.
                    World.Interaction.DoubleClick(overEntity);
                    World.Interaction.LastTarget = overEntity.Serial;

                    if (WorldModel.Entities.GetPlayerEntity().Flags.IsWarMode)
                    {
                        m_Network.Send(new AttackRequestPacket(overEntity.Serial));
                    }
                }
            }
            else if(e.EventType == MouseEvent.DragBegin)
            {
                if(overEntity is Ground)
                {
                    // no action.
                }
                else if(overEntity is StaticItem)
                {
                    // no action.
                }
                else if(overEntity is Item)
                {
                    // attempt to pick up item.
                    World.Interaction.PickupItem((Item)overEntity, new Point((int)m_dragOffset.X, (int)m_dragOffset.Y));
                }
                else if(overEntity is Mobile)
                {
                    // drag off a status gump for this mobile.
                    MobileHealthTrackerGump gump = new MobileHealthTrackerGump(overEntity as Mobile);
                    m_UserInterface.AddControl(gump, e.X - 77, e.Y - 30);
                    m_UserInterface.AttemptDragControl(gump, new Point(e.X, e.Y), true);
                }
            }

            e.Handled = true;
        }