Пример #1
0
    public static void OnMouseButtonPressed(object sender, MouseButtonEventArgs e)
    {
        // Clique duplo
        if (Environment.TickCount < DoubleClick_Timer + 142)
        {
            if (Tools.CurrentWindow == Tools.Windows.Game)
            {
                // Usar item
                byte Slot = Panels.Inventory_Mouse();
                if (Slot > 0)
                {
                    if (Player.Inventory[Slot].Item_Num > 0)
                    {
                        Send.Inventory_Use(Slot);
                    }
                }

                // Usar o que estiver na hotbar
                Slot = Panels.Hotbar_Mouse();
                if (Slot > 0)
                {
                    if (Player.Hotbar[Slot].Slot > 0)
                    {
                        Send.Hotbar_Use(Slot);
                    }
                }
            }
        }
        // Clique único
        else
        {
            // Percorre toda a árvore de ordem para executar o comando
            Stack <List <Tools.Order_Structure> > Stack = new Stack <List <Tools.Order_Structure> >();
            Stack.Push(Tools.Order);
            while (Stack.Count != 0)
            {
                List <Tools.Order_Structure> Top = Stack.Pop();

                for (byte i = 0; i < Top.Count; i++)
                {
                    if (Top[i].Data.Visible)
                    {
                        // Executa o comando
                        if (Top[i].Data is Buttons.Structure)
                        {
                            ((Buttons.Structure)Top[i].Data).MouseDown(e);
                        }
                        Stack.Push(Top[i].Nodes);
                    }
                }
            }

            // Eventos em jogo
            if (Tools.CurrentWindow == Tools.Windows.Game)
            {
                Panels.Inventory_MouseDown(e);
                Panels.Equipment_MouseDown(e);
                Panels.Hotbar_MouseDown(e);
            }
        }
    }