private static void SecondaryPanelControl_MouseLeave(object sender, EventArgs e) { BattleEventRenderer.IsSecondaryPanelMouseDown = false; BattleEventRenderer.IsHoveringSecondaryPanel = false; BattleEventRenderer.DrawSecondaryPanel(); BattleEventRenderer.DrawField(); }
private static void FieldControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (!BattleEventRenderer.FieldMouseDownPosition.HasValue) { BattleEventRenderer.FieldMouseDownPosition = e.Location; BattleEventRenderer.DrawField(); } }
private static void DrawPanels() { var cols = 4; var startPoint = new Point(10, 10); var margin = 5; var optionsCount = 10; for (int panel = 0; panel < optionsCount; panel++) { var topLeft = new Point(startPoint.X + (panel % cols) * (40 + margin * 2), startPoint.Y + (panel / cols) * (32 + margin * 2)); BattleEventRenderer.PanelSelectionRenderer.Draw(new Sprite { Position = new Point(topLeft.X, topLeft.Y), TexX = 0, TexY = 32 * panel, Width = 40, Height = 32, Texture = $"battleobjects" }.WithTopLeftPosition(), 0); } { var selectedPanel = (int)(BattleEventRenderer.IsSettingPrimaryPanel ? BattleEventRenderer.CurrentEncounter.PrimaryPanel : BattleEventRenderer.CurrentEncounter.SecondaryPanel); var topLeft = new Point(startPoint.X - margin + (selectedPanel % cols) * (40 + margin * 2), startPoint.Y - margin + (selectedPanel / cols) * (32 + margin * 2)); var bottomRight = new Point(topLeft.X + 40 + margin * 2, topLeft.Y + 32 + margin * 2); BattleEventRenderer.PanelSelectionRenderer.DrawQuad(new Quad { A = new Point(bottomRight.X, topLeft.Y), B = new Point(bottomRight.X, bottomRight.Y), C = new Point(topLeft.X, bottomRight.Y), D = new Point(topLeft.X, topLeft.Y), Color = Color.FromArgb(125, Color.Wheat), Type = DrawType.Outline | DrawType.Fill }, 4); } var selectedPosition = BattleEventRenderer.PanelSelectionMouseClickConfirmPosition ?? BattleEventRenderer.PanelSelectionMouseClickPosition ?? BattleEventRenderer.PanelSelectionMousePosition; if (selectedPosition != null) { var highlightedPanel = (selectedPosition.Value.X / (40 + 2 * margin)) + cols * (selectedPosition.Value.Y / (32 + 2 * margin)); if (highlightedPanel < optionsCount) { var topLeft = new Point(startPoint.X - margin + (highlightedPanel % cols) * (40 + margin * 2), startPoint.Y - margin + (highlightedPanel / cols) * (32 + margin * 2)); var bottomRight = new Point(topLeft.X + 40 + margin * 2, topLeft.Y + 32 + margin * 2); var color = BattleEventRenderer.PanelSelectionMouseClickPosition.HasValue ? Color.FromArgb(128, Color.DarkBlue) : Color.FromArgb(128, Color.AliceBlue); BattleEventRenderer.PanelSelectionRenderer.DrawQuad(new Quad { A = new Point(bottomRight.X, topLeft.Y), B = new Point(bottomRight.X, bottomRight.Y), C = new Point(topLeft.X, bottomRight.Y), D = new Point(topLeft.X, topLeft.Y), Color = color, Type = DrawType.Outline | DrawType.Fill }, 4); } if (BattleEventRenderer.PanelSelectionMouseClickConfirmPosition.HasValue && BattleEventRenderer.PanelSelectionMouseClickPosition.HasValue) { var selectedPanel = (BattleEventRenderer.PanelSelectionMouseClickPosition.Value.X / (40 + 2 * margin)) + cols * (BattleEventRenderer.PanelSelectionMouseClickPosition.Value.Y / (32 + 2 * margin)); var confirmPanel = (BattleEventRenderer.PanelSelectionMouseClickConfirmPosition.Value.X / (40 + 2 * margin)) + cols * (BattleEventRenderer.PanelSelectionMouseClickConfirmPosition.Value.Y / (32 + 2 * margin)); if (confirmPanel < optionsCount && confirmPanel == selectedPanel) { if (BattleEventRenderer.IsSettingPrimaryPanel) { BattleEventRenderer.CurrentEncounter.PrimaryPanel = (Panel.PANEL)highlightedPanel; } else { BattleEventRenderer.CurrentEncounter.SecondaryPanel = (Panel.PANEL)highlightedPanel; } BattleEventRenderer.DrawField(); BattleEventRenderer.DrawPrimaryPanel(); BattleEventRenderer.DrawSecondaryPanel(); } BattleEventRenderer.PanelSelectionMouseClickPosition = null; BattleEventRenderer.PanelSelectionMouseClickConfirmPosition = null; } } BattleEventRenderer.PanelSelectionRenderer.Render(); }
private static void DrawEnemies() { var cols = 10; var startPoint = new Point(10, 10); var margin = 5; var optionsCount = LoadingWindowViewModel.Settings.EnemyCount; for (int enemyID = 0; enemyID < optionsCount; enemyID++) { if (enemyID == 0) { var offX = 5; var offY = -3; BattleEventRenderer.EnemySelectionRenderer.DrawQuad(new Quad { A = new Point(70 + offX, 15 + offY), B = new Point(80 + offX, 25 + offY), C = new Point(20 + offX, 85 + offY), D = new Point(10 + offX, 75 + offY), Color = Color.Red, Type = DrawType.Fill }, 1); continue; } var x = (enemyID % cols); var y = (enemyID / cols); var renderPass = y * RenderPassPadding; var enemyDef = Constants.BaseEnemyDefinitions[enemyID]; if (enemyDef == null) { continue; } foreach (var drawCall in enemyDef.DrawCalls) { var drawnSprite = new Sprite { Position = new Point(drawCall.Position.X + x * (80 + margin * 2) + 40 - 10, drawCall.Position.Y + y * (80 + margin * 2) - 20), TexX = drawCall.TexturePosition.X, TexY = drawCall.TexturePosition.Y, Width = drawCall.Size.Width, Height = drawCall.Size.Height, Texture = drawCall.TextureName, Scale = new Vector2((float)(drawCall.IsReversed ? -drawCall.Scale : drawCall.Scale), (float)drawCall.Scale), Rotate = (float)drawCall.Rotate }; if (drawCall.IsFromTopLeft) { drawnSprite = drawnSprite.WithTopLeftPosition(); } BattleEventRenderer.EnemySelectionRenderer.Draw(drawnSprite, renderPass); } } if (BattleEventRenderer.CurrentEnemy != null) { var selectedEnemy = BattleEventRenderer.CurrentEnemy.ID; var topLeft = new Point(startPoint.X - margin + (selectedEnemy % cols) * (80 + margin * 2), startPoint.Y - margin + (selectedEnemy / cols) * (80 + margin * 2)); var bottomRight = new Point(topLeft.X + 80 + margin * 2, topLeft.Y + 80 + margin * 2); BattleEventRenderer.EnemySelectionRenderer.DrawQuad(new Quad { A = new Point(bottomRight.X, topLeft.Y), B = new Point(bottomRight.X, bottomRight.Y), C = new Point(topLeft.X, bottomRight.Y), D = new Point(topLeft.X, topLeft.Y), Color = Color.FromArgb(125, Color.Wheat), Type = DrawType.Outline | DrawType.Fill }, 4); } var selectedPosition = BattleEventRenderer.EnemySelectionMouseClickConfirmPosition ?? BattleEventRenderer.EnemySelectionMouseClickPosition ?? BattleEventRenderer.EnemySelectionMousePosition; if (selectedPosition != null) { var highlightedEnemy = (selectedPosition.Value.X / (80 + 2 * margin)) + cols * (selectedPosition.Value.Y / (80 + 2 * margin)); if (highlightedEnemy < optionsCount && (highlightedEnemy == 0 || Constants.BaseEnemyDefinitions[highlightedEnemy] != null)) { var topLeft = new Point(startPoint.X - margin + (highlightedEnemy % cols) * (80 + margin * 2), startPoint.Y - margin + (highlightedEnemy / cols) * (80 + margin * 2)); var bottomRight = new Point(topLeft.X + 80 + margin * 2, topLeft.Y + 80 + margin * 2); var color = BattleEventRenderer.EnemySelectionMouseClickPosition.HasValue ? Color.FromArgb(128, Color.DarkBlue) : Color.FromArgb(128, Color.AliceBlue); BattleEventRenderer.EnemySelectionRenderer.DrawQuad(new Quad { A = new Point(bottomRight.X, topLeft.Y), B = new Point(bottomRight.X, bottomRight.Y), C = new Point(topLeft.X, bottomRight.Y), D = new Point(topLeft.X, topLeft.Y), Color = color, Type = DrawType.Outline | DrawType.Fill }, 4); } if (BattleEventRenderer.EnemySelectionMouseClickConfirmPosition.HasValue && BattleEventRenderer.EnemySelectionMouseClickPosition.HasValue) { var selectedEnemy = (BattleEventRenderer.EnemySelectionMouseClickPosition.Value.X / (80 + 2 * margin)) + cols * (BattleEventRenderer.EnemySelectionMouseClickPosition.Value.Y / (80 + 2 * margin)); var confirmEnemy = (BattleEventRenderer.EnemySelectionMouseClickConfirmPosition.Value.X / (80 + 2 * margin)) + cols * (BattleEventRenderer.EnemySelectionMouseClickConfirmPosition.Value.Y / (80 + 2 * margin)); if (confirmEnemy < optionsCount && confirmEnemy == selectedEnemy && (highlightedEnemy == 0 || Constants.BaseEnemyDefinitions[highlightedEnemy] != null)) { BattleEventRenderer.CurrentEnemy.ID = highlightedEnemy; BattleEventRenderer.DrawField(); BattleEventRenderer.DrawEnemy(); } BattleEventRenderer.EnemySelectionMouseClickPosition = null; BattleEventRenderer.EnemySelectionMouseClickConfirmPosition = null; } } BattleEventRenderer.EnemySelectionRenderer.Render(); }
private static void FieldControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { BattleEventRenderer.FieldMousePosition = e.Location; BattleEventRenderer.DrawField(); }
private static void SecondaryPanelControl_MouseEnter(object sender, EventArgs e) { BattleEventRenderer.IsHoveringSecondaryPanel = true; BattleEventRenderer.DrawSecondaryPanel(); BattleEventRenderer.DrawField(); }