Beispiel #1
0
 void SwapSelectedSlot(SlotUI newSlot, bool controlKeyPressed)
 {
     if (m_selectedSlot != null && newSlot != null)
     {
         int        index         = m_selectedSlot.GetSlotIndex();
         int        newSlotIndex  = newSlot.GetSlotIndex();
         int        amount        = m_selectedSlot.GetSlotAmount(controlKeyPressed);
         int        windowId      = m_selectedSlot.GetWindow().GetWindowId();
         int        newWindowId   = newSlot.GetWindow().GetWindowId();
         int        npcId         = m_selectedSlot.GetWindow().GetNPCId();
         int        newNpcId      = newSlot.GetWindow().GetNPCId();
         bool       viewOnlySlot  = m_selectedSlot.ViewOnly() || newSlot.ViewOnly();
         WindowType windowType    = m_selectedSlot.GetWindow().GetWindowType();
         WindowType newWindowType = newSlot.GetWindow().GetWindowType();
         if (windowType.Equals(WindowType.InventoryWindow))
         {
             if (windowType.Equals(newWindowType) && !m_selectedSlot.Equals(newSlot))
             {
                 if (controlKeyPressed)
                 {
                     m_gameManager.SendSplit(index, newSlotIndex);
                 }
                 else
                 {
                     m_gameManager.SendChange(index, newSlotIndex);
                 }
             }
             else if (newWindowType.Equals(WindowType.CharacterWindow))
             {
                 m_gameManager.SendUse(index);
             }
             else if (IsCombineWindow(newWindowType))
             {
                 m_gameManager.SendInventoryToWindow(index, newWindowId, newSlotIndex);
             }
             else if (newWindowType.Equals(WindowType.VendorWindow))
             {
                 m_gameManager.SendInventorySellToVendor(newNpcId, index, amount);
             }
             else if (newWindowType.Equals(WindowType.TradeWindow) && !viewOnlySlot)
             {
                 m_gameManager.SendAddTradeItem(newSlotIndex, index);
             }
             else if (newWindowType.Equals(WindowType.CommandBar))
             {
                 m_state.AddCommandSlot(newSlotIndex, m_selectedSlot);
             }
         }
         else if (windowType.Equals(WindowType.CharacterWindow))
         {
             if (windowType.Equals(newWindowType))
             {
                 m_gameManager.SendUse(index);
             }
             else if (newWindowType.Equals(WindowType.InventoryWindow))
             {
                 m_gameManager.SendUse(index);
             }
             else if (newWindowType.Equals(WindowType.VendorWindow))
             {
                 m_gameManager.SendInventorySellToVendor(newNpcId, index, amount);
             }
             else if (newWindowType.Equals(WindowType.CommandBar))
             {
                 m_state.AddCommandSlot(newSlotIndex, m_selectedSlot);
             }
         }
         else if (windowType.Equals(WindowType.SpellsWindow))
         {
             if (windowType.Equals(newWindowType) && !m_selectedSlot.Equals(newSlot))
             {
                 m_gameManager.SendSwap(index, newSlotIndex);
             }
             else if (newWindowType.Equals(WindowType.CommandBar))
             {
                 m_state.AddCommandSlot(newSlotIndex, m_selectedSlot);
             }
         }
         else if (IsCombineWindow(windowType))
         {
             if (IsCombineWindow(newWindowType))
             {
                 m_gameManager.SendWindowToWindow(windowId, index, newWindowId, newSlotIndex);
             }
             else if (newWindowType.Equals(WindowType.InventoryWindow))
             {
                 m_gameManager.SendWindowToInventory(windowId, index, newSlotIndex);
             }
             else if (newWindowType.Equals(WindowType.VendorWindow))
             {
                 m_gameManager.SendWindowSellToVendor(newNpcId, windowId, index, amount);
             }
         }
         else if (windowType.Equals(WindowType.VendorWindow))
         {
             if (newWindowType.Equals(WindowType.InventoryWindow))
             {
                 m_gameManager.SendVendorPurchaseToInventory(npcId, index);
             }
         }
         else if (windowType.Equals(WindowType.CommandBar))
         {
             if (newWindowType.Equals(WindowType.CommandBar))
             {
                 m_state.SwapCommandSlot(index, newSlotIndex);
             }
         }
     }
 }