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