⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 movestep.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                break;            case MovePath.STEP_GO_PRONE :                setMp(1);                break;            case MovePath.STEP_START_JUMP :                break;            case MovePath.STEP_UP :                setElevation(elevation+1);                setMp(parent.isJumping()?0:1);                break;            case MovePath.STEP_DOWN :                 setElevation(elevation-1);                setMp(parent.isJumping()?0:1);                break;            case MovePath.STEP_HULL_DOWN :                setMp(2);                break;            case MovePath.STEP_CLIMB_MODE_ON:                setClimbMode(true);                break;            case MovePath.STEP_CLIMB_MODE_OFF:                setClimbMode(false);                break;            default :                setMp(0);        }        // Update the entity's total MP used.        addMpUsed(getMp());        // Check for a stacking violation.        final Entity violation =            Compute.stackingViolation( game, entity.getId(), getPosition() );        if ( violation != null             && getType() != MovePath.STEP_CHARGE             && getType() != MovePath.STEP_DFA ) {            setStackingViolation(true);        }        // set moveType, illegal, trouble flags        this.compileIllegal(game, entity, prev);    }    /**     * Returns whether the two step types contain opposite turns     */    boolean oppositeTurn(MoveStep turn2) {        switch (type) {            case MovePath.STEP_TURN_LEFT :                return turn2.getType() == MovePath.STEP_TURN_RIGHT;            case MovePath.STEP_TURN_RIGHT :                return turn2.getType() == MovePath.STEP_TURN_LEFT;            default :                return false;        }    }        public void setElevation(int el) {        elevation=el;    }    /**     * Takes the given state as the previous state and sets flags from it.     *      * @param game     * @param prev     */    public void copy(final IGame game, MoveStep prev) {        if (prev == null) {            setFromEntity(parent.getEntity(), game);            return;        }        this.hasJustStood = prev.hasJustStood;        this.facing = prev.getFacing();        this.position = prev.getPosition();        this.distance = prev.getDistance();        this.mpUsed = prev.mpUsed;        this.totalHeat = prev.totalHeat;        this.isPavementStep = prev.isPavementStep;        this.onlyPavement = prev.onlyPavement;        this.thisStepBackwards = prev.thisStepBackwards;        this.isProne = prev.isProne;        this.isHullDown = prev.isHullDown;        this.climbMode = prev.climbMode;        this.isRunProhibited = prev.isRunProhibited;        this.hasEverUnloaded = prev.hasEverUnloaded;        this.elevation = prev.elevation;    }    /**     * Sets this state as coming from the entity.     *      * @param entity     */    public void setFromEntity(Entity entity, IGame game) {        this.position = entity.getPosition();        this.facing = entity.getFacing();        // elevation        this.mpUsed = entity.mpUsed;        this.distance = entity.delta_distance;        this.isProne = entity.isProne();        isHullDown = entity.isHullDown();        climbMode = entity.climbMode();                this.elevation = entity.getElevation();        movementType = entity.moved;                int nMove = entity.getMovementMode();        // check pavement & water        if (position != null) {            IHex curHex = game.getBoard().getHex(position);            if (curHex.hasPavement()) {                onlyPavement = true;                isPavementStep = true;            }            //if entity already moved into water it can't run now            if(curHex.containsTerrain(Terrains.WATER)                    && entity.getElevation() < 0                    && distance > 0                    && nMove != IEntityMovementMode.NAVAL                    && nMove != IEntityMovementMode.HYDROFOIL                    && nMove != IEntityMovementMode.SUBMARINE) {                isRunProhibited = true;            }        }    }    /**     * Adjusts facing to comply with the type of step indicated.     *      * @param stepType     */    public void adjustFacing(int stepType) {        facing = MovePath.getAdjustedFacing(facing, stepType);    }    /**     * Moves the position one hex in the direction indicated. Does not change     * facing.     *      * @param dir     */    public void moveInDir(int dir) {        position = position.translated(dir);        if (!parent.game.getBoard().contains(position)) {            throw new RuntimeException("Coordinate off the board.");        }    }    /**     * Adds a certain amount to the distance parameter.     *      * @param increment     */    public void addDistance(int increment) {        distance += increment;    }    /**     * Adds a certain amount to the mpUsed parameter.     *      * @param increment     */    public void addMpUsed(int increment) {        mpUsed += increment;    }    /**     * @return     */    public boolean isDanger() {        return danger;    }    /**     * @return     */    public int getDistance() {        return distance;    }    /**     * @return     */    public int getFacing() {        return facing;    }    /**     * @return     */    public boolean isFirstStep() {        return firstStep;    }    /**     * @return     */    public boolean isHasJustStood() {        return hasJustStood;    }    public boolean isPavementStep() {        return isPavementStep;    }    /**     * @return     */    public boolean isProne() {        return isProne;    }    public boolean isHullDown() {        return isHullDown;    }    public boolean climbMode() {        return climbMode;    }    /**     * @return     */    public boolean isTurning() {        return isTurning;    }    /**     * @return     */    public boolean isUnloaded() {        return isUnloaded;    }    /**     * @return     */    public boolean isUsingMASC() {        return isUsingMASC;    }    /**     * Determine if this is a legal step.     *     * @return <code>true</code> if the step is legal.  <code>false</code>     *          otherwise.     */    public boolean isLegal() {        // A step is legal if it's static movement type is not illegal,        // and it is either a valid end position, or not an end position.        return ( movementType != IEntityMovementType.MOVE_ILLEGAL                 && (isLegalEndPos() || !isEndPos) );    }    /**     * Return this step's movement type.     *     * @return the <code>int</code> constant for this step's movement type.     */    public int getMovementType() {        int moveType = movementType;        // If this step's position is the end of the path, and it is not        // a valid end postion, then the movement type is "illegal".        if (!isLegalEndPos() && isEndPos) {            moveType = IEntityMovementType.MOVE_ILLEGAL;        }        return moveType;    }    /**     * Check to see if this step's position is a valid end of a path.     *     * @return <code>true</code> if this step's position is a legal end     *          of a path.  If the step is not legal for an end of a path,     *          then <code>false</code> is returned.     */    public boolean isLegalEndPos() {        // Can't be a stacking violation.        boolean legal = true;        if (isStackingViolation) {            legal = false;        } else if (terrainInvalid) {            // Can't be into invalid terrain.            legal = false;        } else if (parent.isJumping() && distance == 0) {            // Can't jump zero hexes.            legal = false;        } else if (hasEverUnloaded && this.type != MovePath.STEP_UNLOAD) {            // Can't be after unloading BA/inf            legal = false;        }        return legal;    }    /**     * Update this step's status as the ending position of a path.     *     * @param isEnd the <code>boolean</code> flag that specifies that this     *          step's position is the end of a path.     * @return <code>true</code> if the path needs to keep updating the steps.     *         <code>false</code> if the update of the path is complete.     *     * @see <code>#isLegalEndPos()</code>     * @see <code>#isEndPos</code>     * @see <code>MovePath#addStep( MoveStep )</code>     */    public boolean setEndPos( boolean isEnd ) {        // A step that is always illegal is always the end of the path.        if ( IEntityMovementType.MOVE_ILLEGAL == movementType ) isEnd = true;        // If this step didn't already know it's status as the ending        // position of a path, then there are more updates to do.        boolean moreUpdates = (this.isEndPos != isEnd);        this.isEndPos = isEnd;        return moreUpdates;    }    /**     * @return     */    public int getMpUsed() {        return mpUsed;    }    /**     * @return     */    public boolean isOnlyPavement() {        return onlyPavement;    }    /**     * @return     */    public boolean isPastDanger() {        return pastDanger;    }    /**     * @return     */    public Coords getPosition() {        return position;    }    /**     * @return     */    public boolean isPrevStepOnPavement() {        return prevStepOnPavement;    }    /**     * @return     */    public int getTargetNumberMASC() {        return targetNumberMASC;    }    /**     * @return     */    public boolean isThisStepBackwards() {        return thisStepBackwards;    }    /**     * @param b     */    public void setDanger(boolean b) {        danger = b;    }    /**     * @param i     */    public void setDistance(int i) {        distance = i;    }    /**     * @param i     */    public void setFacing(int i) {        facing = i;    }    /**     * @param b     */    public void setFirstStep(boolean b) {        firstStep = b;    }    /**     * @param b     */    public void setHasJustStood(boolean b) {        hasJustStood = b;    }    /**     * @param b     */    public void setPavementStep(boolean b) {        isPavementStep = b;    }    /**     * @param b     */    public void setProne(boolean b) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -