somethings
This commit is contained in:
parent
67ad38f49a
commit
ecb63e6e2c
@ -109,27 +109,6 @@ public class DrawningSPAU {
|
||||
boolean hasBodyKit = EntitySPAU.BodyKit;
|
||||
|
||||
Path2D.Double path = new Path2D.Double();
|
||||
|
||||
/* Обвесы
|
||||
if (hasBodyKit) {
|
||||
path.moveTo(startPosX + 15, startPosY + 20);
|
||||
path.lineTo(startPosX + 35, startPosY + 20);
|
||||
path.lineTo(startPosX + 35, startPosY + 60);
|
||||
path.lineTo(startPosX + 15, startPosY + 60);
|
||||
path.closePath();
|
||||
|
||||
g2d.setPaint(additionalColor);
|
||||
g2d.fill(path);
|
||||
|
||||
g2d.setPaint(Color.BLACK);
|
||||
g2d.setStroke(penBlack);
|
||||
g2d.draw(path);
|
||||
path.reset();
|
||||
|
||||
Line2D line = new Line2D.Double(startPosX + 5, startPosY + 20, startPosX + 15, startPosY + 25);
|
||||
g2d.draw(line);
|
||||
}
|
||||
*/
|
||||
|
||||
//гусеницы
|
||||
DrawningRollers Rollers = new DrawningRollers(g2d, startPosX, startPosY, bodyColor, _numbeRollers);
|
||||
@ -230,4 +209,4 @@ public class DrawningSPAU {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,232 @@
|
||||
package SelfPropelledArtilleryUnit.DrawningObjects;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.geom.Path2D;
|
||||
|
||||
import SelfPropelledArtilleryUnit.DirectionType;
|
||||
import SelfPropelledArtilleryUnit.EntitySPAU;
|
||||
import SelfPropelledArtilleryUnit.SelfPropelledArtilleryUnit.Entities;
|
||||
|
||||
|
||||
public class DrawningSPAUchild {
|
||||
private EntitySPAU EntitySPAU;
|
||||
private int pictureWidth;
|
||||
private int pictureHeight;
|
||||
protected int startPosX;
|
||||
protected int startPosY;
|
||||
private int _numbeRollers;
|
||||
private final int carWidth = 135;
|
||||
private final int carHeight = 75;
|
||||
|
||||
protected void setEntitySPAU(EntitySPAU entitySPAU) {
|
||||
this.EntitySPAU = entitySPAU;
|
||||
}
|
||||
|
||||
public DrawningSPAUchild(int _numbeRollers, int speed, double weight, Color bodyColor, Color additionalColor, boolean bodyKit, int width, int height)
|
||||
{
|
||||
this._numbeRollers = _numbeRollers;
|
||||
this.pictureWidth = width;
|
||||
this.pictureHeight = height;
|
||||
if (this.carHeight >= height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.carWidth >= width)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EntitySPAU = new EntitySPAU(_numbeRollers, speed, weight, bodyColor, additionalColor, bodyKit);
|
||||
}
|
||||
|
||||
public DrawningSPAU(int _numbeRollers, int speed, double weight, Color bodyColor, Color additionalColor, boolean bodyKit, int width, int height, int carWidth, int carHeight)
|
||||
{
|
||||
this._numbeRollers = _numbeRollers;
|
||||
this.pictureWidth = width;
|
||||
this.pictureHeight = height;
|
||||
this.carWidth = carWidth;
|
||||
this.carHeight = carHeight;
|
||||
if (this.carHeight >= height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.carWidth >= width)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EntitySPAU = new EntitySPAU(_numbeRollers, speed, weight, bodyColor, additionalColor, bodyKit);
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (x < 0 || x > this.pictureWidth - this.carWidth)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
if (y < 0 || y > this.pictureHeight - this.carHeight)
|
||||
{
|
||||
y = 0;
|
||||
}
|
||||
this.startPosX = x;
|
||||
this.startPosY = y;
|
||||
}
|
||||
public void MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (!CanMove(direction) || EntitySPAU == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
case Left:
|
||||
this.startPosX -= (int)EntitySPAU.Step;
|
||||
break;
|
||||
//вверх
|
||||
case Up:
|
||||
this.startPosY -= (int)EntitySPAU.Step;
|
||||
break;
|
||||
// вправо
|
||||
case Right:
|
||||
this.startPosX += (int)EntitySPAU.Step;
|
||||
break;
|
||||
//вниз
|
||||
case Down:
|
||||
this.startPosY += (int)EntitySPAU.Step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawTransport(Graphics g) {
|
||||
if (EntitySPAU == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
|
||||
BasicStroke penBlack = new BasicStroke(1);
|
||||
//Color additionalColor = EntitySPAU.AdditionalColor;
|
||||
Color bodyColor = EntitySPAU.BodyColor;
|
||||
boolean hasBodyKit = EntitySPAU.BodyKit;
|
||||
|
||||
Path2D.Double path = new Path2D.Double();
|
||||
|
||||
// Обвесы
|
||||
if (hasBodyKit) {
|
||||
path.moveTo(startPosX + 15, startPosY + 20);
|
||||
path.lineTo(startPosX + 35, startPosY + 20);
|
||||
path.lineTo(startPosX + 35, startPosY + 60);
|
||||
path.lineTo(startPosX + 15, startPosY + 60);
|
||||
path.closePath();
|
||||
|
||||
g2d.setPaint(additionalColor);
|
||||
g2d.fill(path);
|
||||
|
||||
g2d.setPaint(Color.BLACK);
|
||||
g2d.setStroke(penBlack);
|
||||
g2d.draw(path);
|
||||
path.reset();
|
||||
|
||||
Line2D line = new Line2D.Double(startPosX + 5, startPosY + 20, startPosX + 15, startPosY + 25);
|
||||
g2d.draw(line);
|
||||
}
|
||||
|
||||
//гусеницы
|
||||
DrawningRollers Rollers = new DrawningRollers(g2d, startPosX, startPosY, bodyColor, _numbeRollers);
|
||||
Rollers.Draw();
|
||||
|
||||
// пушка
|
||||
path.moveTo(startPosX + 35, startPosY + 40);
|
||||
path.lineTo(startPosX + 40, startPosY + 45);
|
||||
path.lineTo(startPosX + 135, startPosY + 5);
|
||||
path.lineTo(startPosX + 130, startPosY + 0);
|
||||
path.closePath();
|
||||
|
||||
g2d.setPaint(bodyColor);
|
||||
g2d.fill(path);
|
||||
g2d.draw(path);
|
||||
path.reset();
|
||||
|
||||
// корпус
|
||||
path.moveTo(startPosX, startPosY + 60);
|
||||
path.lineTo(startPosX + 10, startPosY + 30);
|
||||
path.lineTo(startPosX + 130, startPosY + 30);
|
||||
path.lineTo(startPosX + 135, startPosY + 60);
|
||||
path.closePath();
|
||||
|
||||
g2d.setPaint(bodyColor);
|
||||
g2d.fill(path);
|
||||
g2d.draw(path);
|
||||
path.reset();
|
||||
|
||||
// башня
|
||||
path.moveTo(startPosX + 40, startPosY + 30);
|
||||
path.lineTo(startPosX + 45, startPosY + 15);
|
||||
path.lineTo(startPosX + 70, startPosY + 15);
|
||||
path.lineTo(startPosX + 75, startPosY + 30);
|
||||
path.closePath();
|
||||
|
||||
g2d.setPaint(bodyColor);
|
||||
g2d.fill(path);
|
||||
g2d.draw(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Координата X объекта
|
||||
*
|
||||
* @return значение координаты X
|
||||
*/
|
||||
public int getPosX() {
|
||||
return this.startPosX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Координата Y объекта
|
||||
*
|
||||
* @return значение координаты Y
|
||||
*/
|
||||
public int getPosY() {
|
||||
return this.startPosY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ширина объекта
|
||||
*
|
||||
* @return значение ширины
|
||||
*/
|
||||
public int getWidth() {
|
||||
return this.carWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Высота объекта
|
||||
*
|
||||
* @return значение высоты
|
||||
*/
|
||||
public int getHeight() {
|
||||
return this.carHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка, что объект может переместиться в указанном направлении
|
||||
*
|
||||
* @param direction Направление
|
||||
* @return true - можно переместиться в указанном направлении
|
||||
*/
|
||||
public boolean canMove(DirectionType direction) {
|
||||
if (EntitySPAU == null) {
|
||||
return false;
|
||||
}
|
||||
switch (direction) {
|
||||
case Left: // влево
|
||||
return startPosX - EntitySPAU.getStep() > 0;
|
||||
case Up: // вверх
|
||||
return startPosY - EntitySPAU.getStep() > 0;
|
||||
case Right: // вправо
|
||||
return startPosX + EntitySPAU.getStep() < _pictureWidth - _carWidth;
|
||||
case Down: // вниз
|
||||
return startPosY + EntitySPAU.getStep() < _pictureHeight - _carHeight;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user