Package megamek.common

Examples of megamek.common.VTOL


                    game.addPSR(new PilotingRollData(bm.getId(), 6, "hit by nuclear blast"));
                }
            } else if (o instanceof VTOL) {
                // Needs a piloting check at +6 to avoid crashing.
                // Wheeeeee!
                VTOL vt = (VTOL) o;

                // Check only applies if it's in the air.
                // FIXME: is this actually correct? What about
                // buildings/bridges?
                if (vt.getElevation() > 0) {
                    game.addPSR(new PilotingRollData(vt.getId(), 6, "hit by nuclear blast"));
                }
            } else if (o instanceof Tank) {
                // As per official answer on the rules questions board...
                // Needs a piloting check at +6 to avoid a 1-level fall...
                // But ONLY if a hover-tank.
View Full Code Here


    public Vector<BackGroundDrawer> getBackgroundDrawers() {
        return bgDrawers;
    }

    public void setEntity(Entity e) {
        VTOL t = (VTOL) e;
        int a = 1;
        int a0 = 1;
        int x = 0;
        for (int i = 1; i <= 8; i++) {
            switch (i) {
                case 1:
                    x = 1;
                    break;
                case 2:
                    x = 2;
                    break;
                case 3:
                    x = 2;
                    break;
                case 4:
                    x = 3;
                    break;
                case 5:
                    x = 3;
                    break;
                case 6:
                    x = 4;
                    break;
                case 7:
                    x = 5;
                    break;
                case 8:
                    x = 5;
                    break;
            }
            a = t.getArmor(x);
            a0 = t.getOArmor(x);
            vLabels[i].setValue(t.getArmorString(x));
            WidgetUtils.setAreaColor(areas[i], vLabels[i], (double) a
                    / (double) a0);
        }
        for (int i = 9; i <= 15; i++) {
            switch (i) {
                case 9:
                    x = 1;
                    break;
                case 10:
                    x = 2;
                    break;
                case 11:
                    x = 2;
                    break;
                case 12:
                    x = 3;
                    break;
                case 13:
                    x = 3;
                    break;
                case 14:
                    x = 4;
                    break;
                case 15:
                    x = 5;
                    break;
            }
            a = t.getInternal(x);
            a0 = t.getOInternal(x);
            vLabels[i].setValue(t.getInternalString(x));
            WidgetUtils.setAreaColor(areas[i], vLabels[i], (double) a
                    / (double) a0);
        }
        if (t instanceof SupportVTOL)
            vLabels[16].setValue(String.valueOf(((SupportVTOL)t).getBARRating()));
View Full Code Here

    public Vector<BackGroundDrawer> getBackgroundDrawers() {
        return bgDrawers;
    }

    public void setEntity(Entity e) {
        VTOL t = (VTOL) e;
        int a = 1;
        int a0 = 1;
        int x = 0;
        for (int i = 1; i <= 8; i++) {
            switch (i) {
                case 1:
                    x = 1;
                    break;
                case 2:
                    x = 2;
                    break;
                case 3:
                    x = 2;
                    break;
                case 4:
                    x = 3;
                    break;
                case 5:
                    x = 3;
                    break;
                case 6:
                    x = 4;
                    break;
                case 7:
                    x = 5;
                    break;
                case 8:
                    x = 5;
                    break;
            }
            a = t.getArmor(x);
            a0 = t.getOArmor(x);
            vLabels[i].setValue(t.getArmorString(x));
            WidgetUtils.setAreaColor(areas[i], vLabels[i], (double) a
                    / (double) a0);
        }
        for (int i = 9; i <= 15; i++) {
            switch (i) {
                case 9:
                    x = 1;
                    break;
                case 10:
                    x = 2;
                    break;
                case 11:
                    x = 2;
                    break;
                case 12:
                    x = 3;
                    break;
                case 13:
                    x = 3;
                    break;
                case 14:
                    x = 4;
                    break;
                case 15:
                    x = 5;
                    break;
            }
            a = t.getInternal(x);
            a0 = t.getOInternal(x);
            vLabels[i].setValue(t.getInternalString(x));
            WidgetUtils.setAreaColor(areas[i], vLabels[i], (double) a
                    / (double) a0);
        }
        if (t instanceof SupportVTOL) {
            vLabels[16].setValue(String.valueOf(((SupportVTOL)t).getBARRating()));
View Full Code Here

    public BLKVTOLFile(BuildingBlock bb) {
        dataFile = bb;
    }

    public Entity getEntity() throws EntityLoadingException {
        VTOL t = new VTOL();

        if (!dataFile.exists("Name")) {
            throw new EntityLoadingException("Could not find name block.");
        }
        t.setChassis(dataFile.getDataAsString("Name")[0]);
        if (dataFile.exists("Model") && dataFile.getDataAsString("Model")[0] != null) {
            t.setModel(dataFile.getDataAsString("Model")[0]);
        } else {
            t.setModel("");
        }

        setTechLevel(t);

        if (dataFile.exists("source")) {
            t.setSource(dataFile.getDataAsString("source")[0]);
        }

        if (!dataFile.exists("tonnage")) {
            throw new EntityLoadingException("Could not find weight block.");
        }
        t.setWeight(dataFile.getDataAsFloat("tonnage")[0]);

        if (!dataFile.exists("motion_type")) {
            throw new EntityLoadingException("Could not find movement block.");
        }
        String sMotion = dataFile.getDataAsString("motion_type")[0];
        int nMotion = -1;
        for (int x = 0; x < MOVES.length; x++) {
            if (sMotion.equals(MOVES[x])) {
                nMotion = x;
                break;
            }
        }
        if (nMotion == -1) {
            throw new EntityLoadingException("Invalid movment type: " + sMotion);
        }
        t.setMovementMode(nMotion);

        if (dataFile.exists("transporters")) {
            String[] transporters = dataFile.getDataAsString("transporters");
            // Walk the array of transporters.
            for (String transporter : transporters) {
                // TroopSpace:
                if (transporter.startsWith("TroopSpace:", 0)) {
                    // Everything after the ':' should be the space's size.
                    Double fsize = new Double(transporter.substring(11));
                    t.addTransporter(new TroopSpace(fsize.doubleValue()));
                }

            } // Handle the next transportation component.

        } // End has-transporters

        int engineCode = BLKFile.FUSION;
        if (dataFile.exists("engine_type")) {
            engineCode = dataFile.getDataAsInt("engine_type")[0];
        }
        int engineFlags = Engine.TANK_ENGINE;
        if (t.isClan()) {
            engineFlags |= Engine.CLAN_ENGINE;
        }
        if (!dataFile.exists("cruiseMP")) {
            throw new EntityLoadingException("Could not find cruiseMP block.");
        }
        int engineRating = dataFile.getDataAsInt("cruiseMP")[0] * (int) t.getWeight() - t.getSuspensionFactor();
        t.setEngine(new Engine(engineRating, BLKFile.translateEngineCode(engineCode), engineFlags));

        if (dataFile.exists("armor_type")) {
            t.setArmorType(dataFile.getDataAsInt("armor_type")[0]);
        }
        if (dataFile.exists("armor_tech")) {
            t.setArmorTechLevel(dataFile.getDataAsInt("armor_tech")[0]);
        }
        if (dataFile.exists("internal_type")) {
            t.setStructureType(dataFile.getDataAsInt("internal_type")[0]);
        }

        if (!dataFile.exists("armor")) {
            throw new EntityLoadingException("Could not find armor block.");
        }

        int[] armor = dataFile.getDataAsInt("armor");

        if (armor.length != 5) {
            throw new EntityLoadingException("Incorrect armor array length");
        }
        // add the body to the armor array
        int[] fullArmor = new int[armor.length + 1];
        fullArmor[0] = 0;
        System.arraycopy(armor, 0, fullArmor, 1, armor.length);
        for (int x = 0; x < fullArmor.length; x++) {
            t.initializeArmor(fullArmor[x], x);
        }

        t.autoSetInternal();

        loadEquipment(t, "Front", Tank.LOC_FRONT);
        loadEquipment(t, "Right", Tank.LOC_RIGHT);
        loadEquipment(t, "Left", Tank.LOC_LEFT);
        loadEquipment(t, "Rear", Tank.LOC_REAR);
        loadEquipment(t, "Body", Tank.LOC_BODY);

        if (dataFile.exists("omni")) {
            t.setOmni(true);
        }

        return t;
    }
View Full Code Here

                    || (movementType == HMVMovementType.DISPLACEMENT_HULL)
                    || (movementType == HMVMovementType.HYDROFOIL)
                    || (movementType == HMVMovementType.SUBMARINE)) {
                vehicle = new Tank();
            } else if (movementType == HMVMovementType.VTOL) {
                vehicle = new VTOL();
            } else {
                throw new EntityLoadingException(
                        "Unsupported vehicle movement type:" + movementType);
            }
View Full Code Here

TOP

Related Classes of megamek.common.VTOL

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.