public override void Update(GameTime gameTime) { KeyCheck(); #region Set hero sockets. for (int i = 0; i < Player.HEROFRONT_MAX; i++) { DragSocket socket = heroFrontGroup.GetSocket(i); if (socket == null) { selector.SetItemToMatrix("HeroSockets", null, 0, i); continue; } selector.SetItemToMatrix("HeroSockets", (ISelectable)socket, 0, i); } for (int i = 0; i < Player.HEROBEHIND_MAX; i++) { DragSocket socket = heroBehindGroup.GetSocket(i); if (socket == null) { selector.SetItemToMatrix("HeroSockets", null, 1, i); continue; } selector.SetItemToMatrix("HeroSockets", (ISelectable)socket, 1, i); } for (int i = 0; i < Player.HEROSTORED_MAX; i++) { DragSocket socket = heroStoredGroup.GetSocket(i); if (socket == null) { selector.SetItemToMatrix("HeroSockets", null, 2, i); continue; } selector.SetItemToMatrix("HeroSockets", (ISelectable)socket, 2, i); } #endregion #region Drag MouseState mouse = Mouse.GetState(); if (mouse.LeftButton == ButtonState.Pressed) { if (dragging) { dragEffect.x = mouse.X; dragEffect.y = mouse.Y; // Socket effect. bool selected = false; foreach (GUIComponent element in guiLayer.MainGroup) { if (element is DragSocket) { if (((DragSocket)element).IsInside(mouse.X, mouse.Y) && ((DragSocket)element).MatchKey(dragGUI)) { selected = true; if (element != selectedSocket) { selectedSocket = (DragSocket)element; if (socketEffect is Effect) { socketEffect.Finish(); } socketEffect = new EffectTexture(selectedSocket.emphasis, selectedSocket.x, selectedSocket.y, -1); topEffectLayer.elements.Add(socketEffect); } } } } if (!selected) { if (socketEffect is Effect) { socketEffect.Finish(); } selectedSocket = null; } } else { foreach (GUIComponent element in guiLayer.MainGroup) { if (element is IDragable) { IDragable dragable = (IDragable)element; if (dragable.IsInside(mouse.X, mouse.Y)) { dragGUI = dragable; Texture2D dragTexture = dragable.GetTexture(); Vector2 dragOrigin = dragable.GetOrigin(mouse.X, mouse.Y); Sprite dragSprite = new Sprite(dragTexture, dragOrigin); dragEffect = new EffectSprite(dragSprite, mouse.X, mouse.Y); topEffectLayer.elements.Add(dragEffect); dragging = true; break; } } } } } else if (mouse.LeftButton == ButtonState.Released) { if (dragging) { foreach (GUIComponent element in guiLayer.MainGroup) { if (element is DragSocket) { DragSocket newSocket = (DragSocket)element; if (newSocket.IsInside(mouse.X, mouse.Y)) { if (newSocket.SetContent(dragGUI)) { break; } } } } dragging = false; dragEffect?.Finish(); socketEffect?.Finish(); } } #endregion base.Update(gameTime); }