mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
* GUI: improved attackers draw (if attacker was blocked then arrow colorizes with gray color);
This commit is contained in:
parent
c7595ca476
commit
2b82785e4a
2 changed files with 16 additions and 12 deletions
|
@ -27,6 +27,9 @@ public enum CombatManager {
|
|||
private final Map<UUID, Integer> combatBlockers = new HashMap<>();
|
||||
private int globalBlockersCount; // we need global counter as there are several combat groups
|
||||
|
||||
private static Color ARROW_COLOR_ATTACKER = Color.red;
|
||||
private static Color ARROW_COLOR_BLOCKED_ATTACKER = Color.gray;
|
||||
|
||||
|
||||
private Point parentPoint;
|
||||
|
||||
|
@ -79,15 +82,19 @@ public enum CombatManager {
|
|||
private void drawDefender(CombatGroupView group, MagePermanent attackerCard, UUID gameId) {
|
||||
UUID defenderId = group.getDefenderId();
|
||||
if (defenderId != null) {
|
||||
// if attacker was blocked then use another allow color
|
||||
Color attackColor = group.getBlockers().isEmpty() ? ARROW_COLOR_ATTACKER : ARROW_COLOR_BLOCKED_ATTACKER;
|
||||
parentPoint = getParentPoint(attackerCard);
|
||||
PlayAreaPanel p = MageFrame.getGamePlayers(gameId).get(defenderId);
|
||||
if (p != null) {
|
||||
// attack to player
|
||||
Point target = p.getLocationOnScreen();
|
||||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
Point attackerPoint = attackerCard.getLocationOnScreen();
|
||||
attackerPoint.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(gameId, (int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() - 20, Color.red, ArrowBuilder.Type.COMBAT);
|
||||
ArrowBuilder.getBuilder().addArrow(gameId, (int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() - 20, attackColor, ArrowBuilder.Type.COMBAT);
|
||||
} else {
|
||||
// attack to planeswalker
|
||||
for (PlayAreaPanel pa : MageFrame.getGamePlayers(gameId).values()) {
|
||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(defenderId);
|
||||
if (permanent != null) {
|
||||
|
@ -95,7 +102,7 @@ public enum CombatManager {
|
|||
target.translate(-parentPoint.x, -parentPoint.y);
|
||||
Point attackerPoint = attackerCard.getLocationOnScreen();
|
||||
attackerPoint.translate(-parentPoint.x, -parentPoint.y);
|
||||
ArrowBuilder.getBuilder().addArrow(gameId, (int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() + 10, Color.red, ArrowBuilder.Type.COMBAT);
|
||||
ArrowBuilder.getBuilder().addArrow(gameId, (int) attackerPoint.getX() + 45, (int) attackerPoint.getY() + 25, (int) target.getX() + 40, (int) target.getY() + 10, attackColor, ArrowBuilder.Type.COMBAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
package mage.client.util.gui;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Composite;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class Arrow extends JPanel {
|
||||
|
||||
|
@ -26,6 +19,7 @@ public class Arrow extends JPanel {
|
|||
private float headSize = 17;
|
||||
private Composite composite;
|
||||
private Color color = Color.red;
|
||||
private Color strokeColor = Color.black;
|
||||
|
||||
public Arrow() {
|
||||
setOpaque(false);
|
||||
|
@ -53,8 +47,11 @@ public class Arrow extends JPanel {
|
|||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setComposite(composite);
|
||||
g2d.setColor(this.color);
|
||||
//debug stroke draw
|
||||
//float[] dash2 = {10, 5};
|
||||
//g2d.setStroke(new BasicStroke(3.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10.0f, dash2, 0));
|
||||
g2d.fill(arrow);
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.setColor(this.strokeColor);
|
||||
g2d.draw(arrow);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue