PIbd-14_Antonova_A.A.__Hard/Drawnings/DrawningDumpTruck.java

96 lines
3.3 KiB
Java
Raw Permalink Normal View History

2024-05-09 20:09:37 +04:00
package Drawnings;
import Entities.EntityDumpTruck;
import java.awt.*;
import java.util.Random;
public class DrawningDumpTruck extends DrawningTruck {
public DrawningDumpTruck(int speed, double weight, Color bodyColor,
Color additionalColor, Boolean body, Boolean tent)
{
super(speed, weight, bodyColor);
//super(110, 100);
EntityTruck = new EntityDumpTruck(speed, weight, bodyColor, additionalColor, body, tent);
_ornament.SetCount(random.nextInt(2, 5));
}
public DrawningDumpTruck(){
super(110, 100);
}
@Override
public void DrawTransport(Graphics2D g)
{
if (EntityTruck == null || !(EntityTruck instanceof EntityDumpTruck entityTruck) || _startPosX == null || _startPosY == null)
{
return;
}
_startPosX += 5;
super.DrawTransport(g);
_startPosX -= 5;
g.setPaint(Color.BLACK);
if (entityTruck.Body)
{
int[] x_b = {_startPosX, _startPosX + 77, _startPosX + 77, _startPosX + 20};
int[] y_b = {_startPosY + 15, _startPosY + 15, _startPosY + 50, _startPosY + 50};
g.setPaint(Color.BLACK);
g.drawPolygon(x_b, y_b, 4);
g.setPaint(entityTruck.AdditionalColor);
g.fillPolygon(x_b, y_b, 4);
}
if (entityTruck.Tent && entityTruck.Body)
{
int[] x_t = {_startPosX, _startPosX + 39, _startPosX + 77};
int[] y_t = {_startPosY + 13, _startPosY, _startPosY + 13};
g.setPaint(Color.BLACK);
g.drawPolygon(x_t, y_t, 3);
g.setPaint(entityTruck.AdditionalColor);
g.fillPolygon(x_t, y_t, 3);
}
// Колёса
g.setPaint(Color.BLACK);
if (_ornament != null){
switch (_ornament.get_count_weels()){
case 2:
_ornament.DrawOrnament(g, _startPosX + 10, _startPosY + 67);
_ornament.DrawOrnament(g, _startPosX + 85, _startPosY + 67);
break;
case 3:
_ornament.DrawOrnament(g, _startPosX + 10, _startPosY + 67);
_ornament.DrawOrnament(g, _startPosX + 38, _startPosY + 67);
_ornament.DrawOrnament(g, _startPosX + 85, _startPosY + 67);
break;
case 4:
_ornament.DrawOrnament(g, _startPosX + 5, _startPosY + 67);
_ornament.DrawOrnament(g, _startPosX + 32, _startPosY + 67);
_ornament.DrawOrnament(g, _startPosX + 61, _startPosY + 67);
_ornament.DrawOrnament(g, _startPosX + 88, _startPosY + 67);
break;
}
}
//Границы самосвала
g.drawRect( _startPosX + 10, _startPosY + 53, 100, 13);
g.drawRect( _startPosX + 80, _startPosY + 15, 30, 36);
g.drawRect(_startPosX + 85, _startPosY + 20, 20, 20);
// Кузов
g.setPaint(entityTruck.BodyColor);
g.fillRect(_startPosX + 10, _startPosY + 53, 100, 13);
g.fillRect(_startPosX + 80, _startPosY + 15, 30, 36);
//Окно
g.setPaint(Color.CYAN);
g.fillRect(_startPosX + 85, _startPosY + 20, 20, 20);
}
}