Android Open Source - block-composer Move






From Project

Back to project page block-composer.

License

The source code is released under:

MIT License

If you think the Android project block-composer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package bwr.blockcomposer.gamedata;
/* ww  w  .j  a v a2s.  c  om*/
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.LinkedList;

import bwr.blockcomposer.types.IntVector;

public class Move { 
  private static final byte BLOCK_MOVEMENT_ID = 0;
  private static final byte BLOCK_REMOVAL_ID = 1;

  public final IntVector previousPlayerLocation = new IntVector();
  public final LinkedList<Step> steps = new LinkedList<Step>();
  
  static public interface Step {}
  
  static public class BlockMovement implements Step {
    public final IntVector from = new IntVector();
    public final IntVector to = new IntVector();
  }
  
  static public class BlockRemoval implements Step {
    public Block removedBlock;
  }
  
  public static Move readFrom(DataInputStream in) throws IOException {
    Move m = new Move();
    m.previousPlayerLocation.readFrom(in);
    
    int numSteps = in.readInt();
    byte type;
    for(int i = 0; i < numSteps; i++) {
      type = in.readByte();
      if(type == BLOCK_MOVEMENT_ID) {
        BlockMovement movement = new BlockMovement();
        movement.from.readFrom(in);
        movement.to.readFrom(in);
        m.steps.add(movement);
      } else if(type == BLOCK_REMOVAL_ID) {
        BlockRemoval removal = new BlockRemoval();
        removal.removedBlock = Block.readFrom(in);
        m.steps.add(removal);
      }
    }
    
    return m;
  }
  
  public void writeTo(DataOutputStream out) throws IOException {
    previousPlayerLocation.writeTo(out);
    out.writeInt(steps.size());
    for(Step s : steps) {
      if(s instanceof BlockMovement) {
        out.writeByte(BLOCK_MOVEMENT_ID);
        BlockMovement movement = (BlockMovement) s;
        movement.from.writeTo(out);
        movement.to.writeTo(out);
      } else if(s instanceof BlockRemoval) {
        out.writeByte(BLOCK_REMOVAL_ID);
        BlockRemoval removal = (BlockRemoval) s;
        removal.removedBlock.writeTo(out);
      }
    }
  }
}




Java Source Code List

bwr.blockcomposer.AnimationFinishedListener.java
bwr.blockcomposer.BlockComposerActivity.java
bwr.blockcomposer.BlockComposerRenderer.java
bwr.blockcomposer.BlockComposer.java
bwr.blockcomposer.Camera.java
bwr.blockcomposer.GameResources.java
bwr.blockcomposer.OnUpdateAction.java
bwr.blockcomposer.gamedata.Block.java
bwr.blockcomposer.gamedata.GameEntity.java
bwr.blockcomposer.gamedata.GameState.java
bwr.blockcomposer.gamedata.LevelDimensions.java
bwr.blockcomposer.gamedata.LevelMask.java
bwr.blockcomposer.gamedata.LevelMetadata.java
bwr.blockcomposer.gamedata.LevelStore.java
bwr.blockcomposer.gamedata.Level.java
bwr.blockcomposer.gamedata.Move.java
bwr.blockcomposer.gamedata.StaticLevelStore.java
bwr.blockcomposer.gamedata.UserLevelStore.java
bwr.blockcomposer.misc.GLUtility.java
bwr.blockcomposer.misc.Timer.java
bwr.blockcomposer.models.AxisRenderer.java
bwr.blockcomposer.models.Model.java
bwr.blockcomposer.models.SelectBoxRenderer.java
bwr.blockcomposer.modes.EditMode.java
bwr.blockcomposer.modes.GameDialogMode.java
bwr.blockcomposer.modes.GameMode.java
bwr.blockcomposer.modes.LevelImportMode.java
bwr.blockcomposer.modes.LevelSelectMode.java
bwr.blockcomposer.modes.LogoDisplayMode.java
bwr.blockcomposer.modes.ModeController.java
bwr.blockcomposer.modes.Mode.java
bwr.blockcomposer.modes.OverlayMode.java
bwr.blockcomposer.types.FlipRotateFloat.java
bwr.blockcomposer.types.FloatValueVector3.java
bwr.blockcomposer.types.FloatValue.java
bwr.blockcomposer.types.IntVector.java
bwr.blockcomposer.types.RotatingFloat.java
bwr.blockcomposer.ui.TextRenderer.java
bwr.blockcomposer.ui.UIElementPicture.java
bwr.blockcomposer.ui.UIElementText.java
bwr.blockcomposer.ui.UIElement.java