Некоторые изменения
This commit is contained in:
parent
b881a9a9f9
commit
e88200378f
@ -1,5 +0,0 @@
|
|||||||
public enum CountRollers {
|
|
||||||
Four,
|
|
||||||
Five,
|
|
||||||
Six;
|
|
||||||
}
|
|
@ -0,0 +1,14 @@
|
|||||||
|
package DifferentsDrawningRollers;
|
||||||
|
|
||||||
|
public enum CountRollers {
|
||||||
|
Four(1),
|
||||||
|
Five(2),
|
||||||
|
Six(3);
|
||||||
|
private final int count;
|
||||||
|
CountRollers(int count) {
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
public int getCountRollers() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
@ -1,29 +1,21 @@
|
|||||||
|
package DifferentsDrawningRollers;
|
||||||
|
|
||||||
|
import DifferentsDrawningRollers.CountRollers;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
public class DrawningRollers {
|
public class DrawningRollers implements IDrawningsRollers{
|
||||||
private CountRollers _rollers;
|
private CountRollers _rollers;
|
||||||
|
@Override
|
||||||
public CountRollers getCount() {
|
public void setCountRollers(int numRollers) {
|
||||||
return _rollers;
|
for (CountRollers value : CountRollers.values()) {
|
||||||
}
|
if (value.getCountRollers() == numRollers) {
|
||||||
|
_rollers = value;
|
||||||
public void SetCount(int count) {
|
return;
|
||||||
switch (count) {
|
}
|
||||||
case 1: // 4
|
|
||||||
_rollers = CountRollers.Four;
|
|
||||||
break;
|
|
||||||
case 2: // 5
|
|
||||||
_rollers = CountRollers.Five;
|
|
||||||
break;
|
|
||||||
case 3: // 6
|
|
||||||
_rollers = CountRollers.Six;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_rollers = CountRollers.Four;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void Draw(Graphics2D g, int _StartPosX, int _StartPosY) {
|
public void DrawRollers(Graphics2D g, int _StartPosX, int _StartPosY) {
|
||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
if (_rollers == null) {
|
if (_rollers == null) {
|
||||||
return;
|
return;
|
@ -0,0 +1,8 @@
|
|||||||
|
package DifferentsDrawningRollers;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public interface IDrawningsRollers {
|
||||||
|
void setCountRollers(int numRollers);
|
||||||
|
void DrawRollers(Graphics g, int startPosX, int startPosY);
|
||||||
|
}
|
@ -1,3 +1,7 @@
|
|||||||
|
package Drawnings;
|
||||||
|
|
||||||
|
import Drawnings.DrawningAntiAircraftGun;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
public class CanvasAntiAircraftGun extends JComponent {
|
public class CanvasAntiAircraftGun extends JComponent {
|
@ -1,3 +1,5 @@
|
|||||||
|
package Drawnings;
|
||||||
|
|
||||||
public enum DirectionType {
|
public enum DirectionType {
|
||||||
Up,
|
Up,
|
||||||
Down,
|
Down,
|
@ -1,8 +1,12 @@
|
|||||||
|
package Drawnings;
|
||||||
|
|
||||||
|
import Entities.EntityAntiAircraftGun;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
public class DrawningAntiAircraftGun extends JPanel{
|
public class DrawningAntiAircraftGun extends JPanel{
|
||||||
public EntityAntiAircraftGun EntityAntiAircraftGun;
|
public Entities.EntityAntiAircraftGun EntityAntiAircraftGun;
|
||||||
public DrawningRollers _rollers = null;
|
public DrawningRollers _rollers = null;
|
||||||
private Integer picture_width;
|
private Integer picture_width;
|
||||||
private Integer picture_height;
|
private Integer picture_height;
|
||||||
@ -59,24 +63,24 @@ public class DrawningAntiAircraftGun extends JPanel{
|
|||||||
public boolean MoveTransport(DirectionType direction) {
|
public boolean MoveTransport(DirectionType direction) {
|
||||||
if (EntityAntiAircraftGun == null || _StartPosX == null || _StartPosY == null) return false;
|
if (EntityAntiAircraftGun == null || _StartPosX == null || _StartPosY == null) return false;
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case Left:
|
case DirectionType.Left:
|
||||||
if (_StartPosX - EntityAntiAircraftGun.Step > 0) {
|
if (_StartPosX - EntityAntiAircraftGun.Step > 0) {
|
||||||
_StartPosX -= (int)EntityAntiAircraftGun.Step;
|
_StartPosX -= (int)EntityAntiAircraftGun.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case Up:
|
case DirectionType.Up:
|
||||||
if (_StartPosY - EntityAntiAircraftGun.Step > 0)
|
if (_StartPosY - EntityAntiAircraftGun.Step > 0)
|
||||||
{
|
{
|
||||||
_StartPosY -= (int)EntityAntiAircraftGun.Step;
|
_StartPosY -= (int)EntityAntiAircraftGun.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case Right:
|
case DirectionType.Right:
|
||||||
if (_StartPosX + drawningCarWidth + (int)EntityAntiAircraftGun.Step < picture_width - EntityAntiAircraftGun.Step)
|
if (_StartPosX + drawningCarWidth + (int)EntityAntiAircraftGun.Step < picture_width - EntityAntiAircraftGun.Step)
|
||||||
{
|
{
|
||||||
_StartPosX += (int)EntityAntiAircraftGun.Step;
|
_StartPosX += (int)EntityAntiAircraftGun.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case Down:
|
case DirectionType.Down:
|
||||||
if (_StartPosY + drawningCarHeight + (int)EntityAntiAircraftGun.Step < picture_height - EntityAntiAircraftGun.Step)
|
if (_StartPosY + drawningCarHeight + (int)EntityAntiAircraftGun.Step < picture_height - EntityAntiAircraftGun.Step)
|
||||||
{
|
{
|
||||||
_StartPosY += (int)EntityAntiAircraftGun.Step;
|
_StartPosY += (int)EntityAntiAircraftGun.Step;
|
||||||
@ -124,7 +128,7 @@ public class DrawningAntiAircraftGun extends JPanel{
|
|||||||
g.setColor(EntityAntiAircraftGun.getBodyColor());
|
g.setColor(EntityAntiAircraftGun.getBodyColor());
|
||||||
g.fillRect(_StartPosX + 10, _StartPosY+ 65, 120, 13);
|
g.fillRect(_StartPosX + 10, _StartPosY+ 65, 120, 13);
|
||||||
|
|
||||||
_rollers.Draw(g,_StartPosX, _StartPosY);
|
_rollers.DrawRollers(g,_StartPosX, _StartPosY);
|
||||||
//отрисовки башни
|
//отрисовки башни
|
||||||
if (EntityAntiAircraftGun.getIsTower())
|
if (EntityAntiAircraftGun.getIsTower())
|
||||||
{
|
{
|
@ -1,3 +1,5 @@
|
|||||||
|
package Entities;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
public class EntityAntiAircraftGun {
|
public class EntityAntiAircraftGun {
|
||||||
private int Speed;
|
private int Speed;
|
@ -1,3 +1,7 @@
|
|||||||
|
import Drawnings.CanvasAntiAircraftGun;
|
||||||
|
import Drawnings.DirectionType;
|
||||||
|
import Drawnings.DrawningAntiAircraftGun;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user