internal void RemoveSelection() { foreach (UpgradeBarItem barItem in itemBoxes) { if (barItem.Active) { barItem.Active = false; followMouseSprite = null; selectedBarItem = null; Action = false; break; } } }
private void CheckAction() { if (itemBoxes != null) { foreach (UpgradeBarItem barItem in itemBoxes) { if (barItem.BoundBox.Contains(InputHandler.mPosition) && InputHandler.isJustPressed(MouseButton.LEFT)) { SoundHandler.PlaySoundEffect((int)IDs.MENUCLICK); if (barItem.Active) { RemoveSelection(); RotateItemSelected = false; } else { barItem.Active = true; Action = true; followMouseSprite = new Sprite(barItem.Sprite); followMouseSprite.Origin = new Vector2(followMouseSprite.SpriteRect.Width / 2, followMouseSprite.SpriteRect.Height / 2); followMouseSprite.Scale *= ClickableItem.SCALEFACTOR; selectedBarItem = barItem; if (barItem.id == IDs.ROTATEPART) { RotateItemSelected = true; } else { RotateItemSelected = false; } } foreach (UpgradeBarItem otherItem in itemBoxes) { if (otherItem != barItem) { otherItem.Active = false; } } break; } } if (InputHandler.isJustPressed(MouseButton.LEFT) && Action) { SelectedPart = selectedBarItem.ReturnPart(); } } }
internal void CreateItemBoxes() { itemBoxes = new List <UpgradeBarItem>(); cols = (int)Math.Ceiling((double)(itemBoxes.Count / rows)); int currentCol = 0; float scaleFactor = 32 * ClickableItem.SCALEFACTOR; for (int i = 0; i < upgradePartsIDs.Count; i++) { if (i % (rows) == 0 && i != 0) { currentCol++; } IDs tempID = upgradePartsIDs[i]; if (tempID.Equals(IDs.EMPTYPART)) { tempID = IDs.HAMMERPART; } UpgradeBarItem u = new UpgradeBarItem(new Vector2(currentCol * scaleFactor + spacing * (currentCol + 1) + offsetX, ((i - currentCol * (rows)) * scaleFactor + spacing * (i - currentCol * (rows)) + offsetY)), DrawHelper.UPGRADEFONT, tempID); itemBoxes.Insert(i, u); } }