use of megamek.common.Tank in project megameklab by MegaMek.
the class MainUI method createNewUnit.
@Override
public void createNewUnit(long entityType, boolean isPrimitive, boolean isIndustrial, Entity oldEntity) {
if (entityType == Entity.ETYPE_VTOL) {
setEntity(new VTOL());
getEntity().setTechLevel(TechConstants.T_INTRO_BOXSET);
getEntity().setWeight(20);
getEntity().setMovementMode(EntityMovementMode.VTOL);
} else {
if (entityType == Entity.ETYPE_SUPER_HEAVY_TANK) {
setEntity(new SuperHeavyTank());
getEntity().setTechLevel(TechConstants.T_IS_ADVANCED);
getEntity().setWeight(51);
} else {
setEntity(new Tank());
getEntity().setTechLevel(TechConstants.T_INTRO_BOXSET);
getEntity().setWeight(20);
}
getEntity().setMovementMode(EntityMovementMode.HOVER);
}
Tank tank = (Tank) getEntity();
tank.setYear(3145);
tank.setEngine(new Engine(Math.max(10, (int) getEntity().getWeight() - tank.getSuspensionFactor()), Engine.NORMAL_ENGINE, Engine.TANK_ENGINE));
tank.autoSetInternal();
for (int loc = 0; loc < getEntity().locations(); loc++) {
tank.initializeArmor(0, loc);
}
getEntity().setArmorType(EquipmentType.T_ARMOR_STANDARD);
getEntity().setArmorTechLevel(TechConstants.T_INTRO_BOXSET);
getEntity().setStructureType(EquipmentType.T_STRUCTURE_STANDARD);
tank.setHasNoDualTurret(true);
if (Entity.ETYPE_VTOL == entityType) {
tank.setHasNoTurret(true);
}
if (null == oldEntity) {
tank.setChassis("New");
tank.setModel("Tank");
tank.setYear(3145);
} else {
tank.setChassis(oldEntity.getChassis());
tank.setModel(oldEntity.getModel());
tank.setYear(Math.max(oldEntity.getYear(), tank.getConstructionTechAdvancement().getIntroductionDate()));
tank.setSource(oldEntity.getSource());
tank.setManualBV(oldEntity.getManualBV());
SimpleTechLevel lvl = SimpleTechLevel.max(tank.getStaticTechLevel(), SimpleTechLevel.convertCompoundToSimple(oldEntity.getTechLevel()));
tank.setTechLevel(lvl.getCompoundTechLevel(oldEntity.isClan()));
tank.setMixedTech(oldEntity.isMixedTech());
tank.setMovementMode(oldEntity.getMovementMode());
}
tank.setOriginalWalkMP((tank.getEngine().getRating() + tank.getSuspensionFactor()) / (int) tank.getWeight());
}
use of megamek.common.Tank in project megameklab by MegaMek.
the class StatusBar method refresh.
public void refresh() {
int walk = getTank().getOriginalWalkMP();
int run = getTank().getRunMP(true, true, false);
int jump = getTank().getOriginalJumpMP();
double tonnage = getTank().getWeight();
double currentTonnage;
int bv = getTank().calculateBattleValue();
if (getTank().isSupportVehicle()) {
testEntity = new TestSupportVehicle(getTank(), entityVerifier.tankOption, null);
} else {
testEntity = new TestTank((Tank) getTank(), entityVerifier.tankOption, null);
}
currentTonnage = testEntity.calculateWeight();
currentTonnage += UnitUtil.getUnallocatedAmmoTonnage(getTank());
long currentCost = (long) Math.round(getTank().getCost(false));
tons.setText("Tonnage: " + currentTonnage + "/" + tonnage);
tons.setToolTipText("Current Tonnage/Max Tonnage");
if (currentTonnage > tonnage) {
tons.setForeground(Color.red);
} else {
tons.setForeground(Color.black);
}
Tank tank = getTank();
int currentSlots = tank.getTotalSlots() - tank.getFreeSlots();
slots.setText("Slots: " + currentSlots + "/" + tank.getTotalSlots());
if (currentSlots > tank.getTotalSlots()) {
slots.setForeground(Color.red);
} else {
slots.setForeground(Color.black);
}
bvLabel.setText("BV: " + bv);
bvLabel.setToolTipText("BV 2.0");
cost.setText("Cost: " + formatter.format(currentCost) + " C-bills");
move.setText("Movement: " + walk + "/" + run + "/" + jump);
move.setToolTipText("Walk/Run/Jump MP");
}
use of megamek.common.Tank in project megameklab by MegaMek.
the class StatusBar method slotsPanel.
public JPanel slotsPanel() {
Tank tank = getTank();
int currentSlots = tank.getTotalSlots() - tank.getFreeSlots();
slots.setText("Slots: " + currentSlots + "/" + tank.getTotalSlots());
slotsPanel.add(slots);
return slotsPanel;
}
use of megamek.common.Tank in project megameklab by MegaMek.
the class CVStatusBar method slotsPanel.
public JPanel slotsPanel() {
Tank tank = getTank();
int currentSlots = tank.getTotalSlots() - tank.getFreeSlots();
slots.setText("Slots: " + currentSlots + "/" + tank.getTotalSlots());
slotsPanel.add(slots);
return slotsPanel;
}
Aggregations