Search in sources :

Example 36 with MiscType

use of megamek.common.MiscType in project megameklab by MegaMek.

the class PrintMech method printShields.

private void printShields() {
    for (Mounted m : mech.getMisc()) {
        if (((MiscType) m.getType()).isShield()) {
            String loc = mech.getLocationAbbr(m.getLocation());
            Element element;
            element = getSVGDocument().getElementById("armorDiagram" + loc);
            if (null != element) {
                hideElement(element, true);
            }
            element = getSVGDocument().getElementById("shield" + loc);
            if (null != element) {
                hideElement(element, false);
            }
            element = getSVGDocument().getElementById("shieldDC" + loc);
            if (null != element) {
                addPips(element, m.getBaseDamageCapacity(), false, PipType.CIRCLE);
            }
            element = getSVGDocument().getElementById("shieldDA" + loc);
            if (null != element) {
                addPips(element, m.getBaseDamageAbsorptionRate(), false, PipType.DIAMOND);
            }
        }
    }
}
Also used : Mounted(megamek.common.Mounted) MiscType(megamek.common.MiscType) SVGRectElement(org.w3c.dom.svg.SVGRectElement) Element(org.w3c.dom.Element)

Example 37 with MiscType

use of megamek.common.MiscType in project megameklab by MegaMek.

the class UnitUtil method getShieldDamageAbsorption.

public static int getShieldDamageAbsorption(Mech mech, int location) {
    final String METHOD_NAME = "getShieldDamageAbsorption(Mech, int)";
    for (int slot = 0; slot < mech.getNumberOfCriticals(location); slot++) {
        CriticalSlot cs = mech.getCritical(location, slot);
        if (cs == null) {
            continue;
        }
        if (cs.getType() != CriticalSlot.TYPE_EQUIPMENT) {
            continue;
        }
        Mounted m = cs.getMount();
        if (m == null) {
            getLogger().log(UnitUtil.class, METHOD_NAME, LogLevel.ERROR, "Null Mount index: " + cs.getIndex());
            m = cs.getMount();
        }
        EquipmentType type = m.getType();
        if ((type instanceof MiscType) && ((MiscType) type).isShield()) {
            return m.getBaseDamageAbsorptionRate();
        }
    }
    return 0;
}
Also used : CriticalSlot(megamek.common.CriticalSlot) Mounted(megamek.common.Mounted) MiscType(megamek.common.MiscType) EquipmentType(megamek.common.EquipmentType)

Aggregations

MiscType (megamek.common.MiscType)37 Mounted (megamek.common.Mounted)33 AmmoType (megamek.common.AmmoType)14 EquipmentType (megamek.common.EquipmentType)13 LocationFullException (megamek.common.LocationFullException)12 WeaponType (megamek.common.WeaponType)11 Vector (java.util.Vector)9 CriticalSlot (megamek.common.CriticalSlot)7 ArrayList (java.util.ArrayList)6 Weapon (megamek.common.weapons.Weapon)6 PPCWeapon (megamek.common.weapons.ppc.PPCWeapon)5 JMenuItem (javax.swing.JMenuItem)4 JPopupMenu (javax.swing.JPopupMenu)4 BattleArmor (megamek.common.BattleArmor)4 Entity (megamek.common.Entity)4 Dimension (java.awt.Dimension)3 ActionEvent (java.awt.event.ActionEvent)3 MouseEvent (java.awt.event.MouseEvent)3 MouseListener (java.awt.event.MouseListener)3 List (java.util.List)3