PIbd-23_Mochalov_D.V._Locom.../DrawningWarmlyLocomotive.java

52 lines
1.8 KiB
Java

import java.awt.*;
public class DrawningWarmlyLocomotive extends DrawningLocomotive{
public DrawningWarmlyLocomotive(int speed, float weight, Color bodyColor, int wheelsCount, Color extraColor, boolean pipe, boolean storage)
{
super(speed, weight, bodyColor,wheelsCount, 140, 70);
Locomotive = new EntityWarmlyLocomotive(speed, weight, bodyColor, extraColor, pipe, storage);
}
public DrawningWarmlyLocomotive(EntityLocomotive locomotive, IDrawningExtra extra) {
super(locomotive, extra);
Locomotive = locomotive;
}
@Override
public void SetColor(Color color) {
((EntityWarmlyLocomotive) Locomotive).SetColor(color);
}
public void SetExtraColor(Color color) {
((EntityWarmlyLocomotive) Locomotive).SetExtraColor(color);
}
@Override
public void DrawTransport(Graphics2D g)
{
if (Locomotive instanceof EntityWarmlyLocomotive)
{
EntityWarmlyLocomotive warmlyLocomotive = (EntityWarmlyLocomotive) Locomotive;
g.setColor(warmlyLocomotive.ExtraColor);
if (warmlyLocomotive.Pipe)
{
g.fillRect((int)_startPosX + 10, (int)_startPosY, 30, 20);
g.fillRect((int)_startPosX + 60, (int)_startPosY, 20, 20);
g.fillRect((int)_startPosX + 60, (int)_startPosY + 10, 30, 10);
}
if (warmlyLocomotive.FuelStorage)
{
g.fillRect((int)_startPosX + 120, (int)_startPosY + 10, 10, 50);
g.fillRect((int)_startPosX + 110, (int)_startPosY + 40, 20, 20);
g.fillRect((int)_startPosX + 110, (int)_startPosY, 30, 10);
}
_startPosY += 20;
super.DrawTransport((Graphics2D)g);
_startPosY -= 20;
}
}
}