Search in sources :

Example 11 with Tank

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());
}
Also used : SimpleTechLevel(megamek.common.SimpleTechLevel) VTOL(megamek.common.VTOL) SuperHeavyTank(megamek.common.SuperHeavyTank) SuperHeavyTank(megamek.common.SuperHeavyTank) Tank(megamek.common.Tank) Engine(megamek.common.Engine)

Example 12 with Tank

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");
}
Also used : TestSupportVehicle(megamek.common.verifier.TestSupportVehicle) TestTank(megamek.common.verifier.TestTank) TestTank(megamek.common.verifier.TestTank) Tank(megamek.common.Tank)

Example 13 with Tank

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;
}
Also used : TestTank(megamek.common.verifier.TestTank) Tank(megamek.common.Tank)

Example 14 with Tank

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;
}
Also used : Tank(megamek.common.Tank) TestTank(megamek.common.verifier.TestTank)

Aggregations

Tank (megamek.common.Tank)14 Aero (megamek.common.Aero)7 BattleArmor (megamek.common.BattleArmor)6 File (java.io.File)5 Infantry (megamek.common.Infantry)5 Mech (megamek.common.Mech)5 TestTank (megamek.common.verifier.TestTank)5 Entity (megamek.common.Entity)4 VTOL (megamek.common.VTOL)4 Image (java.awt.Image)3 ImageIcon (javax.swing.ImageIcon)3 SmallCraft (megamek.common.SmallCraft)3 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 FixedWingSupport (megamek.common.FixedWingSupport)2 MechFileParser (megamek.common.MechFileParser)2 TestSupportVehicle (megamek.common.verifier.TestSupportVehicle)2 Frame (java.awt.Frame)1